Is there an event or plugin spot for when cart rule is no longer valid?Shopping cart price rules conditions no longer satisfied eventCatalog + Shopping cart rule, discounting wrong fields when appliedMagento 2 - There is an event or method to “plug-in” when the coupon is removed from the cart/quote in the checkout flow?Magento 2: Multiple Cart rules not working at a timeRemove SalesRule from Quote Magento 1.xmini cart subtotal update in observerMagento Shopping Cart Price Rule For Total Items Quantity 1How to show custom validation message in checkout?Ajax custom cart not applying shopping ruleCart rule free shipping on subtotal after discount magento 2

What is memelemum?

I think I may have violated academic integrity last year - what should I do?

Plot twist where the antagonist wins

Using credit/debit card details vs swiping a card in a payment (credit card) terminal

Pirate democracy at its finest

Looking for a soft substance that doesn't dissolve underwater

Crossing US border with music files I'm legally allowed to possess

Why do Ryanair allow me to book connecting itineraries through a third party, but not through their own website?

Employer demanding to see degree after poor code review

Why were helmets and other body armour not commonplace in the 1800s?

Does Nitrogen inside commercial airliner wheels prevent blowouts on touchdown?

If a person had control of every single cell of their body, would they be able to transform into another creature?

Popcorn is the only acceptable snack to consume while watching a movie

Cipher Block Chaining - How do you change the plaintext of all blocks?

Line of lights moving in a straight line , with a few following

Flying domestically in the US, is my State Issued ID all I need to get past security?

A steel cutting sword?

Image processing: Removal of two spots in fundus images

What does the view outside my ship traveling at light speed look like?

Is it possible to play as a necromancer skeleton?

Does the unit of measure matter when you are solving for the diameter of a circumference?

What is quasi-aromaticity?

At what point in European history could a government build a printing press given a basic description?

keyval - function for keyB should act dependent on value of keyA - how to do this?



Is there an event or plugin spot for when cart rule is no longer valid?


Shopping cart price rules conditions no longer satisfied eventCatalog + Shopping cart rule, discounting wrong fields when appliedMagento 2 - There is an event or method to “plug-in” when the coupon is removed from the cart/quote in the checkout flow?Magento 2: Multiple Cart rules not working at a timeRemove SalesRule from Quote Magento 1.xmini cart subtotal update in observerMagento Shopping Cart Price Rule For Total Items Quantity 1How to show custom validation message in checkout?Ajax custom cart not applying shopping ruleCart rule free shipping on subtotal after discount magento 2






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








10















Is there an event or place I can plugin for when a shopping cart price rule is no longer valid (such as when it expires or if you change the quantity of other products where it no longer applies)? I know that it is automatically removed from the cart, but I can't seem to find the place this is happening in the code.



I am writing a module that adds a free product to the cart for a coupon where the subtotal is more than X amount. It is all working except for when reducing the quantity of items in the cart where the subtotal goes below X. The coupon is getting removed, but my product is staying in the cart.



So far I've tapped into the following events to do what I need so far...



salesrule_validator_process
checkout_cart_update_items_after
sales_quote_collect_totals_before


I did find MagentoQuoteModelCouponManagement which seemed promising since it has set() and remove() methods, but they don't appear to be getting called when the cart is updated.



In the checkout_cart_update_items_after it also seems like a logical place I can check, but it appears the rule is still set according to $cart->getQuote()->getAppliedRuleIds()




UPDATE: I ended up adding an observer for the checkout_cart_save_after event which runs after collectTotals() so knows if the rule is still on the cart or not. Then I basically compare $quote->getAppliedRuleIds() with $quote->getOrigData('applied_rule_ids') to see if the rule has been removed. I feel like there is a better way to do this, but it works for the moment. I still have the issue with coupons that expire though...










