• Resolved clementrectangle

    (@clementrectangle)


    Hi,

    I noticed a bug with the Donation plugin, I’m not sure since when it happens… It seems decimal numbers trigger a fatal error.

    It was working fine before, I’m not sure since how many updates it’s broken… When trying to use decimal number with a dot (1.25), the dot gets removed and it apply a 125$ donation. When trying to use commas (1,25), it triggers the fatal error. Before, using commas worked.

    I think you should check for $donation_price to be a float, and not a string, near line 380 of woo-donations.php. The fatal error is fixed by doing so ($donation_price = floatval($donation_price);).

    Here’s the PHP fatal error and the whole stack trace :

    PHP Fatal error: Uncaught TypeError: number_format(): Argument #1 ($num) must be of type float, string given in /sites/www.quaisud.com/files/wp-content/plugins/woo-donations/woo-donations.php:384
    Stack trace: 0 /sites/www.quaisud.com/files/wp-content/plugins/woo-donations/woo-donations.php(384): number_format() 1 /sites/www.quaisud.com/files/wp-includes/shortcodes.php(433): wdgk_donation_form_shortcode_html() 2 [internal function]: do_shortcode_tag() 3 /sites/www.quaisud.com/files/wp-includes/shortcodes.php(273): preg_replace_callback() 4 /sites/www.quaisud.com/files/wp-content/themes/quai-sud/woocommerce/cart/cart-totals.php(130): do_shortcode() 5 /sites/www.quaisud.com/files/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include(‘…’) 6 /sites/www.quaisud.com/files/wp-content/plugins/woocommerce/includes/wc-template-functions.php(2180): wc_get_template() 7 /sites/www.quaisud.com/files/wp-includes/class-wp-hook.php(324): woocommerce_cart_totals() 8 /sites/www.quaisud.com/files/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() 9 /sites/www.quaisud.com/files/wp-includes/plugin.php(517): WP_Hook->do_action() 10 /sites/www.quaisud.com/files/wp-content/themes/quai-sud/woocommerce/cart/cart.php(213): do_action() 11 /sites/www.quaisud.com/files/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include(‘…’) 12 /sites/www.quaisud.com/files/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-cart.php(101): wc_get_template() 13 /sites/www.quaisud.com/files/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(72): WC_Shortcode_Cart::output() 14 /sites/www.quaisud.com/files/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(85): WC_Shortcodes::shortcode_wrapper() 15 /sites/www.quaisud.com/files/wp-includes/shortcodes.php(433): WC_Shortcodes::cart() 16 [internal function]: do_shortcode_tag() 17 /sites/www.quaisud.com/files/wp-includes/shortcodes.php(273): preg_replace_callback() 18 /sites/www.quaisud.com/files/wp-includes/class-wp-hook.php(324): do_shortcode() 19 /sites/www.quaisud.com/files/wp-includes/plugin.php(205): WP_Hook->apply_filters() 20 /sites/www.quaisud.com/files/wp-includes/post-template.php(256): apply_filters() 21 /sites/www.quaisud.com/files/wp-content/themes/quai-sud/template-parts/content-page.php(21): the_content() 22 /sites/www.quaisud.com/files/wp-includes/template.php(792): require(‘…’) 23 /sites/www.quaisud.com/files/wp-includes/template.php(725): load_template() 24 /sites/www.quaisud.com/files/wp-includes/general-template.php(206): locate_template() 25 /sites/www.quaisud.com/files/wp-content/themes/quai-sud/page.php(25): get_template_part() 26 /sites/www.quaisud.com/files/wp-includes/template-loader.php(106): include(‘…’) 27 /sites/www.quaisud.com/files/wp-blog-header.php(19): require_once(‘…’) 28 /sites/www.quaisud.com/files/index.php(17): require(‘…’) 29 {main}

    thrown in /sites/www.quaisud.com/files/wp-content/plugins/woo-donations/woo-donations.php on line 384

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author rajkakadiya

    (@rajkakadiya)

    Hello @clementrectangle,

    We have checked Donation plugin with diffrent decimal seperator. like, dot, comma, etc. But not found any fatel error or bug like you got.

    Plugin is supported with woocommerce dynamic decimal seperator so we can’t add floatval function on donation price.

    If you have still any queries feel free to reach out to us at [email protected].

Viewing 1 replies (of 1 total)
  • The topic ‘Decimal numbers trigger fatal error’ is closed to new replies.