This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Collect search phrases when 'No results'

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Collect search phrases when 'No results'

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #11641
    fespigadofespigado
    Participant

    Hi there,

    I need to collect the phrases searched by users when the result is ‘No Result’ to later save it to a table.
    I can not capture or use the trigger after the search.

    //add_filter( ‘asp_results’, ‘guardar_busqueda’, 1, 1 );
    add_filter( ‘asp_ajax_results’, ‘guardar_busqueda’, 1, 2 );
    //add_action( ‘asp_after_search’, ‘guardar_busqueda’, 10, 1);
    //add_filter(‘asp_only_non_keyword_results’,’guardar_busqueda’);
    add_action(‘woocommerce_single_product_summary’,’guardar_busqueda’,15);

    function guardar_busqueda($results) {
    Global $wpdb;

    $user = wp_get_current_user();
    if (empty($results[‘nores’])){
    //if (!empty($results[‘nores’])){
    var_dump ($results);
    $wpdb->insert( wpt3_noresults,
    array( ‘id_usuario’=> $user->ID,
    ‘nombre_usuario’ => $user->user_login,
    ‘busqueda’=> $s),
    array(‘%s’,’%s’,’%s’));
    if( ! $insert ) {
    $wpdb->show_errors();}
    }else{
    $results = apply_filters( ‘asp_only_keyword_results’, $results );
    foreach ($results as $k=>$v) {
    $results[$k]->title = $results[$k]->title ;
    }
    }
    return $results;
    }

    Please I need help

    #11685
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    I would recommend using this code skeleton to extend for the functionality:

    [php]add_filter( ‘asp_after_search’, ‘guardar_busqueda’, 10, 2 );

    function guardar_busqueda($s, $results) {

    if ( empty($results) ) {
    // No results, no keyword suggestions
    } else if ( isset($results[‘keywords’]) ) {
    // No results, but there are keyword suggestions
    } else {
    // There are results
    }

    return $results;
    }[/php]

    This way you can do different actions when there are no results, some keyword suggestions or results present 🙂

    #11700
    fespigadofespigado
    Participant

    You cannot access this content.

    #11702
    Ernest MarcinkoErnest Marcinko
    Keymaster

    I don’t think I understand the code here, for example why is this filter used:

    [php]add_action( ‘woocommerce_single_product_summary’, ‘guardar_busqueda’, 15,2);[/php]

    This is most likely incorrect and giving an error, as the ‘woocommerce_single_product_summary’ is executed on the bottom of the product with a single parameter, and without information of any search results or phrases, it’s not used for that.

    Do you want to save the phrases on ajax search results, or when redirected to the results page? Because the code above only works for ajax results, not the results page. For the results page I rather recommend using the built in ‘post_results’ filter:

    #11703
    fespigadofespigado
    Participant

    Thanks for the quick reply.
    Sorry for the code so dirty. I was trying to see that he gave me back the variables.
    What I need is collect the searched words with no results or suggested words and insert in a table.

    Thank you

    #11704
    fespigadofespigado
    Participant

    You cannot access this content.

    #11707
    fespigadofespigado
    Participant

    You cannot access this content.

    #11714
    fespigadofespigado
    Participant

    Morning,Help me solve that problem. I have the customer waiting for this job.

    Thank you

    #11715
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Please note that supports stands for fixing issues with the plugin mainly, and your requesting me to make a custom code for you, which is not part of this process. I can try to help as much as I can, but I cannot guarantee a custom code will work, you will have to verify it.

    This code was working for me on a test table:

    ..and my test table looked like this:

    If you need help with customizations or extending the plugin, I recommend wpkraken.io service. They are professionals, and does not outsorce the work to anyone.

    #11728
    fespigadofespigado
    Participant

    Thank you very much for your attention.
    I understand that the support is not for that. Just commenting, I have not asked you to write the code, since the first code I sent you was already well under way with some errors;-) Thank you very much for your attention. Right now I write a super positive rating on codecanyon

    #11730
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You are very welcome 🙂

    Let me know if something is not clear, or not working, I’m more than happy to suggest possibilities if I can.

    #11780
    fespigadofespigado
    Participant

    Thanks a lot for you help. It’s everything ok

    #11781
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Collect search phrases when 'No results'’ is closed to new replies.