The original overridden unit price is lost on subsequent order refreshes

Created on 10 September 2017, almost 8 years ago
Updated 9 February 2023, over 2 years ago

Steps to reproduce

1. Create a store with tax setting "Prices are entered with taxes included." unchecked.
2. Create a tax type with "European Union VAT" plugin and "Display taxes of this type inclusive in product prices." checked.
3. Create an order type with "Order refresh frequency" of 1 second. (This pretty much makes the order edit form unsavable so you might want to lower this value only after step 5.)
4. Create an order item type with no "Purchasable entity type", with "Services" "Taxable type" and with Order type from step 3.
5. Create an order of the new type through the admin UI.

After this every time you view the order, the order total increases.

Original report

Hi,

Setup:
The store is set up with prices not being inserted with tax included, the tax region is selected as Estonia.
The tax type being used is EU VAT which is to display the prices with taxes included.

I've created a custom order item type, which has the Purchasable entity type set as "none" and the taxable type is "services"

Issue:
When creating a new order with even just 1 order item of my type, info filled in, and price set to 77.99 (just an example). I made it into a "cart" so I could test checkout, but already then the price had been increased by a multitude of tax increases. Opening up the order and order item, re saving increased it again in the checkout and by now, now even having visited checkout again, it's already somehow 194.06 which is 77.99*1.2*1.2*1.2*1.2*1.2

Update:

It seems that every time the cart/order get's updated the tax get's added again and again, because whenever I add order items to the same order or remove them it's definitely to increase the amount of previous order items by the multiple of 1.2. This behavior is not limited to just Estonian VAT, but also tried with other EU VAT's, the behavior remains.

By now the original item amount has grown to €1,441.87 but tax is €240.31 hence I believe somewhere the total taxed amount is being considered as the amount without tax, and tax get's added to it again, and the same thing happens over and over again. but the tax amount remains correct 20% throughout the whole time :)

🐛 Bug report
Status

Active

Version

2.0

Component

Tax

Created by

🇪🇪Estonia Alluuu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇦Ukraine init90 Ukraine

    I encounter the issue when adding a discount to the product for which the price can be adjusted by the customer based on the selected options. In the order item we tell that the price is overridden, i.e. 'overridden_unit_price' set to TRUE. This means that on refresh order item price won't be updated according to the product variation price.

    With the standard setup, I had 2 issues:

    1. It lost the 'overridden_unit_price' setting which lead to the loss customization price.
    2. It's updated already updated order item price, which leads to incorrect calculation.

    As a workaround, I created a custom promotion plugin that fixes the problems above.

    To fix first point the plugin account 'overridden_unit_price' setting: $order_item->setUnitPrice($new_unit_price, $order_item->isUnitPriceOverridden());

    To resolve the second point passes the original price to the order item $order_item->setData('original_price', $price); in add to cart event. Then in the promotion plugin discount always applies to the original price.

    Hope at some time the issue will be fixed with the solution like in message #16.

  • As #18, i have custom price and need to override unit price when product is adding to cart

    unfortunately, promotion with display_inclusive lost the overriden unit price boolean field

    i found make it works updating promotion class and get overriden unit price field to keep it when apply promotion

  • 🇮🇱Israel jsacksick

    I don't think the patch from #19 is the correct fix. This will cause the discounted price to be the new overridden unit price, so the price will keep reducing on each refresh.
    What we need instead is an unprocessed_unit_price field I guess?

    But I guess the question is how do we actually restore the overridden unit price on each refresh? I'd say it is the responsability of an order processor that runs early to constantly set the right unit price?

Production build 0.71.5 2024