Skip to content

Instantly share code, notes, and snippets.

@kilbot
Last active August 17, 2017 20:16
Show Gist options
  • Save kilbot/c9851f24b94c86c24d5ba7f26876a52c to your computer and use it in GitHub Desktop.
Save kilbot/c9851f24b94c86c24d5ba7f26876a52c to your computer and use it in GitHub Desktop.
Customising the WC REST API v2 Order Number
<?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