• Resolved aldoarnet

    (@aldoarnet)


    When I search the site using the Ajax Search plugin and do not type any information and type enter or click search on the site, it returns all products. How to block the empty search without information? And if it would be possible to include information such as “type something to search for what you want”?

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

Viewing 1 replies (of 1 total)
  • Plugin Author Damian Góra

    (@damian-gora)

    Hi,

    Block empty search:
    Yes, you can do it using following code:

    add_action( 'wp_footer', function () {
    	?>
    	<script>
    		(function ($) {
    			$(document).ready(function () {
    				$('.dgwt-wcas-search-form').on('submit', function (e) {
    
    					if ($(this).find('.dgwt-wcas-search-input').val() == '') {
    						e.preventDefault();
    						return false;
    					}
    
    				});
    			});
    		})(jQuery);
    	</script>
    	<?php
    } );

    You can paste it into functions.php file in your child theme or use the Code Snippets plugin.

    Change placeholder:
    You can fo it via plugin settings. Go to WooCommerce -> AJAX Search bar -> Search bar (tab) and change option “Search input placeholder”.

    Best
    Damian

Viewing 1 replies (of 1 total)
  • The topic ‘Empty Search’ is closed to new replies.