WooCommerce-REST-API-Client-Library icon indicating copy to clipboard operation
WooCommerce-REST-API-Client-Library copied to clipboard

Custom fields

Open dtezcan opened this issue 9 years ago • 1 comments

Hi,

I'm trying to update a product with a custom field. Is it possible to do that with this program? and if so how?

current code: `$data = array( 'product' => (object) array( 'managing_stock' => true, 'in_stock' => $inStock, 'stock_quantity' => $aantal, 'regular_price' => (string) $itemresult[$i]->prijs ) );

$woocommerce->products->update($variationid, $data);`

Thanks :)

dtezcan avatar Jul 07 '16 12:07 dtezcan

Hi there! Had the same problem and found the solution. You need to create a API catch handler in your child theme's functions.php. Some saint made this already. Save the class in your child theme folder and include the php class in your functions.php file. The class is here: https://github.com/judgej/wc-api-custom-meta
You then can send them in the same array query from this api client by using syntax below:.
'custom_meta' => array( '_custom_field_A' => 'valuea', '_custom_field_B' => 'valueb')

dyluck07 avatar Jul 08 '16 17:07 dyluck07