I have overridden the checkout\cart\item\default.phtml in my theme. To get the 'used' coupon code I've found below rules in other questions:
$getCoupon = $block->getLayout()->createBlock('Magento\Checkout\Block\Cart\Coupon'); $coupon_code = $getCoupon->getCouponCode();
This is working fine, however I need the RuleId so I can check whether the correct coupon code type is used.
In a class with DI I can resolve this with:
$ruleId = $this->coupon->loadByCode($coupon_code)->getRuleId(); // coupon => use Magento\SalesRule\Model\Coupon;
There is no such block that I can import so I can have access to the getRuleId function?
What is the correct manner to establish this?