A javascript function that simply runs a php function on the plugin

In your JS code, you need an action so it knows what function to execute. var data = { ‘action’: ‘my_action’, ‘nothing’: ‘nothing’ ‘whatever’: ajax_object.we_walue } You should see how the action corresponds to the hook you used in add_action. But I would also add a second action: add_action(‘wp_ajax_my_action’, ‘back_php’); add_action(‘wp_ajax_no_priv_my_action’, ‘back_php’); This will ensure … Read more

Find the method which AJAX GET calls

If the url is something like this admin-ajax.php?example_ajax_request=1&data=1234 The add_action function in the code would be wp_ajax_nopriv_example_ajax_request So, try to grep the whole of your theme directory or plugin directory for the text. Example: grep -r ‘wp_ajax_nopriv_example_ajax_request’ * The second parameter of the add_action is the function name you’re looking for. See https://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Viewer-Facing_Side for example … Read more

Problem with conditional woocommerce custom checkout field

Ok, I figured it out (finally) Instead of using the code above to add a new custom field, I changed it to this: add_filter( ‘woocommerce_checkout_fields’, ‘custom_override_checkout_fields’ ); function custom_override_checkout_fields ( $fields ) { $fields[‘order’][‘the_script’] = array ( woocommerce_form_field ( ‘the_script’, array( ‘type’ => ‘textarea’, ‘class’ => array(‘extracheckoutinfo form-row-wide’), ‘label’ => __(‘What is the script?’), ‘placeholder’ … Read more