Magento 2 – Fix Cart Detail API Missing Subtotal and Total

cartmagento2rest apisubtotal

Cart API url

http://magento.host/rest/V1/carts/mine/

Authorization <Customer Token>
  • This API provided Lists items that are assigned to a specified cart.
  • But Not Subtotal and Total price of items that are assigned to a
    specified cart.

How to get sub-total and total price of items that are assigned to specified cart In REST API using Customer Token ?

Best Answer

quoteCartTotalRepositoryV1

Interface CartTotalRepositoryInterface

GET /V1/carts/mine/totals

Returns quote totals data for a specified cart.

Response data

{
  "grandTotal": 0,
  "baseGrandTotal": 0,
  "subtotal": 0,
  "baseSubtotal": 0,
  "discountAmount": 0,
  "baseDiscountAmount": 0,
  "subtotalWithDiscount": 0,
  "baseSubtotalWithDiscount": 0,
  "shippingAmount": 0,
  "baseShippingAmount": 0,
  "shippingDiscountAmount": 0,
  "baseShippingDiscountAmount": 0,
  "taxAmount": 0,
  "baseTaxAmount": 0,
  "weeeTaxAppliedAmount": 0,
  "shippingTaxAmount": 0,
  "baseShippingTaxAmount": 0,
  "subtotalInclTax": 0,
  "baseSubtotalInclTax": 0,
  "shippingInclTax": 0,
  "baseShippingInclTax": 0,
  "baseCurrencyCode": "string",
  "quoteCurrencyCode": "string",
  "couponCode": "string",
  "itemsQty": 0,
  "items": [
    {
      "itemId": 0,
      "price": 0,
      "basePrice": 0,
      "qty": 0,
      "rowTotal": 0,
      "baseRowTotal": 0,
      "rowTotalWithDiscount": 0,
      "taxAmount": 0,
      "baseTaxAmount": 0,
      "taxPercent": 0,
      "discountAmount": 0,
      "baseDiscountAmount": 0,
      "discountPercent": 0,
      "priceInclTax": 0,
      "basePriceInclTax": 0,
      "rowTotalInclTax": 0,
      "baseRowTotalInclTax": 0,
      "options": "string",
      "weeeTaxAppliedAmount": 0,
      "weeeTaxApplied": "string",
      "extensionAttributes": {},
      "name": "string"
    }
  ],
  "totalSegments": [
    {
      "code": "string",
      "title": "string",
      "value": 0,
      "area": "string",
      "extensionAttributes": {
        "taxGrandtotalDetails": [
          {
            "amount": 0,
            "rates": [
              {
                "percent": "string",
                "title": "string"
              }
            ],
            "groupId": 0
          }
        ],
        "giftCards": "string",
        "gwOrderId": "string",
        "gwItemIds": [
          "string"
        ],
        "gwAllowGiftReceipt": "string",
        "gwAddCard": "string",
        "gwPrice": "string",
        "gwBasePrice": "string",
        "gwItemsPrice": "string",
        "gwItemsBasePrice": "string",
        "gwCardPrice": "string",
        "gwCardBasePrice": "string",
        "gwBaseTaxAmount": "string",
        "gwTaxAmount": "string",
        "gwItemsBaseTaxAmount": "string",
        "gwItemsTaxAmount": "string",
        "gwCardBaseTaxAmount": "string",
        "gwCardTaxAmount": "string",
        "gwPriceInclTax": "string",
        "gwBasePriceInclTax": "string",
        "gwCardPriceInclTax": "string",
        "gwCardBasePriceInclTax": "string",
        "gwItemsPriceInclTax": "string",
        "gwItemsBasePriceInclTax": "string"
      }
    }
  ],
  "extensionAttributes": {
    "rewardPointsBalance": 0,
    "rewardCurrencyAmount": 0,
    "baseRewardCurrencyAmount": 0
  }
}