Last active
August 17, 2017 20:16
-
-
Save kilbot/c9851f24b94c86c24d5ba7f26876a52c to your computer and use it in GitHub Desktop.
Customising the WC REST API v2 Order Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// the code below goes in your functions.php file | |
function my_custom_prepare_shop_order_object($response, $order, $request) { | |
$data = $response->get_data(); | |
if( function_exists('wc_seq_order_number_pro') ) { | |
$data['number'] = wc_seq_order_number_pro()->find_order_by_order_number( $data['id'] ); | |
} | |
$response->set_data($data); | |
return $response; | |
} | |
add_filter( 'woocommerce_rest_prepare_shop_order_object', 'my_custom_prepare_shop_order_object', 20, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment