Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Sorry, but for now the plugin doesn’t support such a feature.

    Regards

    Thread Starter dipokemon

    (@dipokemon)

    Can you tell me how I can use PHP to add a custom block before displaying the products in the Ajax block?
    Storing and outputting popular queries I will try to do it myself ??

    Plugin Author ILLID

    (@mihail-barinov)

    So you want to show that Popular Requests list once a user clicks on search form input or you want to display such a list just below the search form and set it to be always visible?

    Thread Starter dipokemon

    (@dipokemon)

    The first option. When the user clicks on the search bar, popular queries are displayed. When the user enters something, products are displayed under the popular queries. As on the screenshot.
    https://skr.sh/sNFpG6UtRhK

    • This reply was modified 11 months, 2 weeks ago by dipokemon.
    Thread Starter dipokemon

    (@dipokemon)

    @mihail-barinov
    Is there any way to do this?
    I tried using

    add_action('aws_get_results', 'custom_search_results_block', 10);

    but that didn’t work.

    Plugin Author ILLID

    (@mihail-barinov)

    You can try to use code like this:

    add_action( 'wp_enqueue_scripts', 'aws_wp_enqueue_scripts', 999 );
    function aws_wp_enqueue_scripts() {
    
        $block_name = 'Popular Requests';
        $links = array(
            'request 1', 'request 2', 'request 3'
        );
    
        $block = '';
        
        $block .= "<div class='aws-suggestions aws_results style-inline'>";
            $block .= "<span style='display:block;padding: 15px;border-bottom: 1px solid #ccc;font-weight:700;'>" . $block_name . "</span>";
            foreach ( $links as $link ) {
                $block .= "<div class='aws_result_item'>";
                $block .= "<a href='#'>" . $link . "</a>";
                $block .= "</div>";
            }
        $block .= "</div>";
    
    
        $script = ' 
            function aws_results_html( html, options ) { 
    			if ( ! html.includes("aws-suggestions") ) {
    						    html = "'. $block .'" + html; 
    
    			}
                return html; 
            } 
    		document.addEventListener("awsLoaded", function() {
                AwsHooks.add_filter( "aws_results_html", aws_results_html ); 
    		});
        ';
        wp_add_inline_script( 'aws-script', $script);
        wp_add_inline_script( 'aws-pro-script', $script);
    }
    Thread Starter dipokemon

    (@dipokemon)

    Thank you very much, it’s working.
    Another question. Is it possible to make this block show up when clicking on the search form? Now the block is shown only when something is entered into the line.

    Plugin Author ILLID

    (@mihail-barinov)

    I am afraid that for now there is no feature to add such a block on form focus.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Popular requests’ is closed to new replies.