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

时间:2015-01-28 12:30:40

标签: bundle edit kabel-bundleplus

我正在使用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

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

任何帮助?

1 个答案:

答案 0 :(得分:-1)

我已经修好了,如果有人有兴趣,这里是解决方案

替换两行

$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;