1

我正在使用 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 .= ‘&amp;bundle_option[‘ . $option->option_id . ‘]=’ . $option->selection_id;
$bundleOptions .= ‘&amp;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(‘&lt;?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

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

有什么帮助吗?

4

1 回答 1

-1

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

替换这两行

$bundleOptions .= ‘&amp;bundle_option[‘ . $option->option_id . ‘]=’ . $option->selection_id;
$bundleOptions .= ‘&amp;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;
于 2015-01-29T09:14:59.443 回答