share|improve this question






























    10















    Is there an event or place I can plugin for when a shopping cart price rule is no longer valid (such as when it expires or if you change the quantity of other products where it no longer applies)? I know that it is automatically removed from the cart, but I can't seem to find the place this is happening in the code.



    I am writing a module that adds a free product to the cart for a coupon where the subtotal is more than X amount. It is all working except for when reducing the quantity of items in the cart where the subtotal goes below X. The coupon is getting removed, but my product is staying in the cart.



    So far I've tapped into the following events to do what I need so far...



    salesrule_validator_process
    checkout_cart_update_items_after
    sales_quote_collect_totals_before


    I did find MagentoQuoteModelCouponManagement which seemed promising since it has set() and remove() methods, but they don't appear to be getting called when the cart is updated.



    In the checkout_cart_update_items_after it also seems like a logical place I can check, but it appears the rule is still set according to $cart->getQuote()->getAppliedRuleIds()




    UPDATE: I ended up adding an observer for the checkout_cart_save_after event which runs after collectTotals() so knows if the rule is still on the cart or not. Then I basically compare $quote->getAppliedRuleIds() with $quote->getOrigData('applied_rule_ids') to see if the rule has been removed. I feel like there is a better way to do this, but it works for the moment. I still have the issue with coupons that expire though...










    share|improve this question


























      10












      10








      10








      Is there an event or place I can plugin for when a shopping cart price rule is no longer valid (such as when it expires or if you change the quantity of other products where it no longer applies)? I know that it is automatically removed from the cart, but I can't seem to find the place this is happening in the code.



      I am writing a module that adds a free product to the cart for a coupon where the subtotal is more than X amount. It is all working except for when reducing the quantity of items in the cart where the subtotal goes below X. The coupon is getting removed, but my product is staying in the cart.



      So far I've tapped into the following events to do what I need so far...



      salesrule_validator_process
      checkout_cart_update_items_after
      sales_quote_collect_totals_before


      I did find MagentoQuoteModelCouponManagement which seemed promising since it has set() and remove() methods, but they don't appear to be getting called when the cart is updated.



      In the checkout_cart_update_items_after it also seems like a logical place I can check, but it appears the rule is still set according to $cart->getQuote()->getAppliedRuleIds()




      UPDATE: I ended up adding an observer for the checkout_cart_save_after event which runs after collectTotals() so knows if the rule is still on the cart or not. Then I basically compare $quote->getAppliedRuleIds() with $quote->getOrigData('applied_rule_ids') to see if the rule has been removed. I feel like there is a better way to do this, but it works for the moment. I still have the issue with coupons that expire though...










      share|improve this question
















      Is there an event or place I can plugin for when a shopping cart price rule is no longer valid (such as when it expires or if you change the quantity of other products where it no longer applies)? I know that it is automatically removed from the cart, but I can't seem to find the place this is happening in the code.



      I am writing a module that adds a free product to the cart for a coupon where the subtotal is more than X amount. It is all working except for when reducing the quantity of items in the cart where the subtotal goes below X. The coupon is getting removed, but my product is staying in the cart.



      So far I've tapped into the following events to do what I need so far...



      salesrule_validator_process
      checkout_cart_update_items_after
      sales_quote_collect_totals_before


      I did find MagentoQuoteModelCouponManagement which seemed promising since it has set() and remove() methods, but they don't appear to be getting called when the cart is updated.



      In the checkout_cart_update_items_after it also seems like a logical place I can check, but it appears the rule is still set according to $cart->getQuote()->getAppliedRuleIds()




      UPDATE: I ended up adding an observer for the checkout_cart_save_after event which runs after collectTotals() so knows if the rule is still on the cart or not. Then I basically compare $quote->getAppliedRuleIds() with $quote->getOrigData('applied_rule_ids') to see if the rule has been removed. I feel like there is a better way to do this, but it works for the moment. I still have the issue with coupons that expire though...







      magento2 event-observer shopping-cart-price-rules plugin sales-quote






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 20 at 17:01







      Scruffy Paws

















      asked Feb 6 '18 at 23:12









      Scruffy PawsScruffy Paws

      305418




      305418




















          0






          active

          oldest

          votes












          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%2f212474%2fis-there-an-event-or-plugin-spot-for-when-cart-rule-is-no-longer-valid%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f212474%2fis-there-an-event-or-plugin-spot-for-when-cart-rule-is-no-longer-valid%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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?