0

In (themePath)/Magento_Checkout/templates/cart/item/default.phtml, i want get the coupon / Discount object. I use this code :

@var \Magento\Framework\View\Element\AbstractBlock $block
[...]
var_dump($block->getCouponCode());

In a cart with a coupon/discount, the var_dump return NULL, why?

Anybody have a solution to get the coupon/discount object set with coupon/discount value?

1 Answer 1

0

If you want to get the coupon code directly from that template, you can try

$block->getCheckoutSession()->getQuote()->getCouponCode();
1
  • It's work! Thank you Nikolas.
    – clama4242
    Nov 8, 2022 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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