• Hi Guys,

    When we search for products on our site, it is not showing results for the product tags even though we have them included in the settings.

    For example, we have the ‘Milena’ loungewear sets with multiple colour options. If I search ‘Grey Milena’ it will not come up with the products even though it is in the product tags.

    Any help appreciated.

    Kind regards,

    Nina @ Rene K

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    You want to see this tags inside ajax search results box or inside separated search results page?

    Regards

    Thread Starter carriekay

    (@carriekay)

    Hello,

    I want to see the tags on the search results page.

    The ‘Milena’ loungewear sets have different colour options, so we have tagged ‘grey milena’ ‘black milena’ ‘red milena’ in the product tags but if I search ‘grey milena’ the product will not come up on the search results page.

    The only things that seem to come up on the search results page are from the title or description, but not the tags.

    Kind regards,

    Nina @ Rene K

    Plugin Author ILLID

    (@mihail-barinov)

    Ok, I understand you.

    Do you enable tags search source in the plugin settings page?
    Like this – https://prnt.sc/v8q69s

    Thread Starter carriekay

    (@carriekay)

    Hi,

    Yes we’ve enabled the tags like that, I’ve tried to turn it to no and yes again but it still does not work.

    Kind regards,

    Nina @ Rene K

    Plugin Author ILLID

    (@mihail-barinov)

    Looks like I found the solution for you. Please use following code snippet

    class AWS_Add_Tax {
        public $tax_id = 0;
        public $tax = array();
        public function __construct() {
            add_filter( 'aws_search_page_results',  array( $this, 'aws_search_page_results' ), 10, 3 );
            add_filter( 'woocommerce_loop_product_link',  array( $this, 'woocommerce_loop_product_link' ), 10 );
            add_filter( 'the_permalink',  array( $this, 'woocommerce_loop_product_link' ), 10 );
            add_filter( 'woocommerce_product_get_image',  array( $this, 'woocommerce_product_get_image' ), 10, 4 );
            add_filter( 'woocommerce_loop_add_to_cart_link',  array( $this, 'woocommerce_loop_add_to_cart_link' ), 10, 2 );
            add_filter( 'woocommerce_sale_flash',  array( $this, 'woocommerce_sale_flash' ), 10, 3 );
            add_filter( 'woocommerce_get_price_html',  array( $this, 'woocommerce_get_price_html' ), 10, 2 );
        }
        public function aws_search_page_results( $posts, $query, $data ) {
            $new_posts = array();
            $product = get_posts( array(
                'posts_per_page'      => 1,
                'numberposts'         => 1,
                'fields'              => 'ids',
                'post_type'           => 'product',
                'post_status'         => 'publish',
                'ignore_sticky_posts' => true,
                'suppress_filters'    => true,
                'no_found_rows'       => 1,
                'orderby'             => 'ID',
                'order'               => 'ASC',
                'lang'                => ''
            ) );
            foreach ( $data['search_res'] as $search_res_fields ) {
                if ( isset( $search_res_fields['tax'] ) ) {
                    $this->tax_id = $product[0];
                    foreach ( $search_res_fields['tax'] as $tax_name => $tax_terms ) {
                        foreach ( $tax_terms as $tax_term) {
                            $post = new stdClass();
                            $post->ID = $product[0];
                            $post->site_id = get_current_blog_id();
                            $post->post_name = $tax_term['name'];
                            $post->post_title = $tax_term['name'];
                            $post->permalink = $tax_term['link'];
                            $post->post_type = "product";
                            $post->post_author = "1";
                            $post->post_status = "publish";
                            $post->post_parent = 0;
                            $post->post_content = "";
                            $post->menu_order = 0;
                            $post->post_date = "2000-01-01 12:00:00";
                            $post->post_date_gmt = "2000-01-01 12:00:00";
                            $post->post_modified = "2000-01-01 12:00:00";
                            $post->post_modified_gmt = "2000-01-01 12:00:00";
                            $post->awssearch = true;
                            if ( $post ) {
                                $new_posts[] = $post;
                            }
                            $this->tax[$post->ID][] = $tax_term;
                        }
                    }
                }
            }
            if ( ! empty( $new_posts ) ) {
                $posts = $new_posts + $posts;
            }
            return $posts;
        }
        public function woocommerce_loop_product_link( $link ) {
            global $product;
            if ( $product ) {
                $id = $product->get_id();
                if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                    foreach( $this->tax[$id] as $key => $tax_term ) {
                        $link = $tax_term['link'];
                        unset( $this->tax[$id][$key] );
                        break;
                    }
                    return $link;
                }
            }
            return $link;
        }
        public function woocommerce_product_get_image( $image, $product, $size, $attr ) {
            $id = $product->get_id();
            if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                return wc_placeholder_img( $size, $attr );
            }
            return $image;
        }
        public function woocommerce_loop_add_to_cart_link( $output, $product ) {
            $id = $product->get_id();
            if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                return '';
            }
            return $output;
        }
        public function woocommerce_sale_flash( $output, $post, $product ) {
            $id = $product->get_id();
            if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                return '';
            }
            return $output;
        }
        public function woocommerce_get_price_html( $output, $product ) {
            $id = $product->get_id();
            if ( isset( $_REQUEST['type_aws'] ) && isset( $this->tax[$id] ) ) {
                return '';
            }
            return $output;
        }
    }
    new AWS_Add_Tax();

    You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

    Thread Starter carriekay

    (@carriekay)

    Hi,

    Thank you!

    I’ve just added it to our ‘Code Snippets’ plugin but it has not worked unfortunately.

    Kind regards,

    Nina @ Rene K

    Plugin Author ILLID

    (@mihail-barinov)

    Please tell me what WordPress theme you are using?

    Plugin Author ILLID

    (@mihail-barinov)

    ALso – do you use any page builder plugins to customize search results page?

    Thread Starter carriekay

    (@carriekay)

    Hi,

    We use the Shop Isle theme and we have not customised the search page.

    Kind regards,

    Nina @ Rene K

    Plugin Author ILLID

    (@mihail-barinov)

    Please tell me ?AWS plugin are currently active on your site?
    If so, please give me the link where I can find a plugin search form and test it.

    Thread Starter carriekay

    (@carriekay)

    Hi,

    I’m not sure what you mean, I can screenshot our plugins but I don’t know how to send them on here.

    Nina

    Plugin Author ILLID

    (@mihail-barinov)

    I mean – if Advanced Woo Search plugin are active on your site can you give me the link to the page where I can find plugins search form and test it?

    Thread Starter carriekay

    (@carriekay)

    Plugin Author ILLID

    (@mihail-barinov)

    Thanks, but it is the link to the standard search results page.

    Did you placed somewhere on your website AWS plugin search form? Those search forms that I see now are not plugin ones, but just some theme default forms.

    amihaidany

    (@amihaidany)

    Hello,

    I’m experiencing the same thing. After setting the ‘Search in’ to include tags, in the plugin settings page, we got not results relevant to the tags in the search PAGE (*not* ajax results).

    This has started after one of the last updates.
    Basically, when querying a search results page with the query string:
    ‘?s={s}&post_type=product&type_aws=true’, the search is not querying by tags.

    Thank you!

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Product tags not included in search’ is closed to new replies.