Is it possible to get, from one of the cart.adjustments of type discount, whether the discount was added with a coupon code, and if so, what that coupon code is?

  • Is this for Commerce 1 or 2? You tagged both on the question. – Brad Bell Nov 20 at 3:37
  • @BradBell It's for Commerce 2, sorry about that! – benface Nov 20 at 21:26
up vote 2 down vote accepted

An adjustment will take a snapshot of the source object that contained the rule for its application.

So the following is an array of a discounts attribute if you have a discount adjustment

{{ adjustment.sourceSnapshot }}

You could get the coupon code with

{{ adjustment.sourceSnapshot.code }}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.