Title: WooCommerce API
Last modified: October 26, 2018

---

# WooCommerce API

 *  Resolved [slimschip](https://wordpress.org/support/users/slimschip/)
 * (@slimschip)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/)
 * Hi,
 * I am in the process of creating a program that talks to the WooCommerce REST 
   API and I am trying to get the EAN data stored by this pluging via the “products”
   endpoint.
 * It it possible to get this data using the REST API and can you tell me how?
 * Kind regrads,
 * Martijn

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [Emanuela Castorina](https://wordpress.org/support/users/kreamweb/)
 * (@kreamweb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818699)
 * Hello,
    the EAN code it is a custom field this is the name ‘_wpm_gtin_code’ You
   should search how get custom fields with WooCommerce Rest API.
 *  Thread Starter [slimschip](https://wordpress.org/support/users/slimschip/)
 * (@slimschip)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818933)
 * Hi Emanuela,
 * When I search on how to get custom fields I run into circles and php code I do
   not understand (I’m a pyhon devoloper), but seem related to the way the php api
   works and how to handle the return data.
 * when I do a get on “products?filter[meta]=true” I do get the “product_meta” but
   no _wpm_gtin_code, in some places I see that “protected” values (starting with“_”)
   are not shown.
 * I have searched the API docs and tried google before I posted my question to 
   you.
 * I try to get the value in the response for a get. thats is all.
 * Any hint beyond “search how to get custom fields” would be highly appreciated.
 * Kind regards,
 * Martijn
    -  This reply was modified 7 years, 6 months ago by [slimschip](https://wordpress.org/support/users/slimschip/).
 *  Plugin Author [Emanuela Castorina](https://wordpress.org/support/users/kreamweb/)
 * (@kreamweb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818952)
 * I’ve never worked with Rest API but I found this that you can try
 *     ```
       add_filter( 'woocommerce_rest_prepare_product', 'custom_products_api_data', 90, 2 );
       function custom_products_api_data( $response, $post ) {
   
       // retrieve a custom field and add it to API response
       $response->data['ean_code'] = get_post_meta( $post->ID, '_wpm_gtin_code', true );
   
       return $response;
       }
       ```
   
 * [https://wordpress.stackexchange.com/questions/308591/woocommerce-product-custom-field](https://wordpress.stackexchange.com/questions/308591/woocommerce-product-custom-field)
 *  Thread Starter [slimschip](https://wordpress.org/support/users/slimschip/)
 * (@slimschip)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818968)
 * I have found that one too, there is no reference on where to add that code ….
 * As said I am not familiar with php development.
 * To me the whole issue is with the “_” at the start of “_wpm_gtin_code” as a fieldname
   in the wp_postmeta as that is a “protected” field. in the first place.
 * Martijn
 *  Plugin Author [Emanuela Castorina](https://wordpress.org/support/users/kreamweb/)
 * (@kreamweb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818974)
 * Put the script in the file functions.php of your theme.
 *  Thread Starter [slimschip](https://wordpress.org/support/users/slimschip/)
 * (@slimschip)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818982)
 * a bit off-topic, but wouldn’t that be overwitten by an update of the theme? that
   seems to be the case every time when there is a WC update.
 *  Plugin Author [Emanuela Castorina](https://wordpress.org/support/users/kreamweb/)
 * (@kreamweb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818984)
 * for the moment you can try, if this script works I’ll add it to the plugin.
 *  Thread Starter [slimschip](https://wordpress.org/support/users/slimschip/)
 * (@slimschip)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10818988)
 * oh cool!
 *  Thread Starter [slimschip](https://wordpress.org/support/users/slimschip/)
 * (@slimschip)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10819108)
 * That did not work, as you scroll down on that page the is a reply from someone
   telling that and a suggested fix. but:
 * I think this is close to what is needed:
 * [https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/](https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/)
 * I guess the info on this page is for the correct integration with the REST API
   for getting and adding changing the value.
 * It is that I am clueless about WP/WC/php… otherwise I would have hacked the plug-
   in to see if I could make it work.
 * I’m happy to test though as I am familiar with the REST API of WC.
 * Martijn
 *  Plugin Author [Emanuela Castorina](https://wordpress.org/support/users/kreamweb/)
 * (@kreamweb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10819345)
 * I made a test,
    I changed the file includes/class.product-gtin-wc.php with this
   code [https://gist.github.com/kreamweb/0452907d3ad0121a6535eedad2f7a85a](https://gist.github.com/kreamweb/0452907d3ad0121a6535eedad2f7a85a)
 * the ‘ean_code’ is present in the product detail:
    [http://nimb.ws/df9tRk](http://nimb.ws/df9tRk)
 * Let me know!
 *  Thread Starter [slimschip](https://wordpress.org/support/users/slimschip/)
 * (@slimschip)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10819519)
 * It works ! Thank you, I guess an update will just overwrite my hand made changes.
 * You are a live saver and deserve a big kiss!
 *  Plugin Author [Emanuela Castorina](https://wordpress.org/support/users/kreamweb/)
 * (@kreamweb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-10819713)
 * I’ll commit that file in the new release so you won’t lost these changes.
    This
   can be useful to other developer.
 * If you have two minutes could you leave a review for this plugin?
    [https://wordpress.org/support/plugin/product-gtin-ean-upc-isbn-for-woocommerce/reviews/](https://wordpress.org/support/plugin/product-gtin-ean-upc-isbn-for-woocommerce/reviews/)
 * Thank you!
 *  [arnebel](https://wordpress.org/support/users/arnebel/)
 * (@arnebel)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-11170058)
 * Would it be possible to link it also with: [https://your-site.com/wc-api/v2/products](https://your-site.com/wc-api/v2/products)?
   Our cash register system works with this.
 * Thanks in advance!
 *  [paul13234](https://wordpress.org/support/users/pavelreuk/)
 * (@pavelreuk)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-11260290)
 * Hi,
 * Do you know if the issue with using API to update the GTIN for the Product GTIN(
   EAN, UPC, ISBN) for WooCommerce plugin got resolved?
 * I’m trying to update the GTIN using API Post Calls and can’t seem to figure out
   why i can’t update using that method, please let me know if it was fixed and 
   how to resolve it on my end?
 * Thanks.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘WooCommerce API’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/product-gtin-ean-upc-isbn-for-woocommerce.
   svg)
 * [Product GTIN (EAN, UPC, ISBN) for WooCommerce](https://wordpress.org/plugins/product-gtin-ean-upc-isbn-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/product-gtin-ean-upc-isbn-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/product-gtin-ean-upc-isbn-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/product-gtin-ean-upc-isbn-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/product-gtin-ean-upc-isbn-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/product-gtin-ean-upc-isbn-for-woocommerce/reviews/)

 * 14 replies
 * 4 participants
 * Last reply from: [paul13234](https://wordpress.org/support/users/pavelreuk/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/woocommerce-api-6/#post-11260290)
 * Status: resolved