Is it possible to use custom field value for product name when using Woocommerce REST API?
I have added a key for DHL in REST API settings. Now I want to add a custom field on every product (it will be short names) so it will be used when sending API request for DHL, instead of original product names.
Question posted in Woocommerce
The official Woocommerce documentation can be found here.
The official Woocommerce documentation can be found here.
2
Answers
You can use the SKU field of the product.
WooCommerce API allows you to GET products via the SKU field for example – add to your GET products (without a product id) params &sku=DD1213 and your will receive said product – I don’t recall if Woocommerce allows SKU duplicates but if it does… than don’t! 🙂
So that means you can GET a product via SKU query example (PHP Curl):
This is only for the GET purposes – for updating and others you will need to use the product ID endpoint.
I found a number of other developers with solutions for this on github, here is one, yes I know it is for secondary SKU, but it should be fairly trivial to modify it to cater for a secondary Product Name.
https://github.com/pmgarman/wc-international-sku