• Hi XYZ team!

    Several times, when i use a woocommerce functions inside my code, i got an error. Most of the time, the error is not critical or i can find another way to make it but for some functions it’s very complicated:

    global $product; gives me sometimes a fatal error

    Or currently, i’m trying to use get_type() or is_type() without any success: everything is working well but it creates an uncomptability with my Divi builder. Therefore, it becomes totally impossible for me to save a page.

    [29-Jan-2021 17:23:01 UTC] PHP Fatal error:  Uncaught Error: Call to a member function is_type() on bool in blablabla/www/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65) : eval()'d code:7
    Stack trace:
    #0 blablabla/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65): eval()
    #1 blablabla/wp-includes/shortcodes.php(343): xyz_ips_display_content(Array, '', 'xyz-ips')
    #2 [internal function]: do_shortcode_tag(Array)
    #3 blablabla/wp-includes/shortcodes.php(218): preg_replace_callback('/\\[(\\[?)(xyz\\-i...', 'do_shortcode_ta...', ' \t[xyz-ips snip...')
    #4 blablabla/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(2755): do_shortcode(' \t[xyz-ips snip...')
    #5 blablabla/wp-includes/shortcodes.php(343): ET_Builder_Element->_render(Array, ' \t[xyz-ips snip...', 'et_pb_code')
    #6 [internal function]: do_shortcode_tag(Array)
    #7 blablabla/wp-includes/shortcodes.php(218): preg_replace_callback('/\\[(\\[?)(showmo...', 'do_shortcode_ta...', ' in blablabla/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65) : eval()'d code on line 7

    or even:

    [29-Jan-2021 17:21:39 UTC] PHP Fatal error:  Uncaught Error: Call to a member function get_type() on bool in blablabla/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65) : eval()'d code:7
    Stack trace:
    #0 blablabla/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65): eval()
    #1 blablabla/wp-includes/shortcodes.php(343): xyz_ips_display_content(Array, '', 'xyz-ips')
    #2 [internal function]: do_shortcode_tag(Array)
    #3 blablabla/wp-includes/shortcodes.php(218): preg_replace_callback('/\\[(\\[?)(xyz\\-i...', 'do_shortcode_ta...', ' \t[xyz-ips snip...')
    #4 blablabla/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(2755): do_shortcode(' \t[xyz-ips snip...')
    #5 blablabla/wp-includes/shortcodes.php(343): ET_Builder_Element->_render(Array, ' \t[xyz-ips snip...', 'et_pb_code')
    #6 [internal function]: do_shortcode_tag(Array)
    #7 blablabla/wp-includes/shortcodes.php(218): preg_replace_callback('/\\[(\\[?)(showmo...', 'do_shortcode_ta...',  in /home/inextremsk/www/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65) : eval()'d code on line 7

    Do you have any idea how i can get out of this error loop?

    Code used:

    $product = wc_get_product( get_the_ID() ); // Get the WC_Product Object
    
    // Simple products
     if( $product->is_type( 'simple' ) ) {
    	$active_price  = wc_get_price_to_display($product);
    	$regular_price = wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) );
    	$weight        = $product->get_weight();
    	$in_stock      = $product->is_in_stock();
    }

    In advance, thanks a lot!!

    Bertrand

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

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Uncaught/Fatal/Critical Error when using woocommerce functions’ is closed to new replies.