我正在尝试在Magento中设置一个捆绑产品。此产品应允许客户选择4个免费产品包含在捆绑包中。这些产品可以是完全不同的,也可以是同一产品的4个。
例如
免费产品1免费产品2免费产品3
客户可以选择免费产品1中的四个,或者免费产品1和2中的一个,以及免费产品3中的两个。
我使用4个下拉输入类型,每个类型都有所有三个自由产品作为选项。因此,客户可以为每个免费礼物行项目选择三种产品中的任何一种。
Magento只显示一个下拉选择列表,我相信是因为每个下拉列表都包含相同的产品列表。
我需要在哪里查看才能阻止Magento检查产品选项是否已在以前的选择中列出?
发布于 2013-07-23 13:05:57
除非你是以编程的方式来做这件事(也就是编写代码),否则就没有办法做到这一点。
当Magento添加产品时,它首先查看报价/购物车,看看是否已经存在。如果有,它就会拉出那个,并将其添加到数量上。没有办法将其关闭。
通过编程,您可以非常手动地将项目添加到购物车中。这就是..。
$cart = Mage::getSingleton("checkout/cart");
foreach ($products_to_add as $product_id => $custom_options) {
$product = Mage::getModel("catalog/product")->load($product_id);
$options = new Varien_Object(array("options" => $custom_options,
"qty" => 1));
// some products may result in multiple products getting added to cart
// I beleive this pulls them all and sets the custom options accordingly
$add_all = $product->getTypeInstance(true)
->prepareForCartAdvanced($options, $product, Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL);
foreach ($add_all as $add_me) {
$item = Mage::getModel('sales/quote_item');
$item->setStoreId(Mage::app()->getStore()->getId());
$item->setOptions($add_me->getCustomOptions())
->setProduct($add_me);
$item->setQty(1);
$cart->getQuote()->addItem($item);
}
}
// when done adding all the items, finally call save on the cart
$cart->save();https://stackoverflow.com/questions/15304680
复制相似问题