Home Forums WoodMart – Premium Template Relevansi plugin + Ajax Search for Everyone

This topic contains 15 replies, has 6 voices, and was last updated by  ggeeky 6 days, 8 hours ago.

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #64927

    newsprince
    Expert

    Dear xtemos team.

    I find a way to integrate Relevanssi plugin with your ajax form so that if someone uses a Relevanssi plugin can now search on all product information.

    Relevanssi plugin works just find on its own with your theme BUT on your AJAX search form doesn’t load the corresponding products. Let’s say for example i search “blue jeans” with blue the attribute of product jeans. Your form doesn’t bring any results unless you hit enter then the search is done via Relevanssi plugin.

    But you can integrate relevansi plugin on your ajax form by simply putting a line of code in search.php file.

    So on

    /wp-content/themes/woodmart/inc/classes/search.php

    On line 71

    after

    $results = new WP_Query( apply_filters( ‘woodmart_ajax_get_results’, $query_args ) );

    put that line of code

    relevanssi_do_query( $results );

    Now the AJAX search form brings the results from relevansi plugin so now the search term blue jeans bring the product results.

    If you want please implement it on future updates. It’s an one line of code and the rest of your theme users can now make more advanced search with the free relevansi plugin

    Thank you.

    Please note, for the modification to work Relevanssi plugin must be active.

    • This topic was modified 6 months, 4 weeks ago by  newsprince.
    #64967

    Hello,

    Thank you very much for the information. We will investigate this in the future.

    Regards

    #65026

    insideweb
    Customer

    Thank you for this feature sir. Seems working fine!

    #65055

    Thank you for the information.

    #65066

    newsprince
    Expert

    Side note for everyone that want to try it.

    To index the variation sku if the product is variable, so that the results will show the corresponding product you must add this snippet too on functions.php or with a snippet plugin.

    https://www.relevanssi.com/knowledge-base/indexing-product-variation-skus-main-product/

    add_filter('relevanssi_content_to_index', 'rlv_index_variation_skus', 10, 2);
    function rlv_index_variation_skus($content, $post) {
    	if ($post->post_type == "product") {
    		$args = array('post_parent' => $post->ID, 'post_type' => 'product_variation', 'posts_per_page' => -1);
    		$variations = get_posts($args);
    		if (!empty($variations)) {
    			foreach ($variations as $variation) {
    				$sku = get_post_meta($variation->ID, '_sku', true);
    				$content .= " $sku";
    			}
    		}
    	}
     
    	return $content;
    }

    Thank you

    #88883

    newsprince
    Expert

    Update:

    Woodmart version 3.2 changed file search.php location and made some modifications.

    Now you have to go to folder:

    /wp-content/themes/woodmart/inc/modules

    edit the search.php file and add after line 233 add:

    relevanssi_do_query( $results );

    That’s it.

    #90970

    Brandboutik
    Customer

    Brilliant Sir! Worked like a charm 🙂

    #101334

    mbiehl
    Customer

    Sorry, I can not php

    How should I exactly add it?

    233 $results = new WP_Query( apply_filters( ‘woodmart_ajax_get_results’, $query_args ) );
    234 $relevanssi_do_query ($ results);

    #101343

    newsprince
    Expert

    Yes like that but you have to install the Relevanssi plugin also

    #101345

    newsprince
    Expert

    Go to folder and open the file

    /wp-content/themes/woodmart/inc/modules/search.php

    #101407

    mbiehl
    Customer

    I have it installed and can not get it to work
    In the attachment times the file
    Thanks for your support

    #101409

    mbiehl
    Customer

    now with attachment

    Attachments:
    You must be logged in to view attached files.
    #101448

    newsprince
    Expert

    You have a space between $ and results.

    relevanssi_do_query($results);

    Copy paste this.

    #101669

    ggeeky
    Customer

    Hi,
    sorry to bother.
    I’ve tried to implement this plugin following your instruction but I can’t get it to work.
    Do you know of any other alternative? Thank you.

    #101737

    newsprince
    Expert

    It is working. Other people tried it too and works. We use it on our shop constantly. Just insert this line of code and then activate the relevanssi plugin. You have to setup the plugin to index the right properties of the products.

    I attach the file.

    Attachments:
    You must be logged in to view attached files.
    #101769

    ggeeky
    Customer

    Thank you. The issue was in the settings of the plugin.
    I very much appreciate your help.
    Have a good one

Viewing 16 posts - 1 through 16 (of 16 total)

You must be logged in to reply to this topic.