Checkout Webhook not including Automatic Discount Code

Solved
Highlighted

Checkout webhooks like, checkout/update and checkout/create do not fill in the discount code in the field when an automatic discount is applied.

 

I currently have the checkout/create and checkout/add webhooks pointed to my server where I can log the results of the webhooks.

 

I've created a test FIX14 automatic discount.

 

fix14.png

 

The automatic discount is automatically applied in the checkout process, but when the webhook fires, I do not see any discount codes in the webhook.

{
    "id": 7979224268851,
    "token": "5bb4ca16d04e6982413944b10899aeea",
    "cart_token": "5db44e3c994237ced7f47f7d2ca01331",
    "email": null,
    "created_at": "2019-08-09T13:02:26-04:00",
    "updated_at": "2019-08-09T13:02:26-04:00",
    "currency": "CAD",
    "line_items": [
        {
            "applied_discounts": [],
            "key": "4d6f645d12b1bc35125443ea3dc1ae4f",
            "destination_location_id": null,
            "fulfillment_service": "manual",
            "gift_card": false,
            "grams": 0,
            "origin_location_id": 836893081651,
            "product_id": 1689663438899,
            "properties": [],
            "quantity": 1,
            "requires_shipping": true,
            "sku": "01",
            "tax_lines": [],
            "taxable": true,
            "title": "Tshirt A",
            "variant_id": 16096882753587,
            "variant_title": "",
            "variant_price": "11.99",
            "vendor": "Gab",
            "user_id": null,
            "unit_price_measurement": {
                "measured_type": null,
                "quantity_value": null,
                "quantity_unit": null,
                "reference_value": null,
                "reference_unit": null
            },
            "country_hs_codes": [],
            "country_code_of_origin": null,
            "province_code_of_origin": null,
            "harmonized_system_code": null,
            "compare_at_price": "10.99",
            "line_price": "11.99",
            "price": "11.99"
        }
    ],
    "discount_codes": [],
    "total_price": "10.32",
    "total_tax": "0.00"
}

By Default it should appear in the field: "discountcodes": [] , but instead it is empty. As you can see that the total_price does not reflect the line item and is discounted, but there is no explanation for the discount.

 

This appears to be a bug.

ui-gab
https://www.uiavenue.ca
We specialize in data analytics. If I've helped you today, please give our give our app a try (15-day free trial) https://apps.shopify.com/ui-ave-analytics and maybe write a good review.
Send me a message if you want a free data analysis consultation.
0 Likes
Highlighted
Shopify Expert
1381 111 205

Hi,

 

This is an inbuilt Shopify feature only one discount code can be applied at a time.

 

 

0 Likes
Highlighted

Sorry, but I don't think you have understood what I have written above.

 

I'm not looking to add new discount codes. This automatic discount code has already been applied. It just doesn't show up in webhooks.

ui-gab
https://www.uiavenue.ca
We specialize in data analytics. If I've helped you today, please give our give our app a try (15-day free trial) https://apps.shopify.com/ui-ave-analytics and maybe write a good review.
Send me a message if you want a free data analysis consultation.
0 Likes
Highlighted

This is an accepted solution.

Hi there,

Hanna here from Shopify, thanks for reaching out :)

I heard back from my team and they let me know that this is currently a known limitation of automatic discounts!

  • No API: Automatic Discounts are not currently available via API, this includes Dynamic Checkout, "Buy Now Button" and Buy Button sales channel

This forum post looks to have more info on that as well: https://community.shopify.com/c/Shopify-APIs-SDKs/Is-API-available-for-getting-automatic-discount-co...

We are always looking to built out features more so hopefully this is one day added!

Hanna K | Shopify Guru

ui-gab
https://www.uiavenue.ca
We specialize in data analytics. If I've helped you today, please give our give our app a try (15-day free trial) https://apps.shopify.com/ui-ave-analytics and maybe write a good review.
Send me a message if you want a free data analysis consultation.
0 Likes
Highlighted
Shopify Partner
7 0 0

Hello, I found some another issue with automatic discounts and webhooks, in your cart.json you are showing applied discount type

"cart_level_discount_applications": [
    {
      "type": "automatic",
      "key": "99f96fbc-9377-4376-ab92-398747d09a7d",
      "title": "auto",
      "description": "",
      "value": "50.0",
      "created_at": "2019-12-06T08:18:42.793Z",
      "value_type": "percentage",
      "allocation_method": "across",
      "target_selection": "all",
      "target_type": "line_item",
      "total_allocated_amount": 500
    }
  ]

but in cart update webhook does send this info

{:id=>"1c38a971ad8fdc862efe0d872b4f7926",
 :token=>"1c38a971ad8fdc862efe0d872b4f7926",
 :line_items=>
  [{:id=>15222283173945,
    :properties=>{:infinite_options_1=>"wer"},
    :quantity=>1,
    :variant_id=>15222283173945,
    :key=>"15222283173945:a9a2ad9c50de33559d2b4be8c4481aa8",
    :discounted_price=>"5.00",
    :discounts=>[{:amount=>"5.00", :title=>"hello", :amount_set=>{:shop_money=>{:amount=>"5.0", :currency_code=>"USD"}, :presentment_money=>{:amount=>"5.0", :currency_code=>"USD"}}}],
    :gift_card=>false,
    :grams=>1000,
    :line_price=>"5.00",
    :original_line_price=>"10.00",
    :original_price=>"10.00",
    :price=>"10.00",
    :product_id=>1573109760057,
    :sku=>"",
    :taxable=>true,
    :title=>"Bicycle1 - Red",
    :total_discount=>"5.00",
    :vendor=>"Upsell Shop 002",
    :discounted_price_set=>{:shop_money=>{:amount=>"5.0", :currency_code=>"USD"}, :presentment_money=>{:amount=>"5.0", :currency_code=>"USD"}},
    :line_price_set=>{:shop_money=>{:amount=>"5.0", :currency_code=>"USD"}, :presentment_money=>{:amount=>"5.0", :currency_code=>"USD"}},
    :original_line_price_set=>{:shop_money=>{:amount=>"10.0", :currency_code=>"USD"}, :presentment_money=>{:amount=>"10.0", :currency_code=>"USD"}},
    :price_set=>{:shop_money=>{:amount=>"10.0", :currency_code=>"USD"}, :presentment_money=>{:amount=>"10.0", :currency_code=>"USD"}},
    :total_discount_set=>{:shop_money=>{:amount=>"5.0", :currency_code=>"USD"}, :presentment_money=>{:amount=>"5.0", :currency_code=>"USD"}}}],
 :note=>"",
 :updated_at=>"2019-12-16T16:33:47.057Z",
 :created_at=>"2019-12-16T16:13:26.743Z"}

the discount itself present, but its type is not specified

0 Likes