• Resolved suhashini

    (@suhashini)


    i met this error in my local site Fatal error: Uncaught Error: Call to a member function get_cart() on null in , i have used this code

    function test_cart( $id ){

    $product_id = test_id( $course_id );

    if ( $product_id > 0 ) {

    $product = wc_get_product( $product_id );

    foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {

    $cart_product = $values[‘data’];
    if( $product_id == $cart_product->get_id() ) {

    return true;

    }

    }

    }

    return false;

    }

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Fatal Error’ is closed to new replies.