Take your website
To the next level
Discover our newly launched customization services and elevate your web projects to new heights.
Delegate tasks, save time, and unlock the power of professional WordPress outsourcing.

Okay
  Public Ticket #1822077
Woocommerce Search
Closed

Comments

  •  2
    creoadmin started the conversation

    The built in search function is a site search. I need it to be woocommerce product search. I have downloaded Advanced Woo Search but can't seem to get it placed in the header code and get it to work.


    Thanks for your help!

  •  7,095
    Oliver replied

    Hi,

    Add this code to the functions.php of the child theme:

    function wpse_search_filter( $query ) {
        if ( $query->is_search ) {
            $query->set( 'post_type', array('product') ); // setting post type as product (for woocommerce only)
        }
        return $query;
    }
    add_filter('pre_get_posts','wpse_search_filter');
    

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •  2
    creoadmin replied

    Thank you! That is not changing the search results. It is sill showing up like posts with "read more" links.


    Any other ideas?

  •  7,095
    Oliver replied

    Hi,

    pls. provide the wp-admin and FTP access

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •   creoadmin replied privately
  •  7,095
    Oliver replied

    Where did you added code I gave you?

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •  2
    creoadmin replied

    In Code Snippets

  •  7,095
    Oliver replied

    Hi,

    Remove old code and add this one:

    function thegem_child_init_icon() {
        remove_filter('wp_nav_menu_items', 'thegem_menu_item_search', 10);
    }
    add_action('init', 'thegem_child_init_icon');
    function thegem_menu_item_search_new($items, $args){
        ob_start();
        do_action( 'pre_get_product_search_form'  );
        wc_get_template( 'product-searchform.php' );
        $form = apply_filters( 'get_product_search_form', ob_get_clean() );
        if($args->theme_location == 'primary' && thegem_get_option('header_layout') !== 'overlay'){
            $items .= '<li class="menu-item menu-item-search"><a href="#"></a><div class="minisearch">' . $form . '/div></div></li>';
        }
        return $items;
    }
    add_filter('wp_nav_menu_items', 'thegem_menu_item_search_new', 11, 2);
    

    and add this css to the style css of the child theme:

    .minisearch input#woocommerce-product-search-field {
        display: block;
        width: 90%;
        color: #000;
        overflow: visible;
        z-index: 999;
        height: 40px;
        font-size: 14px;
    }
    .minisearch button {
        width: 40px;
        position: absolute;
        top: 0;
        right: 0;
        height: 42px;
        border: none;
        background-color: transparent;
        font-size: 0;
    }
    form.woocommerce-product-search {
        position: relative;
    }
    .minisearch button:before {
        content: "\e612";
        display: block;
        font-family: "thegem-icons";
        font-size: 24px;
        font-weight: normal;
        line-height: 40px;
        margin-right: 0;
        padding-right: 0;
        text-align: center;
        vertical-align: top;
        width: 100%;
        height: 43px;
        position: absolute;
        top: 0;
        right: 0;
    }
    

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •  2
    creoadmin replied

    Sorry for the delay!! I forgot about this.

    I have added the code and that seems to be working okay. But, when I add the css code, here is what my search box looks like: 

    Any ideas on that?

  •  7,095
    Oliver replied

    Hi,

    pls. provide the wp-admin and FTP access

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •   creoadmin replied privately
  •  7,095
    Oliver replied

    Hi,

    Check now

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •  2
    creoadmin replied

    I am still seeing a tiny search bar box. (see attached)

  •  7,095
    Oliver replied

    Hi,

    Clean your browser cache

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •  2
    creoadmin replied

    Oh wow! THANK YOU!! 

    Can you please let me know what you changed to code to as I am planning to buy more licenses of this theme. You have been MOST helpful!!

  •  7,095
    Oliver replied

    Hi,

    I've added some changes to code in the style.css of the child theme. Remove the code you added in the custom css filed in theme options and use from the style.css

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver