从产品列表页面添加到购物车后无法编辑捆绑产品



我正在使用 kable-bundleplus 模块,并且我在产品列表页面上为我的捆绑产品添加了添加到购物车按钮,这些产品使用以下代码具有默认值:

<?php
$productAddUrl = $this->helper(‘checkout/cart’)->getAddUrl($_product);
if ($_product->getTypeId() == ‘bundle’):
$bundleOptions = ‘?';
$selectionCollection = $_product->getTypeInstance(true)->getSelectionsCollection($_product->getTypeInstance(true)->getOptionsIds($_product), $_product);
foreach($selectionCollection as $option):
$bundleOptions .= ‘&bundle_option[‘ . $option->option_id . ‘]=’ . $option->selection_id;
$bundleOptions .= ‘&bundle_option_qty[‘ . $option->option_id . ‘]=’ . $option->selection_qty;
endforeach;
$productAddUrl .= $bundleOptions;
endif;
?>
<button type="button" title="<?php echo $this->__(‘Add to Cart’) ?>" class="button btn-cart" onclick="setLocation(‘<?php echo $productAddUrl ?>’)"><span><span><?php echo $this->__(‘Add to Cart’) ?></span></span></button> <?php else: ?>

我从这里得到它http://understandinge.com/forum/all-things-coding/add-a-bundle-product-to-cart-from-category-page/

一切正常,产品以默认数量的正确默认选项添加到购物车中。但是当我从购物车页面按编辑时,我看到所有选项都具有默认数量值,并且出现脚本错误:

Uncaught TypeError: Cannot read property 'customQty' of undefined
Uncaught TypeError: Cannot read property 'reloadPrice' of undefined

当我按下复选框更改数量时,我得到了这个

Uncaught TypeError: Cannot read property 'changeSelection' of undefined

我认为问题出在用于将产品添加到购物车的网址中,但我不确定如何。

有什么帮助吗?

我已经修复了它,如果有人感兴趣,这是解决方案

替换两行

$bundleOptions .= ‘&bundle_option[‘ . $option->option_id . ‘]=’ . $option->selection_id;
$bundleOptions .= ‘&bundle_option_qty[‘ . $option->option_id . ‘]=’ . $option->selection_qty;

$bundleOptions .= '&bundle_option[' . $option->option_id . '][0]=' . $option->selection_id;
$bundleOptions .= '&bundle_option_qty[' . $option->option_id . ']['.$option->selection_id.']=' . $option->selection_qty;

最新更新