Hi,
I am not quite sure about your issue. As I understood then you have schedule job to send your AwaitExchange order to your internal system. If there is any exception when sending a certain order then you will flag that order as On Hold? Then commerce admin will go to Order Management and remove On Hold tag? Then the discounts were gone, right?
You added customized code to run promotion again once order is saved after this issue happens to try to fix the issue?
what kind of discounts do you have? at the point of edit the promotion, were those expired?
it is now very hard to fix the problem in Commerce 13 (as it is no longer the latest), but might be the solution in Commerce 14 is to have a Save and Save without validation buttons for Admin UI ...
Binh, thank you for your response. You are more or less correct. It is not necessarily all discounts that are gone. On my local system I have an order I can reproduce this issue on and the Line Item Discounts go from $16 to $4 after updating a meta field.
I am able to track the process loosely and it is as follows:
I would like to understand this process more in order to make sure this doesn't happen. As I said in my original post, I was trying to hook into the "Saving" event so I could run some code prior to the order saving but I haven't had success. I don't know if that is the best approach or not.
Quan, these discounts are employee discounts so the discounts are definitely still active on production. I worry this may be the case for my local testing as my database may be older. However, for the actual live env, the discount is part of a campaign which does not expire until next year. The only thing is that there is a redemption limit of 12 for each employee but that number shouldn't get decremented on Validation, right?
As for bypassing validation, is it possible we could do that from the legacy commerce manager?
Lastly, is this something I can correct in an order saving event?
Thank you for the info about the upgrade, we have that planned for this year.
We believe we have found the issue. It is not all of our discounts that are getting removed from the order. It is a specific discount that is only available to people in a specific visitor group that checks the email domain of the logged in user. It also checks that the current market currency is USD.
I've crafted an admin user that fits that criteria but when updating the order we still get the same result. In addition, in my debugger the visitor group criterion are not even being evaluated, they only get evaluated when loading a CMS page. I think this is the cause of the issue, but how do we fix it?
That will be a tricky one as VG is evaluated based on the current http context. if the context is different the VG will not match.
I checked with the commerce development team and they said that the promotions will be reevaluated if the order status is In Progress. I will need to dig deeper to see if there is a way to customize that. but it wil be only applicable to Commerce 14
Yes, the discounts may be gone if discounts rely on email domain of current user. In commerce version 13, once we change meta field then order is validated again with validating line item, updating price changes, updating inventory changes, applying discounts again.
@Zach Do you really want to run all order validation again like that once changing that meta field or you just want to change meta field value within ignoring order validation?
@Binh, No we do not want to run all order validation again when updating a meta field. In this case, we would prefer everything stays the same, specifically pricing so that order totals are correct when we send the order over for processing.
Is there a way to accomplish this?
Another thing, if the Commerce Admin (the one updating the meta field) was valid for the promotion as well, would this work? My breakpoints were not being hit in development so I could not verifiy this part.
Hi,
It is not reason if we try to have Commerce Admin with same visitor groups with all customers.
By defaut.order validation is always run again once you change meta field. I think you could customize for your case such as:
@Binh, thank you for your response. I like both ideas. I am not sure why this site wasn't built that way originally. I supposed I might find out during development. However, both of these options are promising.
Hello, I am looking for some help on orderflows and promotion calculations, any help would be appreciated.
When a user places an order successfully on our website, we set the order to AwaitingExchange. We then have a scheduled job that loops through orders with the AwaitingExchange status and sends them off to our company's internal order processor. There are a few things that could cause the order to be flagged, in which case we will not send the order and set the order to On Hold (a custom meta field).
If an order is set to On Hold and the issue is resolved, then a Commerce Admin will go in and remove the hold flag. When this happens, we lose some discounts. Now, I found one thread with a very similar issue (https://world.optimizely.com/forum/developer-forum/Commerce/Thread-Container/2020/12/updating-order-address-causes-price-changes/) and the problem seems to be related to customizations which we definitely have. However, I can't seem to pinpoint what it is.
We have some code that runs when a promotion is applied to a cart which calculates the promotion and tax. I tried adding that code to run on IOrderEvents.SavingOrder. I verified that the event is fired and the code runs without exceptions. However, its not solving the issue.
What do you guys think is going on?