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;
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
add a comment |
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
add a comment |
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
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
magento2 event-observer shopping-cart-price-rules plugin sales-quote
edited May 20 at 17:01
Scruffy Paws
asked Feb 6 '18 at 23:12
Scruffy PawsScruffy Paws
305418
305418
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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