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.
XHTML
1 |
http://www.mydomain.com/checkout/cart/add?product=[id]&qty=[qty] |
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:
XHTML
1 |
http://www.mydomain.com/checkout/cart/add?product=[id]&qty=[qty]&options[id]=[value] |
You can get the options id and value by viewing the source of the simple product page and it’s dropdowns.