I'm trying to add to cart a bundle product with default options (options already selected from backend) using the setLocationAjax function. I managed to get the correct url to add which will be javascript:setLocationAjax('http://example.com/checkout/cart/add/uenc/aHR0cDovL2lsYWVtcy5jb20vc2FuZHdpY2hlcy5odG1s/product/29/form_key/YMC8gewJKkZd3QK6/?&bundle_option[2]=4&bundle_option_qty[2]=1.0000&bundle_option[3]=6&bundle_option_qty[3]=10.0000&bundle_option[4]=13&bundle_option_qty[4]=5.0000')

for some reason I'm getting the message "Please specify product option(s)." while if I'm not using ajax it will work fine.

any ideas what is missing here.


2 Answers 2


It's probably due to your form key expiring. If you're trying to paste this in after it's generated then you'll need to ensure that it has a fresh form key. Try adding it like this:

$form_key = Mage::getSingleton('core/session')->getFormKey();
echo "javascript:setLocationAjax('http://example.com/checkout/cart/add/product/29/form_key/".$form_key."/?&bundle_option[2]=4&bundle_option_qty[2]=1.0000&bundle_option[3]=6&bundle_option_qty[3]=10.0000&bundle_option[4]=13&bundle_option_qty[4]=5.0000')";
  • Thanks for your reply but it didn't work. any other suggestions?
    – liza
    Jan 26, 2015 at 8:41
  • In bundle_option[X] is X the actual option ID or are you just making them 1,2,3,4? The X should be the option ID. Jan 26, 2015 at 14:06

yes as I used this code

$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): if($option->is_default ==1){ $bundleOptions .= '&bundle_option[' . $option->option_id . ']=' . $option->selection_id; $bundleOptions .= '&bundle_option_qty[' . $option->option_id . ']=' . $option->selection_qty; } endforeach; $productAddUrl .= $bundleOptions;

The funny thing is if I turn off the ajax the add to cart button will work fine and the product is added to the cart with the correct default option but if I turn off the ajax it gives me this error "Please specify product option(s)."

BTW: I'm using kallyas theme.

Your Answer

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

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