1

I can't figure out how add a product to the cart via a "querystring" with custom options in Magento 1.8. CE I do know about the form key but that hasen't helped me yet.

Here's what I have tried! But it always goes back to the product page and tells me that I have not provided the required option. http://mydomain.com/checkout/cart/add/product/8/qty/2/options[1]/2/form_key/1tIQKeqKeloqlBzL/

This on the other hand takes me to the shooping cart, but it's empty when I get there. http://mydomain.com/checkout/cart/add?product=[9]&qty=[3]&options[1]=[3]&form_key=[1tIQKeqKeloqlBzL]

Has someone solved this?

4
  • Are your custom options set to required or is this a wrong behaviour? I guess the product page shown with required options is correct if you have custom options required. Maybe this could help you: docs.magentocommerce.com/Mage_Catalog/… Aug 10, 2014 at 12:53
  • Where are you getting that fork key value from? Isn't it different for every session? I am trying to solve a similar problem where I need the form key in order to add a simple product to cart.
    – sparecycle
    Aug 19, 2014 at 16:02
  • Have you tried to log the POST request magento sends to the cart with FireBug?
    – Amasty
    Aug 22, 2014 at 23:25
  • @Amasty No that might do the trick ;)
    – 8bitcat
    Sep 2, 2014 at 8:03

1 Answer 1

1

You can copy the code from the build in Wishlist module, that stores the $buyRequest variable. Actually it contains the custom options from the post/get request.

See app\code\core\Mage\Wishlist\controllers\IndexController.php , method _addItemToWishList and then cartAction function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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