Get transaction_id with woocommerce order through REST API

Other topics

The WordPress woocommerce api response order hook.

/*add this code to your function.php file
  now your api will include transaction_id
*/

add_action( 'woocommerce_api_order_response', 'my_woocommerce_api_order', 10, 2);

function my_woocommerce_api_order( $data ) {

    //you can do anything with the $data here lets add the transaction id
    $data['transaction_id'] = get_post_meta( $data['id'], '_transaction_id', true );          
    
    return $data;
}

Contributors

Topic Id: 4704

Example Ids: 16530

This site is not affiliated with any of the contributors.