WooCommerce Singe Product Critical Error

Single product page leads to critical error: https://prnt.sc/TlHLWJIn8U0B
Store page otherwise works fine; https://delawareintstg.wpenginepowered.com/shop/
Please find the admin login below for troubleshooting purposes;

Hello @Ninacc,

Thanks for writing to us

I would suggest you please update the WooCommerce plugin to the latest version and recheck it again.

Thanks

it is all updated; https://prnt.sc/q0zd08KQ9tMq

Hello Nina,

I believe that this is a bug in the latest release. To get around this error, kindly add this custom PHP code in your child theme’s functions.php file:

// Fix for WP Single error 
add_filter( 'cs_condition_rule_wc_product_type', function( $result, $args ) {
    global $product;

    // Safety check: kung string ang $product, kuhaon ang object
    if ( is_string( $product ) || is_numeric( $product ) ) {
        $product = wc_get_product( $product );
    }

    // Kung dili valid ang product, ibalik ang original result
    if ( ! $product || ! is_object( $product ) || ! method_exists( $product, 'get_type' ) ) {
        return $result;
    }

    list( $type ) = $args;

    if ( is_string( $type ) ) {
        return $type === $product->get_type();
    }

    $term = get_term( $type );
    if ( empty( $term ) || empty( $term->slug ) ) {
        return false;
    }

    return $term->slug === $product->get_type();
}, 10, 2 );

Kindly let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.