Magento 1.8 Cart – Fix Adding to Cart with Querystring Redirecting to Homepage

cartmagento-1.8PHPquery

I'm trying to add a product to my cart via query string based on the information on the Magento website.

I've tried the following:

  • /checkout/cart/add/product/3887/1/
  • /checkout/cart/add/product/3887/1/e8JDefUuLcGdLE1Q (Added Form Key)
  • /checkout/cart/add?product=3887&qty=1

The Product ID here is 3887 and it's a Simple product, with no special or custom options.
I'm trying to send it through Ajax but it doesn't get put in the cart and then when I attempt to enter the URL directly I just get redirected to the homepage.

I'm getting the Product ID from a custom page where customers will be able to enter a list of SKU's into 10 input boxes (Quickshop page)

Thanks in advance!

SOLUTION for others:

URL must follow this:

/checkout/cart/add/product/PRODUCTID/qty/NUMBER/form_key/WSFiE69HmvU854G2 

Best Answer

The url for adding needs to include a form_key.

/checkout/cart/add/product/554/form_key/QOTCSV8HqoLA0K3T/
Related Topic