Bug causing wrong order total
-
For the past 6 month on our shop, we have a really strange bug.
After being modified in the woocommerce admin (like a support request), some order total are updated with the wrong price.
This cause problems for later operations (refund, pdf invoice, …) because some order total are just wrong and does not reflect what the customer really paid. And today I finally pinpoint this bug to this plugin.For example the following order:
Line Item:
– Variation ID: 1234 => ¥10,000 × 2 = ¥20,000
– Shipping × 2 ¥1,200Items Subtotal:¥20,000
Shipping:¥1,200
Order Total:¥21,200After being updated, get recalculated with the following values:
Line Item:
– Variation ID: 1234 => ¥5,000 × 2 = ¥10,000
– Shipping × 2 ¥1,200Items Subtotal:¥10,000
Shipping:¥1,200
Order Total:¥11,200Basically the line item calculation seems to ignore the quantity. And it cause the line total to be recalculated and divided by the quantity.
Looking at your code, I found something quite suspicious in class-alg-wc-cpp-core.php (line: 1427), you have the following code:$item->set_subtotal( $return_price ); $item->set_total( $return_price ); // Make new taxes calculations. $item->calculate_taxes(); $item->save(); // Save line item data.
But I feel like this set_total is wrong, $return_price is the price of a single items, but a line total includes the quantity of items.
Maybe I’m wrong, but I feel like the code should be:$item->set_subtotal( $return_price ); $item->set_total($return_price * $item->get_quantity());
And after changing this, I can’t reproduce the problem anymore on my shop.
Can you please investigate and fix this issue.
- The topic ‘Bug causing wrong order total’ is closed to new replies.