Magento 2 check which catalog rule is applied to cart product Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Catalog Price Rule not showing “Discount” value in cart totalsConfigurable products in Catalog price ruleCatalog + Shopping cart rule, discounting wrong fields when appliedHow to replace a catalog price rule by a cart price rule when adding a specific product in cart?Catalog Price Rule Not FiringGet Applied shopping cart price rule/Catalog price Rule name in product details pageMagento 2 Percentage based catalog rule detect on cart pageMagento 2: How to get discount price for each cart rule in quote

Trademark violation for app?

How to pronounce 伝統色

Electrolysis of water: Which equations to use? (IB Chem)

Sentence with dass with three Verbs (One modal and two connected with zu)

How many morphisms from 1 to 1+1 can there be?

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

What does 丫 mean? 丫是什么意思?

Is there public access to the Meteor Crater in Arizona?

preposition before coffee

What order were files/directories output in dir?

How much damage would a cupful of neutron star matter do to the Earth?

Misunderstanding of Sylow theory

What would you call this weird metallic apparatus that allows you to lift people?

Lagrange four-squares theorem --- deterministic complexity

Project Euler #1 in C++

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

Customizing QGIS plugins

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

How does Belgium enforce obligatory attendance in elections?

Google .dev domain strangely redirects to https

AppleTVs create a chatty alternate WiFi network

How to compare two different files line by line in unix?

Draw 4 of the same figure in the same tikzpicture

Putting class ranking in CV, but against dept guidelines



Magento 2 check which catalog rule is applied to cart product



Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Catalog Price Rule not showing “Discount” value in cart totalsConfigurable products in Catalog price ruleCatalog + Shopping cart rule, discounting wrong fields when appliedHow to replace a catalog price rule by a cart price rule when adding a specific product in cart?Catalog Price Rule Not FiringGet Applied shopping cart price rule/Catalog price Rule name in product details pageMagento 2 Percentage based catalog rule detect on cart pageMagento 2: How to get discount price for each cart rule in quote



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have created 3 catalog rules for category.



  1. Shoes Category: 5% Off , Catalog Rule Name: Shoes Offer

  2. Toys Category: 10% Off, Catalog Rule Name: Toys Offer

  3. Fashion Accessories: 8% Off, Catalog Rule Name: Fashion Acc. Offer

So all the product of that categories are showing discounted price in category.
On cart page i want to show which catalog rule is applied to item.



Is there any way to check on cart item that which catalog rule is applied to it?



How can i check which catalog rule is applied to item and how much discount is applied?



Any help would be appreciated.










