Add bundle product to cart without having to specify the options

后端 未结 4 1126
-上瘾入骨i
-上瘾入骨i 2021-02-03 13:30

I have bundle products with 3 checkboxes checked as default. I want to add a bundle product from the page category list (list.phtml) without having to specify the o

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 14:08

    My project needed to only show a single line for a bundle product, hidden options default selected and purchased when buying the bundle. The product had be buyable from the category view.

    Bundle config:

    • Bundle with dynamic price
    • Options are configured to be required, default values and radio buttons default selected values

    I went into my custom category view template and added the following:

    getTypeId() == 'bundle'){ $selectionCollection = $_product->getTypeInstance(true)->getSelectionsCollection( $_product->getTypeInstance(true)->getOptionsIds($_product), $_product ); foreach($selectionCollection as $option) { echo ''; echo ''; }//end: foreach $selectionCollection } // end: if $_product == bundle ?>

    The above creates a add-to-cart-form, retrieves the bundle sub-products if we have a bundle and defaults all the options. Works like a charm!

提交回复
热议问题