3

I am trying to add a base product of the bundled item (with no configuration, or additional products added into the bundle). None of the configurable items are required, and the price of the bundled item is set to a fixed price.

I've attempted to try the solution given here: http://www.magentocommerce.com/boards/viewthread/17289/

 if (empty($optionIds)) {

            // return Mage::helper('bundle')->__('Please select options for product.');
            $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
            $bypass_sel_arry = $selectionCollection->getData();
            $options = array($bypass_sel_arry[0]['option_id']=>$bypass_sel_arry[0]['selection_id']);

  } 

But I've noticed that when the item gets added to cart, it automatically picks up the first option in the configurable items.

Any help would be appreciated.

3
  • That shouldn't happen, if you're setting on of the bundled items as required and the rest as not required then the add to cart should simply work by adding the bundle with just the required "base" product. Commented Jan 20, 2014 at 10:09
  • And if you're setting all bundled items as not required then it does not allow you to add any of them to cart until you chose at least one option. It just redirects you back to the product page with the error message: "Please choose product options." Commented Jan 20, 2014 at 10:10
  • @MihaiStancu that was the initial behaviour until I changed it (see my original post for more details). I need it to be able to add the product without specifying or selecting an option.
    – SNpn
    Commented Jan 20, 2014 at 22:44

1 Answer 1

0

This will need jQuery involvement. You should follow the following approach, it is bit tricky but it may resolve your problem.

  • Associate the simple product with bundle products.
  • Make the show type check-box.
  • Display the price of simple products associated in the product view page.
  • Convert the type check-box to button with text labeled as "Add to cart". This will give you many add to cart buttons on a product detail page.
  • Pass the id of the product in any attribute of the button.(This will be done via code customization)

    //Code to get ID, pass this in any of the button attribute  
    $product_id    =    $this->getProduct()->getId();
    
    //Code to get the button clicked id
    $("#btnDel").click(function(){alert(this.id);});
    
  • When the button is clicked get the id of the product and go to url http://magentoserver.com/checkout/cart/add?product=[productID]&qty;=1

  • This will add your product in the Cart.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.