Magento – Adding item to cart using REST API magento 2 shows price as zero

magento2

I can successfully add item to the cart using this rest API from my APP.

POST /V1/carts/mine/items

However the item is added with a price of ZERO.

The new quote was created from the APP using this API.

POST /V1/carts/mine

But when I try to add an item from magento web the price is showing correct value.

I am using magento 2 .

Best Answer

Here is the solution of this issue

Open file 'vendor/magento/module-quote/Model/QuoteManagement.php'.
Find function 'createEmptyCartForCustomer'.
Add below code inside try{}  (at start of try), before line number 234
$quote->getBillingAddress();
$quote->getShippingAddress()->setCollectShippingRates(true);
After adding these 2 lines it will not show 0 price again.
Related Topic