且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式将带有自定义选项的产品添加到Magento中的购物车?

更新时间:2023-11-26 23:06:22

如果您已经有报价ID,则使用

If you have already a quote id then used

在下面..

要获取选项ID和选项值,请检查以下链接: Magento-从以下位置获取产品选项$ item

For getting option id and option value check this link: Magento - Get Product options from $item

在这里您需要获取产品下拉选项值 如果您需要创建新报价,则可以在

Here you need to fetch product drop down option value If you need to create new quote then used add below

$QuoteId= Mage::getModel('checkout/cart_api')->create('default');

此处defaultstore code. 如果您已经有报价单ID,则无需添加大写代码

Here default is store code . IF you have already a quote id then not need to add upper code

$arrProducts = array(
    array(
        "product_id" => $productId,
        "qty" => 5,
        "options" => array(         
                $optionId => $optinValueId
                 )
    )
);
Mage::getModel('checkout/cart_product_api')->add($QuoteId,$arrProducts,$storeId);