Get discount from cart

In the liquid object documentation, the cart object may contain these fields:

  • cart_level_discount_applications
  • discount_applications
  • item line_level_discount_allocations
  • item discount_allocations

Although the voucher code is applied via a discount link (I can verify it by navigating to check out). Those fields are all empty. I have the same result using the ajax API: no discount application is present in the response.

Why? When are these fields populated?

Some applications can display the applied voucher in the cart page, how do they achieve that.

Thank you

Hey @filosganga .

I actually didn’t know what these were either, I must be rusty with cart-level stuff.

Through testing, discount allocations can come from automatic discounts which are applied on the cart page. This doc implies that the discounts can also come from Shopify Scripts (Plus shops only) and manual discount entry, however I cannot get manual discount entry to work by any means, so I’m not sure about that one (even if it was added to the checkout already).

Hope that helps a little bit at least.

Cheers.

Hi Alex,

Thank you for your reply, these are also my conclusions.

Is it possible to get the checkout id, from the current cart? In this way, I could use the storefront checkout API to fetch the applied discount.

Thanks