cancel
Showing results for 
Search instead for 
Did you mean: 

Quotes and Carts

Quotes and Carts

Hello All,

 

I´m new on Magento and I´m trying to figure out the difference between "Quotes" and "Carts".

 

The problem that I´m facing is about the Magento 2 API, the version of Magento is 2.2

I´m trying to add a product in the cart using the API, and the endpoints are asking for "cartId" and "quoteId", but it is very confuse, because sometimes the api ask for cartId on URL but ignore it and use "QuoteId" inside the JSON that is send using request Body.

 

Example: (Add cart to guest)

 

1 - I create a cart for guest using POST http://"Magento Server"/index.php/rest/all/V1/guest-carts ... the documentation says, "Enable an customer or guest user to create an empty cart and quote for an anonymous customer." What is "quote" for an anonymous customer?

 

2 - Add item to the cart using POST http://"Magento Server"/index.php/rest/all/V1/guest-carts/261509098f2e7f7e4712ef78ce00cec7/items , as you can see I´m passing on the URL the Id that was returned from api endpoint on step 1, but magento ignores it, in fact it is using the id inside the json body.

 

{
"cartItem": {
"sku": "product",
"qty": 1,
"quote_id": "261509098f2e7f7e4712ef78ce00cec7",
"product_option": {
"extension_attributes": {
"custom_options": [{
"option_id": "1",
"option_value": "test"
}]
}
}
}
}

 

3 - Get the cart using http://magento.local/index.php/rest/all/V1/carts/27/items "27" is the cart id that is returned on endpoint of step 2.

 

My reference is https://devdocs.magento.com/swagger/

1 REPLY

Re: Quotes and Carts

There is no difference between carts and quotes. Its synonyms carts and quotes.

Actually, Carts are made from Quotes. When you add any product from site, one entry is generated in quote and quote_item table.

Carts display in shopping cart page while quotes are database entry for added product of cart.

 

When you create a cart for guest or registered user,

You need to create quote item for cart item and based on quote item entry you need to pass quote_item in your API. One Quote have multiple quote_item because at a time you will add multiple product to cart and each product has unique quote_item in a database.

 

So You need to focus on quote instead of cart while create cart using API. Cart is actual presentation of e-commerce site where as Quotes are hidden entity for a site and its value are resides under database table.

 

 

If Issue Solved, Click Kudos/Accept As solutions.
More info visit Blogs