• Resolved kefniark

    (@kefniark)


    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,200

    Items Subtotal:¥20,000
    Shipping:¥1,200
    Order Total:¥21,200

    After being updated, get recalculated with the following values:

    Line Item:
    – Variation ID: 1234 => ¥5,000 × 2 = ¥10,000
    – Shipping × 2  ¥1,200

    Items Subtotal:¥10,000
    Shipping:¥1,200
    Order Total:¥11,200

    Basically 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.

    • This topic was modified 1 year, 9 months ago by kefniark.
Viewing 1 replies (of 1 total)
  • Hi @kefniark,

    I apologize for the delay in response.

    Thank you for explaining the issue in detail.

    I have tried to replicate the issue on my staging site where the order total is resulting in the wrong amount when the order is updated from the admin side.

    But, I am unable to replicate it as the ‘Items Subtotal:’ resulted in to correct amount depending on the quantity updated.
    Screenshot: https://prnt.sc/vO0saqBCrXDV

    I have tried the latest versions of WooCommerce (7.8.0) and
    Currency per Product for WooCommerce Pro (1.9.0).

    Can you please let me know which version of our Pro plugin is currently active on your site?

    If it is not the latest version, I would request you update the plugin, recheck the mentioned issue and let me know the result.

Viewing 1 replies (of 1 total)
  • The topic ‘Bug causing wrong order total’ is closed to new replies.