Ajax Called in Plugin php file

You should not use your own AJAX handler PHP file. Your problem is that your file calls add_action() function and that function is part of WordPress, your file is not loaded in the WordPress context, so that function is not loaded. You need to load WP in your file first. But, that is not a …

Read more

Return custom product in ajax call loop

Yes, you can query products by their ids and display them as ajax response. You code just needs a little revision. Perhaps you could try something along these lines, public function display_search_result(){ $skus = urldecode($_POST[‘sku_universel’]); $skus = explode(‘,’,$sku); $product_ids = array(); // you can use native woocommerce function to get the product ids foreach($skus as …

Read more

Trigger a JavaScript function based on the data fetched from Woo commerce hook

After going through a lot of articles and solutions I finally figured it out: Directory Structure for the plugin (Boilerplate directory structure used from here) First step: Register a js script which would track the event/ user activity and pass it the ajax URL through which it would fetch the product details via ajax. // …

Read more