"applied_discount" contains properties from different discounts.

Highlighted
Shopify Partner
2 0 0

There is a bug in the REST Checkout API.

Prerequisites. In Shopify we have Automatic discount percent “50% off entire order, Minimum purchase of 8 items“. Also we have coupon discount STRAVA110KMBIB12 “£10.00 off entire order“.

Steps to reproduce:

  • Add 7 items of a product to your cart.

  • Apply coupon code. Response from Checkout REST admin API endpoint (expected) :

    "discount_code": "STRAVA110KMBIB12",
     "applied_discount": {
        "amount": "10.00",
        "title": "STRAVA110KMBIB12",
        "description": null,
        "value": "10.00",
        "value_type": "fixed_amount",
        "non_applicable_reason": null,
        "applicable": true
    }

     

  • Go back to the cart and change quantity to 8. Automatic discount is applied on the cart.

  • Go to checkout. Automatic discount is applied, coupon code is removed. But when I get Checkout via API - “applied_discount“ response field contains some mixed data: amount and value from automatic discount, all the others from coupon discount. Unexpected. I expect all fields to be from automatic discount.

    "discount_code": "STRAVA110KMBIB12",
    "applied_discount": {
        "amount": "520.00",
        "title": "STRAVA110KMBIB12",
        "description": null,
        "value": "50.00",
        "value_type": "fixed_amount",
        "non_applicable_reason": "<strong>STRAVA110KMBIB12</strong> discount code isn’t valid for the items in your cart",
        "applicable": false
    }

     

     

  • Go to the cart and change quantity to 7.
  • Go to checkout. Remove applied coupon.
  • Go to the cart and change quantity to 8.
  • Go to checkout. Now automatic discount is returned from API in correct way. Expected
    "discount_code": null,
    "applied_discount": {
        "amount": "520.00",
        "title": "percent",
        "description": null,
        "value": "50.00",
        "value_type": "percentage",
        "non_applicable_reason": null,
        "applicable": true
    }
  • Apply discount coupon via shareable link /discount/STRAVA110KMBIB12 and go to Checkout. Get Checkout from API. "discount_code" and automatic discount is present. Expected
    "discount_code": "STRAVA110KMBIB12",
    "applied_discount": {
        "amount": "520.00",
        "title": "percent",
        "description": null,
        "value": "50.00",
        "value_type": "percentage",
        "non_applicable_reason": null,
        "applicable": true
    }

 

 

0 Likes