Add bundle product to cart without having to specify the options

后端 未结 4 1125
-上瘾入骨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条回答
  •  孤街浪徒
    2021-02-03 14:11

    I had to do similar thing in Magento 1.7 website. I was able to add bundled product to cart from products lists without redirecting to product page.

    /app/design/frontend/your_package/your_theme/template/catalog/product/list.phtml

    Replace occurences of

    
    

    with

    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 . ']=1';
      endforeach;
    
      $productAddUrl .= $bundleOptions;
    endif;
    ?>
    
    

提交回复
热议问题