woocommerce deposit Form with AJAX and shortcode won’t update but add to previous output

Actually figured it out, it was due to the way I printed the data in the main function. Instead of simply outputting it, I placed it in a variable using ob_start and ob_get_clean. It’s all fixed and the code now becomes: //Display deposit choice and add to cart shortcode function add_product_display( $atts ) { $atts … Read more

Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin

My action was wrong in the ajax request jQuery(document).ready(function () { jQuery(“.redeem_gift_card”).click(function (e) { e.preventDefault(); jQuery.ajax({ type: “post”, dataType: “json”, url: myAjax.ajaxurl, data: { action: “gift_card_redeem” }, // not redeem_gift_card success: function (response) { if (response.type == “success”) { jQuery(“#test”).html(response.type); } else { alert(“something broke”); } }, }); }); });

In a plugin, How to update a json file using ajax

Here is your main problem: chemin = plugin_dir_url( __FILE__ ) . “inc/json/notes.json”; There are 5 critical mistakes in the code: file_get_contents requires a file path, but you’re asking for a URL by using plugin_dir_url, not all servers support remote URLs in file_get_contents for security reasons, and if they do, this would be a big performance … Read more

Forbidden Error in ajax call with wordpress

Not sure why this error occur! you may follow this article Or you can review your code in following steps: Use wp_enqueue_scripts and wp_ajax_{action_name} wp_ajax_nopriv_{action_name} in your plugin file. Suppose my plugin name is test-plugin and my main plugin file name is test-plugin.php <?php /* Plugin Name: Test Plugin Plugin URI: http://wordpress.org Description: This just … Read more