Search code examples
wordpresswoocommercewordpress-hook

How to find your action in admin-ajax.php file?


I am using woo commerce plugin for my eCommerce website. There are some order listed on my dashboard. When I change status of an order from processing to completed we click on button.

Here is my action goes:

if ( in_array( $the_order->post_status, array('wc-pending', 'wc-on-hold', 'wc-processing') ) )
     $actions['complete'] = array(
         'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=upen-mark-order-complete&order_id=' . $the_order->id ), 'upen-mark-order-complete' ),
         'name' => __( 'Dispatched', 'dokan' ),
         'action' => "complete",
         'icon' => '<i class="fa fa-truck">&nbsp;</i>'
     );

But when I am looking into admin-ajax.php file there is no order_id getting. I am confused that where these attributes are we getting to change order status like action, order_id etc.


Solution

  • You should read wp_ajax_(action).

    based on your given code, there should be something like this implemented somewhere... maybe on your theme files or plugin files..

    add_action( 'wp_ajax_upen-mark-order-complete', 'my_action_callback' );
    
    function my_action_callback() {
    
        $order_id = $_GET['order_id'];
    
        wp_die(); 
    }
    

    additionally,
    With notepad++ you can search it in your files like this..

    enter image description here