{"id":1523,"date":"2021-01-14T11:11:33","date_gmt":"2021-01-14T11:11:33","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/check-which-shopping-cart-rule-is-applied-to-cart-in-magento-2\/"},"modified":"2025-05-21T17:08:24","modified_gmt":"2025-05-21T11:38:24","slug":"check-which-shopping-cart-rule-is-applied-to-cart-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/check-which-shopping-cart-rule-is-applied-to-cart-in-magento-2\/","title":{"rendered":"How To Check Which Shopping Cart Rule Is Applied To Cart In Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Discount marketing can be profitable for your business when done well. Store owners&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-magento-shopping-cart-price-rules\/\">add shopping cart price rules in Magento 2<\/a>&nbsp;to take advantage of the potential to grow revenues.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To apply the above scenario in the store, the admin must&nbsp;<strong>check which shopping cart rule is applied to cart in Magento 2&nbsp;<\/strong>prior to offering the additional benefits.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Earlier I posted the solution to<a href=\"https:\/\/meetanshi.com\/blog\/check-which-shopping-cart-rule-is-applied-to-cart-in-magento\/\">&nbsp;check which shopping cart rule is applied in Magento<\/a>. Today, I\u2019ve come up with the same solution for Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Check Which Shopping Cart Rule is Applied to Cart in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add the below code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use Magento\\Checkout\\Model\\Session;\n \nprotected $checkoutSession;\n \npublic function __construct(\n    Session $checkoutSession)\n{\n    $this->checkoutSession = $checkoutSession;\n}\n \npublic function getAppliedRuleIds()\n{\n    $quote = $this->checkoutSession->getQuote();\n    $appliedRuleIds = $quote->getAppliedRuleIds();\n    $appliedRuleIds = explode(',', $appliedRuleIds);\n    return $appliedRuleIds;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not forget to share this post with Magento Community via social media,.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Discount marketing can be profitable for your business when done well. Store owners&nbsp;add shopping cart price rules in Magento 2&nbsp;to take advantage of the potential&#8230;<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1523","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1523"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1523\/revisions"}],"predecessor-version":[{"id":13870,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1523\/revisions\/13870"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}