Support » Plugin: CoCart - Decoupling WooCommerce Made Easy » cocart apply coupon response breakdown

  • Resolved mahmed5aleh

    (@mahmed5aleh)


    Hello,

    I’m using the following coCart API to apply a coupon “A15”

    POST {{API_URL}}/cocart/v1/coupon?cart_key=<cart_key>

    “A15” is configured to provide a 15% discount and have a limit of 3 items. When the coupon is applied to a cart that contains a single product “P1” with quantity 5, the discount got applied to 3 items and the other 2 items are charged full price. Following is a sample request & response of GET cart API after coupon is applied

    GET {{API_URL}}/cocart/v2/cart?lang=en&cart_key=<cart_key>

    {
      "cart_hash": "b4ccd078bb23c75da43f8f0753347277",
      "cart_key": "fe090bb24ef98f119d6538ca391e9261",
      "items": [
        {
          "item_key": "4c2342c6b1ba65d084131c87e8b18c5d",
          "id": 217,
          "name": "P1",
          "title": "P1",
          "price": "25913333",
          "quantity": {
            "value": 5,
            "min_purchase": 1,
            "max_purchase": -1
          },
          "totals": {
            "subtotal": "129566667",
            "subtotal_tax": 64.783333333333,
            "total": 1295.666666666667,
            "tax": 64.783333333333
          },
          "slug": "p1",
          "meta": {
            "product_type": "simple",
            "sku": "",
            "dimensions": {
              "length": "",
              "width": "",
              "height": "",
              "unit": "cm"
            },
            "weight": 0,
            "variation": []
          },
          "backorders": "",
          "cart_item_data": {
            "date": "2021-01-03",
            "uuid": "0d18e064-01f7-465a-9cd5-30f291e48d94",
            "nyp": 299
          }
        }
      ],
      "item_count": 5,
      "items_weight": 0,
      "coupons": [
        {
          "coupon": "A15",
          "label": "Coupon: A15",
          "saving": "-0",
          "saving_html": "-USD0.00000"
        }
      ],
      "needs_payment": true,
      "needs_shipping": false,
      "shipping": [],
      "fees": [],
      "taxes": {
        "label": "VAT",
        "total": "6478333"
      },
      "totals": {
        "subtotal": "129566667",
        "subtotal_tax": "6478333",
        "fee_total": "0",
        "fee_tax": "0",
        "discount_total": "0",
        "discount_tax": "0",
        "shipping_total": "0",
        "shipping_tax": "0",
        "total": "136045000",
        "total_tax": "6478333"
      },
      "removed_items": [],
      "cross_sells": [],
      "notices": {
        "success": [
          "Coupon code applied successfully."
        ]
      }
    }

    The original price of “P1” is 299. After applying the coupon to the cart of 5 items, the above response returned a total of “1360.45”. If you do the math you’ll understand that the discount was applied to 3 items & 2 items got charged full price.

    Is there any way to have the GET cart response indicate that the discount got applied to 3 items and 2 items charged full price?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘cocart apply coupon response breakdown’ is closed to new replies.