Filter admin ajax data by url query
Filter admin ajax data by url query
Filter admin ajax data by url query
Solution to my own problem: Enqueue your custom file.js and localize admin-ajax.php. index.php function script_enqueue() { // Register the JS file with a unique handle, file location, and an array of dependencies wp_register_script(“dt_csc”, plugin_dir_url(__FILE__). ‘js/cdt.js’, array(‘jquery’)); // localize the script to your domain name, so that you can reference the url to admin-ajax.php file easily … Read more
First I’d recommend you to make sure $meal_type = get_field(‘meal_type’); returns array of strings – to do this you can simply call var_dumb($meal_type) after getting this field value. So for example if you’ve used a Repeater field for meal_type, you’ll see array of arrays and not array of strings. Also It’s kind of strange thing … Read more
If you want to create global variable intentionally you need to do this. window[‘your_variable_name’]= ‘Some variable value’; then you’ll be able to access it like window.your_variable_name – this way of creating and accessing global variable guarantees that you will work with same variable regardless of what build tools like webpack or from where you access … Read more
jQuery is not defined because you’ve not referred jQuery as dependency for your script so wp isn’t aware it should load it for your script. wp_localize_script should be called on script that is already linked via wp_enqueue_script, so you first run wp_enqueue_script then wp_localize_script as you do in your UPD. Another thing about wp_localize_script is … Read more
About sending emails: wp_mail by default utilizes default PHP’s mailing setting, and PHP by default uses sendmail service so if you don’t have one functioning on localhost you’ll not be able to sendemails, you can use something like MailHog – to capture send emails for you on localhost and you’ll actually will be able to … Read more
You need the function accessible to the AJAX hook when it’s fired, so move the get_states_by_ajax_callback function to your functions.php
add_filter( ‘woocommerce_add_to_cart_fragments’, function($fragments) { ob_start(); ?> <li class=”my_cart”><a href=”javascript:void(0)” id=”sidebarCollapse” class=”carticonmain”><svg xmlns=”http://www.w3.org/2000/svg” style=”display: none;”> <symbol id=”shopping-cart” viewBox=”0 0 700 700″><title>shopping-cart</title> <path d=”m150.355469 322.332031c-30.046875 0-54.402344 24.355469-54.402344 54.402344 0 30.042969 24.355469 54.398437 54.402344 54.398437 30.042969 0 54.398437-24.355468 54.398437-54.398437-.03125-30.03125-24.367187-54.371094-54.398437-54.402344zm0 88.800781c-19 0-34.402344-15.402343-34.402344-34.398437 0-19 15.402344-34.402344 34.402344-34.402344 18.996093 0 34.398437 15.402344 34.398437 34.402344 0 18.996094-15.402344 34.398437-34.398437 34.398437zm0 0″></path> <path d=”m446.855469 94.035156h-353.101563l-7.199218-40.300781c-4.4375-24.808594-23.882813-44.214844-48.699219-48.601563l-26.101563-4.597656c-5.441406-.96875-10.632812 … Read more
You are doing it all wrong, place your code like the following in your file. <?php echo ‘hook called’; // This is not showing any message exit(); global $woocommerce; $product_id = $_POST[‘selected_package_id’]; echo $product_id; // This is not displaying id exit(); $found = false; //check if product already in cart if ( sizeof( WC()->cart->get_cart() ) … Read more
Pass values to ajax