• Resolved idnr1

    (@rm04)


    I am using a function like below.

    function edit_price_display($price, $instance) {
        global $product;
    
    	if( $product->is_type( 'grouped' ) ){
    
    	$price_update = array();
    
    	foreach ( $product->get_children() as $child_id ) {
    Do something
    	}
    	
    	if ( ! empty( $price_update ) ) {
    Do something
    	}
    
    	$all_taxes = array();
    
    	foreach ( $product->get_children() as $child_id ) {
    Do something
    	}
    
    	$price = '<div class="some_class">....</div> ';
    
    	return $price;
    	}}
    add_filter('woocommerce_get_price_html', 'edit_price_display', 10, 2);

    As soon as this function is activated advanced woo search doesn’t give any results back.

    Any ideas on why this causes the plugin to stop returning results?

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

    (@mihail-barinov)

    Hello,

    As I see this problem is in $product object. It is not defined so all its methods returns php errors.

    Please change your code to something like ( use $instance instead of $product ):

    function edit_price_display($price, $instance) {
    
        if( $instance->is_type( 'grouped' ) ){
    
            $price_update = array();
    
            foreach ( $instance->get_children() as $child_id ) {
                Do something
    	    }
    
            if ( ! empty( $price_update ) ) {
                Do something
    	    }
    
            $all_taxes = array();
    
            foreach ( $instance->get_children() as $child_id ) {
                Do something
    	    }
    
            $price = '<div class="some_class">....</div> ';
    
            return $price;
        }
    
    }
    add_filter('woocommerce_get_price_html', 'edit_price_display', 10, 2);
Viewing 1 replies (of 1 total)
  • The topic ‘No search results when using hook’ is closed to new replies.