{"id":1410,"date":"2020-11-20T04:38:20","date_gmt":"2020-11-20T04:38:20","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/check-which-shopping-cart-rule-is-applied-to-cart-in-magento\/"},"modified":"2025-05-21T17:42:18","modified_gmt":"2025-05-21T12:12:18","slug":"check-which-shopping-cart-rule-is-applied-to-cart-in-magento","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/check-which-shopping-cart-rule-is-applied-to-cart-in-magento\/","title":{"rendered":"How to Check Which Shopping Cart Rule is Applied to Cart in Magento"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The default Magento allows the admin to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-magento-shopping-cart-price-rules\/\">add shopping cart price rules<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">He can offer coupon codes to avail the discounts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, sometimes you may want to set conditions based on which discounts are offered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, the admin wants to offer a specific payment method only for certain scenarios.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To implement this, the admin needs to&nbsp;<em><strong>check which shopping cart rule is applied to cart in Magento.<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The below solution can be used for the same:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Check Which Shopping Cart Rule is Applied to Cart in Magento:<\/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=\"\">$appliedRuleIds = Mage::getSingleton('checkout\/session')->getQuote()->getAppliedRuleIds();\n$appliedRuleIds = explode(',', $appliedRuleIds);\nprint_r($appliedRuleIds);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">By adding this code, you will be able to check which shopping cart price rule has applied to quote.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default Magento allows the admin to&nbsp;add shopping cart price rules. He can offer coupon codes to avail the discounts. However, sometimes you may want&#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-1410","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1410","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=1410"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1410\/revisions"}],"predecessor-version":[{"id":13927,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1410\/revisions\/13927"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}