Monday, September 19, 2022
HomeWordPress DevelopmentWooCommerce: Search type that reveals product attributes and queries them

WooCommerce: Search type that reveals product attributes and queries them


I need to add a customized search type incl. an possibility to decide on sure product attributes. The objective is that customers can enter a textual content and select a product attribute worth and outcomes are solely proven from a sure product class.

I do know that I can make the most of the sort parameter of enter to construct a customized URL. How can I embody the phrases of a attributes as effectively?

By utilizing this reply (Create product class and key phrase search type in woocommerce?) my code appears to be like like this to date:

operate custom_search( $type ) {

$phrases = get_terms('pa_attributes');

$type = '<type position="search" technique="get" id="searchform" motion="' . esc_url( home_url( "https://wordpress.stackexchange.com/"  ) ) . '">
    <div>
        <label class="screen-reader-text" for="s">' . __( 'Seek for:', 'woocommerce' ) . '</label>
        <enter sort="textual content" worth="' . get_search_query() . '" title="s" id="s" placeholder="' . __( 'Search inside a class', 'woocommerce' ) . '" />
        <enter sort="hidden" title="post_type" worth="product">
        <enter sort="hidden" title="taxonomy" worth="product_cat">
        <!-- right here: zeitschrift is chosen -->
        <enter sort="hidden" title="time period" worth="my_product_category">

 <!-- HOW TO INCLUDE $phrases ? -->


        <enter sort="submit" id="searchsubmit" worth="'. esc_attr__( 'Search', 'woocommerce' ) .'" />
        <enter sort="hidden" title="post_type" worth="product" />
    </div>
</type>';

return $type;

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments