Search code examples
javascriptmagentomagento2magento-2.0

Add products to cart using a HTTP request in Magento 2.0


Is it possible to add and remove products to the cart using a HTTP request in Magento 2.o?

If yes. What should the request look like (I do have access to the magento database if any data is needed for the request).

Product without options?

example.com/checkout/cart/add/product/[id]?qty=[qty]&form_key=[form_key]

Product with options?

example.com/checkout/cart/add/product/[id]?qty=[qty]&form_key=[form_key]&option1=[option1]&option2=[option2]&option3=[option3]

Solution

  • Here is an example of a link that adds the product to the cart.

    example.com/checkout/cart/add?product=[id]&qty=1&form_key=[key]&uenc=[key]