• Resolved tomek80

    (@tomek80)


    The problem is in the file \includes\shipping\free-shipping\class-wc-shipping-free-shipping.php on line 200
    if ( $total >= $this->min_amount ) {

    Comparison (float) >= (string)
    In the above case, e.g. 150>=75 but 150>=’75’ is treated as (string)>=(string). This has further consequences. For purchases of $8-9.99 it will allow for free shipping.

    I have a problem with PHP 8.1.27 CGI/FastCGI, WordPress 6.4.3, WooCommerce 8.7.0

    As a temporary solution without changing plugin file, I added the following code to my theme:

    add_filter(‘woocommerce_shipping_free_shipping_instance_option’, function($val, $key){
    if($key!=’min_amount’)return $val;
    return Automattic\WooCommerce\Utilities\NumberUtil::round($val, wc_get_price_decimals());
    }, 10, 2);

    After additional analysis, I discovered that when the min_amount field is 150, everything works fine. If the min_amount is 150,00, there is a problem. I can remove the “,00” from the value and once saved, it counts fine. When I open the free shipping edition and have previously saved 150, it show 150,00 in the field and if it is saved in this format, there is a problem with the calculations.

    • This topic was modified 1 year ago by tomek80.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @tomek80,

    It looks like you’ve already created a bug report here: https://github.com/woocommerce/woocommerce/issues/45797

    At the time being, we can’t give you an estimate for when the team will look into or fix the issue, as bug reports are prioritized based on a few criteria.

    In the meantime, you may keep using the code snippet as a temporary workaround.

    Thanks!

    Hey there @tomek80,

    We appreciate you being an active part of the community ??

    As a report has already been submitted, I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

    Have a wonderful day!

    brayamb

    (@brayamb)

    Hello!!!

    I am facing the same problem. For amounts below 100.00, free shipping is available, even when my free shipping rule is > 300.00. How was this problem resolved?

    Thread Starter tomek80

    (@tomek80)

    Hi @brayamb

    Try my code from the first post

    add_filter(‘woocommerce_shipping_free_shipping_instance_option’, function($val, $key){
    if($key!=’min_amount’)return $val;
    return Automattic\WooCommerce\Utilities\NumberUtil::round($val, wc_get_price_decimals());
    }, 10, 2);

    Plugin Support omarfpg a11n

    (@omarfpg)

    Hi @brayamb,

    I am facing the same problem. For amounts below 100.00, free shipping is available, even when my free shipping rule is > 300.00. How was this problem resolved?

    This is a known bug with WooCommerce at the moment. Our developers are looking into it, and it should be fixed very soon (you can find more details here:?https://github.com/woocommerce/woocommerce/pull/46857).

    In the meantime, please try saving your free shipping settings as 300 (without any decimal point or comma). The current workaround is to save the free shipping condition like that.

    Please let us know how it goes!
    -OP

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Free shipping – incorrect calculation’ is closed to new replies.