Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce 2.6 API v1 -> Invalid parameter

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?

like image 911
Harmstra Avatar asked Jul 30 '26 23:07

Harmstra


1 Answers

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;

like image 139
Harmstra Avatar answered Aug 01 '26 20:08

Harmstra