Skip to content

Instantly share code, notes, and snippets.

@emoop
Created February 17, 2014 21:07
Show Gist options
  • Save emoop/9059144 to your computer and use it in GitHub Desktop.
Save emoop/9059144 to your computer and use it in GitHub Desktop.
Get product custom field when get product in Woocmmerce REST API
<?php
/* if you have get a custom field use this filter*/
add_filter('woocommerce_api_product_response','get_custom_field');
// '_brand' is my custom field
function get_custom_field($product){
$product['brand']=get_post_meta($product['id'],'_brand',true);
return $product;
}
?>
@ymsstudios
Copy link

Exactly what I was looking for!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment