Discounts do not appear in checkout webhook (Line Item level)

PatrickWatzeels
Shopify Expert
14 0 13

Hi all,

We have noticed that the Checkout Webhooks do not contain information about discounts on line item level. Although the tax line is updated in the line_item when you apply a discount. So there is something applied, but the line_item total is not updated. Also the discount cannot be found in the "allocated_discount" property (where I would expect it).

 

An example on this. I have 2 products and the second product has a 20% discount code (see below)

Screenshot 2021-02-08 at 17.05.33.png

 

When I receive the "checkout/update" webhook from Shopify. I do see that the total amount was updated, I have a 200.00 euro discount on order level.

 

    ...
    "presentment_currency": "EUR",
    "total_discounts": "200.00",
    "total_line_items_price": "1089.00",
    "total_price": "889.00",
    "total_tax": "154.29",
    "subtotal_price": "889.00",
    ...

 

 

When I look into the line item where I applied the discount. There is no allocation mentioned on any discount.

Below a representation of the line_item that I'm mentioning. The product price is still 1.000 euro. 
And the strange part is, the tax value is updated according to the discount.. Since 138.84 is the value of the tax with the discount being applied. A quick math: 21% tax. 800 euro is 121%. 800/121 = 6.61157... .6.61157... times 21 = 138.84. That is exact the amount in the webhook.

 

{
    "applied_discounts": [],
    "key": "ffc4a8c4aa6a7ec4d75226ec8e55fcdf",
    "destination_location_id": null,
    "fulfillment_service": "manual",
    "gift_card": false,
    "grams": 0,
    "origin_location_id": 1933535608876,
    "presentment_title": "Gold neckless",
    "presentment_variant_title": "",
    "product_id": 5408600391724,
    "properties": [],
    "quantity": 1,
    "requires_shipping": true,
    "sku": "GOLD-123",
    "tax_lines": [
        {
            "position": 1,
            "price": "138.84",
            "rate": 0.21,
            "title": "NL VAT",
            "source": "ActiveTax",
            "compare_at": 0.21,
            "zone": null,
            "channel_liable": false,
            "identifier": null
        }
    ],
    "taxable": true,
    "title": "Gold neckless",
    "variant_id": 34685847339052,
    "variant_title": "",
    "variant_price": "1000.00",
    "vendor": "Mollie payments store",
    "user_id": null,
    "unit_price_measurement": {
        "measured_type": null,
        "quantity_value": null,
        "quantity_unit": null,
        "reference_value": null,
        "reference_unit": null
    },
    "rank": null,
    "compare_at_price": null,
    "line_price": "1000.00",
    "price": "1000.00"
}

 

 

To me this is a bug in the payload of the checkout webhook, you should be able to allocate the applied discount on line_item level. Especially because the tax_line is updated. So it is applied for 50%.

I hope that someone at Shopify can take a look into this so that it can be resolved soon.


Thanks in advance!

Solutions Engineer / Sr. Developer at CODE - a Shopify Plus agency | Delft | The Netherlands
Replies 2 (2)

acceleratorsvoy
Shopify Partner
1 0 0

Hey @PatrickWatzeels ,

 

Experiencing the same problem here.  Only when you apply a discount code, the discount is defined in the payload, it seems. 

 

There is no way of differentiating a discounted product from a product without a price reduction.

 

Did you find a solution to this?

njokipal-wlmn
Shopify Partner
3 0 0

We have developed multiple apps for a few customers, where the "checkout/*" webhooks offer some crucial functionality. Initially, the information was there and was tested, but over a year or so, more and more merchants using one of the different apps, are experiencing this bug where the discount allocations aren't populated correctly.

 

I've tried registering the webhooks through all the supported API versions, tried setting the webhooks API version to all supported versions, and tried asking for all access scopes Shopify simply allows me to, and nothing brings back the information.

 

Some time ago we contacted Shopify about this issue and they then eventually concluded that there was some issues with their code, and promised to fix it. No word or fix since.

 

Now, while trying to mitigate this issue, I've also noticed that the ".properties" information for "line_items.[]" is "null" while in the "cart/*" event payload has them. Automatic discounts are also present in the "cart/*" payload, but not in the "checkout/*" payloads.