Discount marketing can be profitable for your business when done well. Store owners add shopping cart price rules in Magento 2 to take advantage of the potential to grow revenues.
Sometimes, extending the strategy from the site wide discount, you may want to try your hands on providing the additional benefits based on the discount the customers have used. For example, offer free shipping to the customers having purchased more than 5 quantities with 5% discount.
To apply the above scenario in the store, the admin must check which shopping cart rule is applied to cart in Magento 2 prior to offering the additional benefits.
Earlier I posted the solution to check which shopping cart rule is applied in Magento. Today, I’ve come up with the same solution for Magento 2.
Method to Check Which Shopping Cart Rule is Applied to Cart in Magento 2
Add the below code.
public function __construct(
$this->checkoutSession = $checkoutSession;
public function getAppliedRuleIds()
$quote = $this->checkoutSession->getQuote();
$appliedRuleIds = $quote->getAppliedRuleIds();
$appliedRuleIds = explode(',', $appliedRuleIds);
If you have questions regarding this blog, feel free to ask in Comment section below.
I would be happy to answer.
Do not forget to share this post with Magento Community via social media,.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.