2
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 ?

2 Answers 2

1

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
  }
}
1

To collect totals for cart based on shipping/payment methods and additional data. Use this

PUT /V1/carts/mine/collect-totals

Implementation Notes:

Set shipping/billing methods and additional data for cart and collect totals.

Parameters :

{
  "paymentMethod": {
    "po_number": "string",
    "method": "string",
    "additional_data": [
      "string"
    ],
    "extension_attributes": {
      "agreement_ids": [
        "string"
      ]
    }
  },
  "shippingCarrierCode": "string",
  "shippingMethodCode": "string",
  "additionalData": {
    "extension_attributes": {
      "gift_messages": [
        {
          "gift_message_id": 0,
          "customer_id": 0,
          "sender": "string",
          "recipient": "string",
          "message": "string",
          "extension_attributes": {
            "entity_id": "string",
            "entity_type": "string",
            "wrapping_id": 0,
            "wrapping_allow_gift_receipt": true,
            "wrapping_add_printed_card": true
          }
        }
      ]
    },
    "custom_attributes": [
      {
        "attribute_code": "string",
        "value": "string"
      }
    ]
  }
}

Response

{
  "grand_total": 0,
  "base_grand_total": 0,
  "subtotal": 0,
  "base_subtotal": 0,
  "discount_amount": 0,
  "base_discount_amount": 0,
  "subtotal_with_discount": 0,
  "base_subtotal_with_discount": 0,
  "shipping_amount": 0,
  "base_shipping_amount": 0,
  "shipping_discount_amount": 0,
  "base_shipping_discount_amount": 0,
  "tax_amount": 0,
  "base_tax_amount": 0,
  "weee_tax_applied_amount": 0,
  "shipping_tax_amount": 0,
  "base_shipping_tax_amount": 0,
  "subtotal_incl_tax": 0,
  "base_subtotal_incl_tax": 0,
  "shipping_incl_tax": 0,
  "base_shipping_incl_tax": 0,
  "base_currency_code": "string",
  "quote_currency_code": "string",
  "coupon_code": "string",
  "items_qty": 0,
  "items": [
    {
      "item_id": 0,
      "price": 0,
      "base_price": 0,
      "qty": 0,
      "row_total": 0,
      "base_row_total": 0,
      "row_total_with_discount": 0,
      "tax_amount": 0,
      "base_tax_amount": 0,
      "tax_percent": 0,
      "discount_amount": 0,
      "base_discount_amount": 0,
      "discount_percent": 0,
      "price_incl_tax": 0,
      "base_price_incl_tax": 0,
      "row_total_incl_tax": 0,
      "base_row_total_incl_tax": 0,
      "options": "string",
      "weee_tax_applied_amount": 0,
      "weee_tax_applied": "string",
      "extension_attributes": {
        "negotiable_quote_item_totals": {
          "cost": 0,
          "catalog_price": 0,
          "base_catalog_price": 0,
          "catalog_price_incl_tax": 0,
          "base_catalog_price_incl_tax": 0,
          "cart_price": 0,
          "base_cart_price": 0,
          "cart_tax": 0,
          "base_cart_tax": 0,
          "cart_price_incl_tax": 0,
          "base_cart_price_incl_tax": 0,
          "extension_attributes": {}
        }
      },
      "name": "string"
    }
  ],
  "total_segments": [
    {
      "code": "string",
      "title": "string",
      "value": 0,
      "area": "string",
      "extension_attributes": {
        "tax_grandtotal_details": [
          {
            "amount": 0,
            "rates": [
              {
                "percent": "string",
                "title": "string"
              }
            ],
            "group_id": 0
          }
        ],
        "gift_cards": "string",
        "gw_order_id": "string",
        "gw_item_ids": [
          "string"
        ],
        "gw_allow_gift_receipt": "string",
        "gw_add_card": "string",
        "gw_price": "string",
        "gw_base_price": "string",
        "gw_items_price": "string",
        "gw_items_base_price": "string",
        "gw_card_price": "string",
        "gw_card_base_price": "string",
        "gw_base_tax_amount": "string",
        "gw_tax_amount": "string",
        "gw_items_base_tax_amount": "string",
        "gw_items_tax_amount": "string",
        "gw_card_base_tax_amount": "string",
        "gw_card_tax_amount": "string",
        "gw_price_incl_tax": "string",
        "gw_base_price_incl_tax": "string",
        "gw_card_price_incl_tax": "string",
        "gw_card_base_price_incl_tax": "string",
        "gw_items_price_incl_tax": "string",
        "gw_items_base_price_incl_tax": "string"
      }
    }
  ],
  "extension_attributes": {
    "coupon_label": "string",
    "base_customer_balance_amount": 0,
    "customer_balance_amount": 0,
    "negotiable_quote_totals": {
      "items_count": 0,
      "quote_status": "string",
      "created_at": "string",
      "updated_at": "string",
      "customer_group": 0,
      "base_to_quote_rate": 0,
      "cost_total": 0,
      "base_cost_total": 0,
      "original_total": 0,
      "base_original_total": 0,
      "original_tax": 0,
      "base_original_tax": 0,
      "original_price_incl_tax": 0,
      "base_original_price_incl_tax": 0,
      "negotiated_price_type": 0,
      "negotiated_price_value": 0
    },
    "reward_points_balance": 0,
    "reward_currency_amount": 0,
    "base_reward_currency_amount": 0
  }
}
4
  • This is PUT method, It should be GET without passing any data just like mine/cart Dec 8, 2018 at 9:20
  • This returns no- route error Dec 8, 2018 at 9:29
  • It means This named API doesn't exists. Dec 8, 2018 at 9:30
  • Changing from PUT to GET does not work :) Dec 8, 2018 at 9:33

Your Answer

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

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