Issues with the xstore search products form

This topic has 20 replies, 2 voices, and was last updated 1 month, 2 weeks ago ago by Andrew Mitchell

  • Avatar: mitys
    mitys
    Participant
    February 16, 2026 at 19:37

    Hello,
    We are facing some issues related to the results of the xstore search products form.

    1* When we search with a variation SKU (with one letter missing for ex.)(search variations option enabled), the product is displayed more than once (one per variation that has an SKU that would match with our search term)(The results are not easily distinguishable since we have the same product title repeated x times).

    2* With WPML activated in our website, when we search with the term “itouch” for example, we get results displayed in both languages: french and english when they are supposed to follow the user selected language.

    3* When we disable the search variations option, we are no longer enable to get the parent product displayed in the search results (while searching with the variation SKU for example).

    Thanks for your help

    Please, contact administrator
    for this information.
    19 Answers
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 17, 2026 at 09:36

    Hello, mitys,

    We have noticed that your website is utilizing a large number of plugins. This could potentially impact the website’s performance, lead to errors, and affect its overall speed. To ensure optimal functionality and avoid such issues, we kindly ask you to manually review each plugin currently in use on your website.

    If the problem persists, we suggest switching to the Parent theme if you are currently using the Child Theme on your site. After clearing the cache, check again.
    Do the same test for the default WooCommerce theme – Storefront. The issue may be due to your custom code in the Child Theme.

    Let us know the results.

    Best regards,
    8Theme’s Team

    Avatar: mitys
    mitys
    Participant
    February 18, 2026 at 17:49

    Hello,
    Can you tell me please how did you proceed to disable the inclusion of variations in the search results ?
    Thank you.

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 19, 2026 at 11:27

    Hello,

    In this case, the SKU of the parent product should be similar to the SKU of its variations.

    For example, if the parent product has the SKU test-12-12, then the variations should have SKUs such as test-12-12-1, test-12-12-2, and so on.

    Best regards,
    8Theme Team

    Avatar: mitys
    mitys
    Participant
    February 19, 2026 at 20:17

    Hello, okay, get the point.
    However, my question was more related to the screenshot that you’ve sent. Because I’d like to enable the variations search and test it with an other theme / other plugins disabled…
    Thank you.

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 20, 2026 at 08:42

    Hello, mitys,

    Our search by variations is available only for the XStore theme.
    Best regards,
    The 8Theme Team

    Avatar: mitys
    mitys
    Participant
    February 20, 2026 at 20:55

    Sorry, I meant the parent theme instead of the child theme.

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 23, 2026 at 08:03

    Hello, mitys,
    The search by variations is also available in the parent theme too
    Best regards,
    8Theme Team

    Avatar: mitys
    mitys
    Participant
    February 23, 2026 at 22:39

    They are currently disabled, how can I enable them ?

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 24, 2026 at 10:18

    Hello, mitys,
    we were looking for variations. To do this yourself, you need to open the header in the Elementor editor mode, go to the Ajax search element, and in the data type field, select the product variation as shown in the screenshot attached to the post.

    Best Regards,
    8Theme’s Team

    Files is visible for topic creator and
    support staff only.
    Avatar: mitys
    mitys
    Participant
    February 24, 2026 at 21:11

    Hello, I’ve tried that but it didn’t work, you’ve sent to us this screenshot in the past: https://prnt.sc/xzMlvyAB0fnH
    But I cannot find where it is located..

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 25, 2026 at 08:58

    Hello, mitys,

    We have enabled this option for you and are also providing a video showing where to find it in the future.

    Best regards,
    The 8Theme Team

    Files is visible for topic creator and
    support staff only.
    Avatar: mitys
    mitys
    Participant
    February 25, 2026 at 21:45

    Hello, thank you for the demonstrating video.
    I’ve finally succeded to include the search variations again in the staging site. However, I disabled the other than woocommerce and WPML plugins and I also switched from the child theme to the parent them, and I still get search results in both languages despite the fact that I’ve already selected the ‘En’ Language (search by UGS: V50-0202QH).

    Please contact administrator
    for this information.
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    February 26, 2026 at 09:31

    Hello, mitys,

    to fix this issue you have added the following custom code to your child theme. Please check if the issue persists.

    /**
     * Ensure product search by SKU respects selected language in XStore et_search requests.
     */
    add_filter( 'posts_where', 'xstore_child_limit_product_search_by_lang', 999, 2 );
    function xstore_child_limit_product_search_by_lang( $where, $query ) {
        if ( is_admin() || ! ( $query instanceof WP_Query ) ) {
            return $where;
        }
    
        if ( empty( $_GET['et_search'] ) || ! $query->is_search() ) {
            return $where;
        }
    
        $post_type = $query->get( 'post_type' );
        $is_product_query = ( 'product' === $post_type ) || ( is_array( $post_type ) && in_array( 'product', $post_type, true ) );
        if ( ! $is_product_query ) {
            return $where;
        }
    
        $lang = $query->get( 'lang' );
        if ( empty( $lang ) && isset( $_GET['lang'] ) ) {
            $lang = wp_unslash( $_GET['lang'] );
        }
    
        $lang = is_string( $lang ) ? preg_replace( '/[^a-zA-Z_-]/', '', $lang ) : '';
        if ( '' === $lang ) {
            return $where;
        }
    
        global $wpdb;
    
        // WPML: limit products to requested language.
        if ( defined( 'ICL_SITEPRESS_VERSION' ) || defined( 'ICL_LANGUAGE_CODE' ) ) {
            $icl_table = $wpdb->prefix . 'icl_translations';
            $condition = $wpdb->prepare(
                " AND EXISTS (
                    SELECT 1 FROM {$icl_table} icl
                    WHERE icl.element_id = {$wpdb->posts}.ID
                    AND icl.element_type = 'post_product'
                    AND icl.language_code = %s
                )",
                $lang
            );
    
            return $where . $condition;
        }
    
        // Polylang: limit products by language taxonomy relation.
        if ( defined( 'POLYLANG_VERSION' ) || function_exists( 'pll_current_language' ) ) {
            $condition = $wpdb->prepare(
                " AND EXISTS (
                    SELECT 1
                    FROM {$wpdb->term_relationships} tr
                    INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
                    INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id
                    WHERE tr.object_id = {$wpdb->posts}.ID
                    AND tt.taxonomy = 'language'
                    AND t.slug = %s
                )",
                $lang
            );
    
            return $where . $condition;
        }
    
        return $where;
    }

    Best Regards,
    8Theme’s Team

    Avatar: mitys
    mitys
    Participant
    February 27, 2026 at 21:01

    Hello, I’ve implemented this code and the variations are no longer displayed in the search results with it…

    Please contact administrator
    for this information.
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    March 1, 2026 at 16:08

    Could you please provide temporary FTP access? We will check what can be done to help you.

    For FTP access, we require the following details: FTP host, FTP username, FTP password, FTP port, and FTP encryption type. If you need assistance in creating these credentials, please reach out to your hosting provider who will guide you through the process.

    Best Regards,
    8Theme’s Team

    Avatar: mitys
    mitys
    Participant
    March 3, 2026 at 13:02

    Hello, Here they are.

    Please contact administrator
    for this information.
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    March 3, 2026 at 17:18

    Hello, mitys,

    We have made some changes to the functions.php file of your child theme. Please check whether the issue still persists.

    Best regards,
    8Theme Team

    Avatar: mitys
    mitys
    Participant
    March 3, 2026 at 23:56

    Hello, it seems that it is fixed now.
    However, while searching with an SKU, we found that in the search results we do have variations displayed with the parent product title. Therefore, we cannot distinguish between them and the same product parent (image and title) is repeated x times.
    Could you check that please ?

    Please contact administrator
    for this information.
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    March 4, 2026 at 10:41

    Hello Mitys,

    We have once again made changes to the functions.php file of your child theme. Please check whether the issue still persists. This time, we have added code that normalizes the display of variations.

    /**
     * XStore et_search: show variations distinctly in results (title + link to selected variation).
     * - Keeps variations in results
     * - Title becomes: "Parent Product — Color: Cosmos, Size: L"
     * - Link opens parent product with variation preselected via attribute query args
     */
    
    add_filter('the_title', 'xstore_child_search_variation_title', 100, 2);
    function xstore_child_search_variation_title($title, $post_id) {
        if (is_admin() || !is_search()) return $title;
        if (empty($_GET['et_search'])) return $title;
    
        $post = get_post($post_id);
        if (!$post || $post->post_type !== 'product_variation') return $title;
    
        if (!function_exists('wc_get_product')) return $title;
    
        $variation = wc_get_product($post_id);
        if (!$variation) return $title;
    
        $parent = wc_get_product($variation->get_parent_id());
        $parent_name = $parent ? $parent->get_name() : $title;
    
        // Human-readable attributes (e.g. "Color: Cosmos, Size: L")
        $attrs = wc_get_formatted_variation($variation, true, false, true);
    
        if ($attrs) {
            return $parent_name . ' — ' . $attrs;
        }
    
        // Fallback: show SKU if attributes are empty
        $sku = $variation->get_sku();
        return $sku ? ($parent_name . ' — SKU: ' . $sku) : $parent_name;
    }
    
    add_filter('post_type_link', 'xstore_child_search_variation_link_to_parent', 100, 2);
    function xstore_child_search_variation_link_to_parent($permalink, $post) {
        if (is_admin() || !is_search()) return $permalink;
        if (empty($_GET['et_search'])) return $permalink;
    
        if (!$post || $post->post_type !== 'product_variation') return $permalink;
        if (!function_exists('wc_get_product')) return $permalink;
    
        $variation = wc_get_product($post->ID);
        if (!$variation) return $permalink;
    
        $parent_id = (int) $variation->get_parent_id();
        if (!$parent_id) return $permalink;
    
        $parent_link = get_permalink($parent_id);
        if (!$parent_link) return $permalink;
    
        // Add attribute_pa_xxx=yyy so Woo selects the variation on load
        $args = $variation->get_variation_attributes();
        if (!is_array($args) || empty($args)) {
            return $parent_link;
        }
    
        return add_query_arg($args, $parent_link);
    }

    Best regards,
    8Theme Team

  • Viewing 20 results - 1 through 20 (of 20 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.