share|improve this question




























    3















    I have created 3 catalog rules for category.



    1. Shoes Category: 5% Off , Catalog Rule Name: Shoes Offer

    2. Toys Category: 10% Off, Catalog Rule Name: Toys Offer

    3. Fashion Accessories: 8% Off, Catalog Rule Name: Fashion Acc. Offer

    So all the product of that categories are showing discounted price in category.
    On cart page i want to show which catalog rule is applied to item.



    Is there any way to check on cart item that which catalog rule is applied to it?



    How can i check which catalog rule is applied to item and how much discount is applied?



    Any help would be appreciated.










    share|improve this question
























      3












      3








      3


      1






      I have created 3 catalog rules for category.



      1. Shoes Category: 5% Off , Catalog Rule Name: Shoes Offer

      2. Toys Category: 10% Off, Catalog Rule Name: Toys Offer

      3. Fashion Accessories: 8% Off, Catalog Rule Name: Fashion Acc. Offer

      So all the product of that categories are showing discounted price in category.
      On cart page i want to show which catalog rule is applied to item.



      Is there any way to check on cart item that which catalog rule is applied to it?



      How can i check which catalog rule is applied to item and how much discount is applied?



      Any help would be appreciated.










      share|improve this question














      I have created 3 catalog rules for category.



      1. Shoes Category: 5% Off , Catalog Rule Name: Shoes Offer

      2. Toys Category: 10% Off, Catalog Rule Name: Toys Offer

      3. Fashion Accessories: 8% Off, Catalog Rule Name: Fashion Acc. Offer

      So all the product of that categories are showing discounted price in category.
      On cart page i want to show which catalog rule is applied to item.



      Is there any way to check on cart item that which catalog rule is applied to it?



      How can i check which catalog rule is applied to item and how much discount is applied?



      Any help would be appreciated.







      magento2 cart magento2.2 catalog-price-rules programmatically






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 2 '18 at 4:31









      jackjack

      461722




      461722




















          1 Answer
          1






          active

          oldest

          votes


















          0














          We can use MagentoQuoteModelQuoteItem $item to check the applied rules.



          vendor/magento/module-sales-rule/Model/Quote/Discount.php



           $item->getAppliedRuleIds();
          $item->getDiscountAmount();


          See a good example here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php



          In database, we should take a look at quote_item table.






          share|improve this answer

























          • $item->getAppliedRuleIds(); Will it show the catalog rule name?

            – jack
            Apr 2 '18 at 13:18











          • It just returns the rule ids, we can loop this array to find the rule entity.

            – Khoa TruongDinh
            Apr 2 '18 at 14:06











          • Thanksf or your help! Just tried this method it's returning shopping cart rules but not Catalog Price rule. How can i load applied catalog price rule? Product of shoes cateogry have 5% discount based on catalog rule i want to display that on cart page. Above code is displaying cart rule. Any other way to detect catalog price rule?

            – jack
            Apr 3 '18 at 4:47











          • See more here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php. I updated my answer.

            – Khoa TruongDinh
            Apr 4 '18 at 3:34











          • For Catalog Price rule, it need to check.

            – Khoa TruongDinh
            Apr 4 '18 at 3:35











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f220660%2fmagento-2-check-which-catalog-rule-is-applied-to-cart-product%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          We can use MagentoQuoteModelQuoteItem $item to check the applied rules.



          vendor/magento/module-sales-rule/Model/Quote/Discount.php



           $item->getAppliedRuleIds();
          $item->getDiscountAmount();


          See a good example here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php



          In database, we should take a look at quote_item table.






          share|improve this answer

























          • $item->getAppliedRuleIds(); Will it show the catalog rule name?

            – jack
            Apr 2 '18 at 13:18











          • It just returns the rule ids, we can loop this array to find the rule entity.

            – Khoa TruongDinh
            Apr 2 '18 at 14:06











          • Thanksf or your help! Just tried this method it's returning shopping cart rules but not Catalog Price rule. How can i load applied catalog price rule? Product of shoes cateogry have 5% discount based on catalog rule i want to display that on cart page. Above code is displaying cart rule. Any other way to detect catalog price rule?

            – jack
            Apr 3 '18 at 4:47











          • See more here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php. I updated my answer.

            – Khoa TruongDinh
            Apr 4 '18 at 3:34











          • For Catalog Price rule, it need to check.

            – Khoa TruongDinh
            Apr 4 '18 at 3:35















          0














          We can use MagentoQuoteModelQuoteItem $item to check the applied rules.



          vendor/magento/module-sales-rule/Model/Quote/Discount.php



           $item->getAppliedRuleIds();
          $item->getDiscountAmount();


          See a good example here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php



          In database, we should take a look at quote_item table.






          share|improve this answer

























          • $item->getAppliedRuleIds(); Will it show the catalog rule name?

            – jack
            Apr 2 '18 at 13:18











          • It just returns the rule ids, we can loop this array to find the rule entity.

            – Khoa TruongDinh
            Apr 2 '18 at 14:06











          • Thanksf or your help! Just tried this method it's returning shopping cart rules but not Catalog Price rule. How can i load applied catalog price rule? Product of shoes cateogry have 5% discount based on catalog rule i want to display that on cart page. Above code is displaying cart rule. Any other way to detect catalog price rule?

            – jack
            Apr 3 '18 at 4:47











          • See more here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php. I updated my answer.

            – Khoa TruongDinh
            Apr 4 '18 at 3:34











          • For Catalog Price rule, it need to check.

            – Khoa TruongDinh
            Apr 4 '18 at 3:35













          0












          0








          0







          We can use MagentoQuoteModelQuoteItem $item to check the applied rules.



          vendor/magento/module-sales-rule/Model/Quote/Discount.php



           $item->getAppliedRuleIds();
          $item->getDiscountAmount();


          See a good example here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php



          In database, we should take a look at quote_item table.






          share|improve this answer















          We can use MagentoQuoteModelQuoteItem $item to check the applied rules.



          vendor/magento/module-sales-rule/Model/Quote/Discount.php



           $item->getAppliedRuleIds();
          $item->getDiscountAmount();


          See a good example here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php



          In database, we should take a look at quote_item table.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 4 '18 at 3:34

























          answered Apr 2 '18 at 6:08









          Khoa TruongDinhKhoa TruongDinh

          22.3k64187




          22.3k64187












          • $item->getAppliedRuleIds(); Will it show the catalog rule name?

            – jack
            Apr 2 '18 at 13:18











          • It just returns the rule ids, we can loop this array to find the rule entity.

            – Khoa TruongDinh
            Apr 2 '18 at 14:06











          • Thanksf or your help! Just tried this method it's returning shopping cart rules but not Catalog Price rule. How can i load applied catalog price rule? Product of shoes cateogry have 5% discount based on catalog rule i want to display that on cart page. Above code is displaying cart rule. Any other way to detect catalog price rule?

            – jack
            Apr 3 '18 at 4:47











          • See more here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php. I updated my answer.

            – Khoa TruongDinh
            Apr 4 '18 at 3:34











          • For Catalog Price rule, it need to check.

            – Khoa TruongDinh
            Apr 4 '18 at 3:35

















          • $item->getAppliedRuleIds(); Will it show the catalog rule name?

            – jack
            Apr 2 '18 at 13:18











          • It just returns the rule ids, we can loop this array to find the rule entity.

            – Khoa TruongDinh
            Apr 2 '18 at 14:06











          • Thanksf or your help! Just tried this method it's returning shopping cart rules but not Catalog Price rule. How can i load applied catalog price rule? Product of shoes cateogry have 5% discount based on catalog rule i want to display that on cart page. Above code is displaying cart rule. Any other way to detect catalog price rule?

            – jack
            Apr 3 '18 at 4:47











          • See more here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php. I updated my answer.

            – Khoa TruongDinh
            Apr 4 '18 at 3:34











          • For Catalog Price rule, it need to check.

            – Khoa TruongDinh
            Apr 4 '18 at 3:35
















          $item->getAppliedRuleIds(); Will it show the catalog rule name?

          – jack
          Apr 2 '18 at 13:18





          $item->getAppliedRuleIds(); Will it show the catalog rule name?

          – jack
          Apr 2 '18 at 13:18













          It just returns the rule ids, we can loop this array to find the rule entity.

          – Khoa TruongDinh
          Apr 2 '18 at 14:06





          It just returns the rule ids, we can loop this array to find the rule entity.

          – Khoa TruongDinh
          Apr 2 '18 at 14:06













          Thanksf or your help! Just tried this method it's returning shopping cart rules but not Catalog Price rule. How can i load applied catalog price rule? Product of shoes cateogry have 5% discount based on catalog rule i want to display that on cart page. Above code is displaying cart rule. Any other way to detect catalog price rule?

          – jack
          Apr 3 '18 at 4:47





          Thanksf or your help! Just tried this method it's returning shopping cart rules but not Catalog Price rule. How can i load applied catalog price rule? Product of shoes cateogry have 5% discount based on catalog rule i want to display that on cart page. Above code is displaying cart rule. Any other way to detect catalog price rule?

          – jack
          Apr 3 '18 at 4:47













          See more here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php. I updated my answer.

          – Khoa TruongDinh
          Apr 4 '18 at 3:34





          See more here: vendor/magento/module-sales-rule/Observer/SalesOrderAfterPlaceObserver.php. I updated my answer.

          – Khoa TruongDinh
          Apr 4 '18 at 3:34













          For Catalog Price rule, it need to check.

          – Khoa TruongDinh
          Apr 4 '18 at 3:35





          For Catalog Price rule, it need to check.

          – Khoa TruongDinh
          Apr 4 '18 at 3:35

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f220660%2fmagento-2-check-which-catalog-rule-is-applied-to-cart-product%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

          Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?