Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter distl

    (@distl)

    Hi

    Sorry I am not able to provide you access to the site that this is being used on.

    The problem is that on the WC search page, the search input field and search for title is being cleared / not displaying the last input you may have typed in on submit.

    I have made a temporary fix by adding this function “proceedToSearchGSF” to mu-plugins which is overwriting your function.

    function proceedToSearchGSF($query)
    {
        $search_string  = get_query_var('s');
        $product_ids    = [];
        $variation_ids  = [];
        $sku            = [];
        $productData    = array();
        $args           = ['s' => $search_string, 'limit' => 5];
        $products       = wc_get_products($args);
        if ($products) {
            foreach ($products as $value) {
                $variation_id = isset($value->get_children()[0]) ? $value->get_children()[0] : 0;
                array_push($product_ids, $value->id);
                array_push($variation_ids, $variation_id);
                array_push($sku, $value->sku);
            }
        }
        if ($product_ids) {
            $products_ids = implode(',', $product_ids);
        }
    
        $productData['product_id']      = $product_ids;
        $productData['search_string']   = $search_string;
        $productData['variation_id']    = $variation_ids;
        $productData['sku']             = $sku;
    
        callJSFuncGSF($productData, "proceedToSearchGSF"); 
    
        return $query; /* This was missing from original plugin, remove once plugin returns the query */
    }

    Your function “proceedToSearchGSF” (in helper/helper.php) is filtering the WP core function “get_search_query”
    https://wp-kama.com/hook/get_search_query which requires a return $query.

    If you just search through your plugin code for “proceedToSearchGSF” you will find the function that is missing a return.

    Hope this helps

Viewing 1 replies (of 1 total)