[Core] fix price calculation with immutables and adjustments - #2573
Conversation
dpfaffenbauer
commented
Mar 4, 2024
| Q | A |
|---|---|
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Fixed tickets | #2572 |
…Processor.php Co-authored-by: Jacob Dreesen <jacob@hdreesen.de>
…sor.php Co-authored-by: Jacob Dreesen <jacob@hdreesen.de>
|
@dpfaffenbauer thanks for the quick response. Unfortunately, this does not work when using additional adjustments on cart items. In other words: The total value of the order items are getting completely ignored now. To reproduce: You may want to add a simple adjustment to an item (not cart) in your test to validate the total value. I'm not sure why this PR is not failing, but I guess it's because CoreShop/src/CoreShop/Component/Core/Cart/Rule/Applier/CartRuleApplier.php Lines 189 to 190 in 1ca9f58 CoreShop/src/CoreShop/Component/Core/Cart/Rule/Applier/CartRuleApplier.php Lines 200 to 202 in 1ca9f58 |
|
@solverat adding an adjustment to the item without the order is not supported and is something we cannot make work easily without breaking other things. as you pointed out, cart-rules are applied on cart-item and cart directly. and that is the reason it is applied on both. |
|
@solverat one solution could be that we set the adjustment on the cart itself as neutral and use them from the items. not sure what side-effects that can have. |
…ateSubtotal function
|
@solverat please check the latest changes |
|
@dpfaffenbauer This looks VERY promising! In my Test, I've
…and all calculations are correct now! The only thing I don't understand in your PR: 9e742c8#diff-ad51a1ab22ce6a03fe767ee679b9ccfd41a00b017606df746e1baf50b4c5f490R61-R72 I removed that part, and I wasn't able to spot the difference. Maybe a hint to test it would be great! |
|
@solverat If you have already have items with a total of 0, without that, it would lead to a division by 0 error. I did some other changes as well, can you test them as well? Since we are now changing which discounts apply to what, we need to make sure to always have the right calculations. |
|
@dpfaffenbauer Just adopted your changes: Still valid! |
|
I will also test it in one of our projects first. It might have unconsidered side-effects |
|
I also think that this PR makes the neutral adjustment calculation more solid. 👍 It's quite clear now, what's happening when adding custom adjustments - especially if they have to be added to the order item subtotal to allow them to be discountable by cart rules! |
|
Yeah, so basically what this changes is:
|
|
@dpfaffenbauer Btw, I was not able to test cart items action ( I don't know where the cart item rule processor should get triggered? |
|
@solverat They do work though for me. They are triggered as Cart Item Rule Action. |
|
On my debug marker, only |
|
🙈 I'm so sorry, I'm very new to coreshop... |


