I'm trying to add products to Woocommerce with the Wordpress API as per https://github.com/woothemes/wc-api-php
I am using the Wordpress API /wp-json/wc/v1
This is my data
Array
(
[type] => simple
[name] => Bike
[regular_price] => 300
[description] => This is a new bike
)
Then I do $woocommerce->post('products',$data);
But the regular_price won't work. Without it it works fine, when I add it I get errors like
Invalid parameter regular_price [rest_invalid_param]
Not sure if this is the exact error, translated it from Dutch
Any ideas?
Solved! regular_price has to be a string, I assigned a integer to it
Changed
$wcProduct['regular_price'] = $moxPart->price;
to
$wcProduct['regular_price'] = (string)$moxPart->price;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With