2

I created a landing page on an external site and I want to be able to add to cart from that external site. Is there any hack I can use to do this? Is there a custom URL I can use? I am using Magento 2.

1

You can use Magento 2 REST API

Add a simple product to a cart

To add a simple product to a cart, you must provide a sku, the quantity, and the quote ID, which was generated when the cart was created.

The following example adds an orange medium-sized Radiant women’s t-shirt (sku: WS12-M-Orange) to the cart.

Endpoint

POST http:///rest/default/V1/carts/mine/items

Headers

Content-Type application/json

Authorization Bearer

Payload

{
  "cartItem": {
    "sku": "WS12-M-Orange",
    "qty": 1,
    "quote_id": "4"
  }
}

Response

{
  "item_id": 7,
  "sku": "WS12-M-Orange",
  "qty": 1,
  "name": "Radiant Tee-M-Orange",
  "product_type": "simple",
  "quote_id": "4"
}

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.