How do I save the result of the last of multiple runs of a rule on a commerce order?
This has been solved. Thanks if you considered the question.
We have a rule that runs “after updating an existing commerce order.” The rule does many things that have a direct effect on the price of the order — and when a coupon is used on the order it actually runs twice. It seems to run well, most of the time.
Our problem is that the results of the second run (when a customer uses a coupon) is the one we need. But we end up with the results of the first run. We put a ton of debugging code in and dumped the order object into watchdog at different times during execution. What we’re finding is that after the second run the commerce_order object looks perfect. But that perfection is not saved into the order. Instead the order always gets the result of the first run.
We tried this with order revisions enabled and disabled. No diff. We also put in commerce_order_save commands.
We have been looking at this for days. We suspect it has something to do with Database concurrency since the two runs happen so close to one another (we looked at the timestamps).
Does anybody have a clue about what may be going on? We are really looking to save the result of that last run of the rule. FWIW this is running on MySQL (i.e. no real transactions).