Patrick Mutwiri
Patrick Mutwiri

Reputation: 1351

Why is Woocommerce getting 542.67 after 271.34 is multiplied by 2?

I have a cart with a product that costs USD 271.34. When I update quantity to 2, the price total changes to 542.67, instead of 542.68.

I'm stuck because this value brings along discrepancies that paypal can't check it out, hence generating error no. 10413 - The totals of the cart item amounts do not match order amounts.

Upvotes: 0

Views: 56

Answers (1)

Vasim Shaikh
Vasim Shaikh

Reputation: 4532

Its rounding problem in woo commerce check out :

Reason
paypal receives 542.68 and so with any quantity greater than 1 there is a mismatch in paypal’s calculation of the amount and WooCommerce’s.So this error happen.

Solution

add_filter( 'woocommerce_get_price_excluding_tax', 'round_price_product', 10, 1 );
add_filter( 'woocommerce_get_price_including_tax', 'round_price_product', 10, 1 );
add_filter( 'woocommerce_tax_round', 'round_price_product', 10, 1);
add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1);
    function round_price_product( $price ){
        // Return rounded price
        return round( $price);
    }

Reference

Other Answer that I found,

https://wordpress.org/support/topic/price-rounding-issues-in-paypal/

Upvotes: 1

Related Questions