I'm working on M2 rest API's. I'm getting zero price issue in the same API.

How to re-create issue:

1. Create new customer through rest API.
2. Login with the registered customer.
3. Now add the product to cart.
4. Now check the cart info through rest API URL.

Now cart showing zero price with zero total.

If you again add a new product or same product again. The correct price will be displayed.

The zero price issue always comes only in case of new customers. 

Request URL with parameters:
SKU, qty, user_id

Please check screenshots of the response:

enter image description here

enter image description here

3 Answers 3


I had same issue and fixed it on the Magento side with following plugin

// app/code/Custom/Rest/Plugin/Model/Quote/Item/RepositoryPlugin.php

 * Created by PhpStorm.
 * User: Dmytro Portenko
 * Date: 10/16/18
 * Time: 10:36 PM
namespace Custom\Rest\Plugin\Model\Quote\Item;
class RepositoryPlugin
     * Quote repository.
     * @var \Magento\Quote\Api\CartRepositoryInterface
    protected $quoteRepository;
     * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
    public function __construct(
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
    ) {
        $this->quoteRepository = $quoteRepository;
    public function beforeSave(
        \Magento\Quote\Model\Quote\Item\Repository $subject,
        \Magento\Quote\Api\Data\CartItemInterface $cartItem
        $cartId = $cartItem->getQuoteId();
        $quote = $this->quoteRepository->getActive($cartId);

// app/code/Custom/Rest/etc/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Quote\Model\Quote\Item\Repository">
        <plugin sortOrder="1" name="customRestRepository" type="Custom\Rest\Plugin\Model\Quote\Item\RepositoryPlugin"/>

After create a new cart by API, POST a cart address by API rest/V1/carts/mine/billing-address, the POST body could be empty like below

    "address" :     {


    "cartId" : "{the cartId get from the cart you created just now}"

then the problem will be solved.

More information you could get from Products added to cart with REST API give total prices equal to zero


Follow the below steps to resolve this issue

step 1) Go to file 'vendor/magento/module-quote/Model/QuoteManagement.php'(override this file using preference don't make change in core files)

step 2) Edit this function 'createEmptyCartForCustomer'.

step 3) In try before saving quote line number 234 add below code

  • Thank you so much. It worked like charm. +1 Jun 23, 2020 at 12:13
  • Hi @jyoti , Subtotal and Grand total fixed with this. But Tax is still coming as 0.00 Any suggestions? Jun 27, 2020 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.