Problem/Motivation

I created custom PurchasableEntity, user decides on price himself so when I add it to cart (via custom form) I set overridden_unit_price flag to true on OrderItem. Unfortunately this gets reset by TaxOrderProcessor which does not check if overridden_unit_price flag is checked or not.

Proposed resolution

Replace:
$order_item->setUnitPrice($unit_price);
With:
$order_item->setUnitPrice($unit_price, $order_item->isUnitPriceOverridden());

Comments

zaporylie created an issue. See original summary.

zaporylie’s picture

Status: Active » Needs review
StatusFileSize
new634 bytes

I'm thinking about just doing this

zaporylie’s picture

Title: Overriden UnitPrice resets by TaxOrderProcessor » Overridden UnitPrice resets by TaxOrderProcessor
bojanz’s picture

Status: Needs review » Needs work

We also need to fix LocalTaxTypeBase::apply().

zaporylie’s picture

Status: Needs work » Needs review
StatusFileSize
new1.44 KB

True that!

zaporylie’s picture

Should we also add some tests?

zaporylie’s picture

Issue tags: +DevDaysLisbon
StatusFileSize
new5.57 KB
new7.01 KB

Well, let's just add them.

The last submitted patch, 7: 2965498-7-TEST-ONLY.patch, failed testing. View results

zaporylie’s picture

Talked with Bojan in Darmstad and he said that there is something about this issue that makes the latest patch not ready to be committed but, honestly, I don't remember what that was 😅 Some bigger issue with taxes/calculations.

zaporylie’s picture

Priority: Normal » Major

I should have set higher priority from the beginning as this issue has a major impact to all sites using customizable price.

bojanz’s picture

Status: Needs review » Closed (duplicate)

Let's continue in #2907808: The original overridden unit price is lost on subsequent order refreshes, my #15 explains what needs to happen (adding a new field to avoid data loss).