Created
December 5, 2017 16:10
-
-
Save abadrahman/18f2a3b3280dfd52217a528ab2cbeb3a to your computer and use it in GitHub Desktop.
Adding custom post meta to Woocommerce REST API V1
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
function ar_add_post_meta_to_order_api_response( $response ) { | |
$data = $response->get_data(); | |
// Adding your custom field: | |
$data['postmeta'] = get_post_meta( $data['id'] ); | |
$response->set_data( $data ); | |
return $response; | |
} | |
add_filter( 'woocommerce_rest_prepare_shop_order', 'ar_add_post_meta_to_order_api_response' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment