Magento is truly a powerful and flexible platform! I enjoy working with it more and more every day. I recently came across the need to add a product to the cart VIA the Querystring/URL. Guess what? Magento can do it and I’ll show you how!
Simple products are the easiest to add because there are fewer options that need to be passed. The basic structure is as follows.
Where [id] is the Magento ID of the product and [qty] is the Quantity you wish to add.
To add a simple product with custom options simply add options[id]=[value] to the end. The basic structure is:
You can get the options id and value by viewing the source of the simple product page and it’s dropdowns.
Hey, that’s pretty awesome. Would you know if you can reuse option sets for a whole category of simple products?
I just tried this to add products with custom options through url in cart, but it didnt worked 🙁 .
Could you please give me a working url or example url.
This is the code of my custom options on product details page.
Thanks in advance !!
code is eliminated from last post ..
i am posting it again
Thanks – any idea how to do this with configurable products? I’ve tried by adding the configurable option IDs but no dice 🙂
Thanks! Exactly what I was looking for.
Thank you for that share!
@molecule , YES its absolutely possible, Here’s an example:
to break this down:
Product ID: Your configurable product ID, found in managing products through the backend
options: The “98” is an option I added for the user to write something in a text area, you can find this number by inspecting the element on the product view page through firefox’s firebug tool. Look at the element and look for it’s name, for this text area it was “options”
super_attribute: same as above, although this is the associated product, not an option, the “157” is the defined selection in the dropdown, also found using firebug.
This is very handy. Do you know if it’s possible to remove an item from the cart via querystring as well?
Is there a way to add products via query string using the SKU without modifying any code? I have tried various methods with no luck.
I am working on a Magento theme using this method to add things to a cart as well. I just figured I would add this URL to further help people that found this useful blog post, thanks!
I actually just want to set the option via url and display that product with all the options set… is that possible?
Thanks. It worked for me.
The above code does not works for price.
I added a product with price 0
and custom options with price 100, but it is passing only the product price not the option price
Help me with this please.
I’m doing a project in magento. I want that users can add to cart configurable products directly from category page. They no need to go to product view page. When i disable product view page and addtocart on category page, i get an error message “options required”. How can i make this? Please help me.