• Resolved macfan007

    (@krgauravit007)


    HI,
    I would like to apply this instant search in default search box. How do i do ?
    I am using storefront child theme.
    Pl advice.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi, in file functions.php, of your storefront child theme, add

    
    /* Remove Storefront Product Search in Header */
    add_action( 'init', 'jk_remove_storefront_header_search' );
    function jk_remove_storefront_header_search() {
    	remove_action( 'storefront_header', 'storefront_product_search', 40);
    }
    
    /* Add Ajax Search for woocommerce */
    function custom_storefront_search() {
        if ( storefront_is_woocommerce_activated() ) { ?>
          <div class="site-search">
            <?php
    	if( class_exists( 'DGWT_WCAS_Search' ) ) {
    		echo do_shortcode('[wcas-search-form]');
    	}
    	?>
          </div>
        <?php
        }
    }
    add_action('storefront_header', 'custom_storefront_search', 40);
    
    Plugin Author Damian Góra

    (@damian-gora)

    Hello,

    Thanks Carret for your solution. I really appreciate that.

    Thread Starter macfan007

    (@krgauravit007)

    Thanks @carret for snippet. It worked.
    Thanks @damian-gora – Plugin is great.

    One more thing, I can see autosuggest (Search box) working for Desktop version of site, but it doesn’t work on mobile version of site. Any advice.

    Thanks

    Hi Team thanks for wonderful plugin this is really useful for customer on site.

    I can see autosuggest (Search box) working for Desktop version of site, but it doesn’t work on mobile version of site. Any advice.

    Thread Starter macfan007

    (@krgauravit007)

    Yea, I am also looking for solution for mobile version. Pl advice.

    • This reply was modified 7 years, 2 months ago by macfan007. Reason: text
    Plugin Author Damian Góra

    (@damian-gora)

    Hi,
    I found alternative solution. Paste following code into functions.php in your Storefront child theme.

    
    if ( class_exists( 'DGWT_WCAS_Search' ) ) {
    	if ( ! function_exists( 'storefront_product_search' ) ) {
    		function storefront_product_search() {
    			if ( storefront_is_woocommerce_activated() ) { ?>
                    <div class="site-search">
    					<?php echo do_shortcode( '[wcas-search-form]' ); ?>
                    </div>
    				<?php
    			}
    		}
    	}
    	add_action( 'wp_footer', 'asfwc_inverse_orientation_on_mobile' );
    	function asfwc_inverse_orientation_on_mobile() {
    		?>
            <script>
                jQuery(window).on('load', function () {
                    var $footerSearch = jQuery('.storefront-handheld-footer-bar .dgwt-wcas-search-input');
                    if ($footerSearch.length > 0) {
                        $footerSearch.dgwtWcasAutocomplete('setOptions', {
                                orientation: 'top',
                                forceFixPosition: true
                            }
                        );
                    }
                });
            </script>
    		<?php
    	}
    }
    

    More readable: https://gist.github.com/damian-gora/81552a794434f2715aa31ae2751ad8f2

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how to use plugin for default search box’ is closed to new replies.