• Resolved Robin

    (@robinrsa)


    Hi there

    I get an error with multiple code snippets when using the plugin.

    method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given

    An example code snippet being used is:

    function search_above_shop_loop() {
    	$term = get_queried_object();
    	$taxonomy = isset($term->taxonomy) ? $term->taxonomy : null;
    	if( $taxonomy && ! in_array( $taxonomy, array( 'product_cat', 'product_brand' ) ) ){
    		echo '<div class="shop_search_bar">'.do_shortcode('[wd_asp id=1]').'</div>';
    	}
    }
    add_action( 'woocommerce_before_shop_loop', 'search_above_shop_loop', 10 );
    	
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @robinrsa,

    Since it seems like the error is not coming directly from the snippet you shared, the error is likely coming from one of the other snippets that are active on your site that is causing a side-effect.

    I recommend doing a search for “method_exists” using the search in the list of snippets to narrow down the search and then make sure that the variable you are using for the method_exists call is actually an object or class.

    You can also try to deactivate the other active snippets one by one until the error is no longer showing up if you don’t have a large number of active snippets.

    Thread Starter Robin

    (@robinrsa)

    Thank you @gripgrip I managed to find the issue based on your steps.

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

The topic ‘method_exists()’ is closed to new replies.