- Issue created by @berdir
- Merge request !3Directly use order item API instead of price calculator for fields on order items β (Open) created by berdir
- π¨πSwitzerland berdir Switzerland
I created a first merge request, this still needs to be properly tested on our side.
The logic is a bit convoluted now due all the if/else conditions, it might make sense to introduce two methods to abstract this, wanted to keep the changes minimal for now.
At first I wasn't sure if the adjustment types setting works with order items then, but I think it actually works very well, all the API's we need allow to provide adjustment types, just have to be careful about when it ends up being empty.
- π¬π·Greece fotisp
Thanks for the patch.
It works unless promotions are set to "Include the discount in the displayed unit price."
(This option was introduced in: https://www.drupal.org/project/commerce/issues/3025383 β )When "Include the discount in the displayed unit price" is enabled, order items only show the final price, as "original_price" and "final_price" are identical.
I wasnβt able to fully understand the API used to fix this issue, but if someone can give me any tips, Iβd be happy to create a patch.
Additionally, the code below seems to have the exact same statement within both the if and else blocks:
if ($items->getName() === 'total_price') { $result = new PriceCalculatorResult($purchasable_entity->getAdjustedTotalPrice($adjustment_types), $purchasable_entity->getTotalPrice(), $adjustments); } else { $result = new PriceCalculatorResult($purchasable_entity->getAdjustedTotalPrice($adjustment_types), $purchasable_entity->getTotalPrice(), $adjustments); }
thanks
- First commit to issue fork.
- πΊπΈUnited States loze Los Angeles
this works well for my needs. (showing price difference in the views order cart table)
I made one small change that @fostip pointed out.