I don't think I understand the code here, for example why is this filter used:
add_action( 'woocommerce_single_product_summary', 'guardar_busqueda', 15,2);
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:Best,
If you like my products, don't forget to rate them on codecanyon :)