Home Forums WoodMart support forum FILTER DISAPEAR

FILTER DISAPEAR

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #34002

    tvojsplet
    Participant

    Hi, i have some issues with filter. When i insert sku number (4 digits) in search box the filters disapear from sidebar. If i search with words every thing is ok.

    #34006

    Artem Temos
    Keymaster

    Hello,

    We are glad to know that you considered using WoodMart for your web-site. I hope you will be happy with it.

    Could you please provide us an instruction how to reproduce the issue on your side?

    Kind Regards
    Xtemos

    #34020

    tvojsplet
    Participant

    Hi, i have to say it is very very nice theme. If you check on page http://www.wowbaby.si and typ in 191 and press enter the search result appears but filter on left sidebar disapear (img1.jpg). But if you type for example “HLA” and press enter the search results appera and filter is also visible on left sidebar. (img2.jpg)

    Attachments:
    You must be logged in to view attached files.
    #34032

    Artem Temos
    Keymaster

    Please, provide us your admin and FTP access so we can login and check this on your side.

    Thank you in advance.

    #34035

    tvojsplet
    Participant

    In private content is access

    #34089

    Artem Temos
    Keymaster

    OK, we found some issue in our theme. It may take some time to investigate it. We will back to you tomorrow.

    #34168

    tvojsplet
    Participant

    ok, thanks

    #34174

    Artem Temos
    Keymaster

    OK, we as we can see, WooCommerce widgets don’t take into account our SKU database query. To fix this you will need to edit a few files:

    1. First one – wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-price-filter.php

    change this code

    if ( $search = WC_Query::get_main_search_query_sql() ) {
    	$sql .= ' AND ' . $search;
    }

    to this one

    if ( $search = WC_Query::get_main_search_query_sql() ) {
    
    	$search_ids = array();
    
    	// search for variations with a matching sku and return the parent.
    	$sku_to_parent_id = $wpdb->get_col( $wpdb->prepare( "SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key='_sku' and pm.meta_value LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean( $_GET['s'] ) ) );
    
    	//Search for a regular product that matches the sku.
    	$sku_to_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value LIKE '%%%s%%';", wc_clean( $_GET['s'] ) ) );
    
    	$search_ids = array_merge( $search_ids, $sku_to_id, $sku_to_parent_id );
    
    	$search_ids = array_filter( array_map( 'absint', $search_ids ) );
    
    	$sql .= " AND " . $search;
    
    	if ( sizeof( $search_ids ) > 0 ) {
    		$sql = str_replace( '))', ") OR ({$wpdb->posts}.ID IN (" . implode( ',', $search_ids ) . ")))", $sql );
    	}
    	
    }

    2. In this file woodmart/inc/widgets/class-widget-layered-nav.php

    replace this

    if ( $search = WC_Query::get_main_search_query_sql() ) {
    	$query['where'] .= ' AND ' . $search;
    }

    with this part

    if ( $search = WC_Query::get_main_search_query_sql() ) {
        
        $search_ids = array();
        
        // search for variations with a matching sku and return the parent.
        $sku_to_parent_id = $wpdb->get_col( $wpdb->prepare( "SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key='_sku' and pm.meta_value LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean( $_GET['s'] ) ) );
        
        //Search for a regular product that matches the sku.
        $sku_to_id = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value LIKE '%%%s%%';", wc_clean( $_GET['s'] ) ) );
        
        $search_ids = array_merge( $search_ids, $sku_to_id, $sku_to_parent_id );
        
        $search_ids = array_filter( array_map( 'absint', $search_ids ) );
        
        $query['where'] .= ' AND ' . $search;
        
        if ( sizeof( $search_ids ) > 0 ) {
            $query['where'] = str_replace( '))', ") OR ({$wpdb->posts}.ID IN (" . implode( ',', $search_ids ) . ")))", $query['where'] );
        }
        
    }

    Kind Regards

    #34192

    tvojsplet
    Participant

    Thanks that work. I have one question. When i update woocommerce will i have to do the same?

    #34195

    Artem Temos
    Keymaster

    Yes, you will need to update the WooCommerce file only. We will fix it in our theme filters. We will try to find some better workaround in the future.

    #34196

    tvojsplet
    Participant

    ok thanks for info and fast response.

    #34200

    Artem Temos
    Keymaster

    You are welcome!

Tagged: 

Viewing 12 posts - 1 through 12 (of 12 total)