kloon/WooCommerce-REST-API-Client-Library

Variations not working

bedoya opened this issue · 0 comments

Maybe this library is a little too old, but I was looking for one exactly like this. Sadly it does not have support for variations. I tried creating the method to create a variation, adding the following code to the /lib/woocommerce-api/resources/class-wc-api-client-resource-products.php

public function create_variation( $id, $data ) {
	$this->set_request_args( array(
		'method' => 'POST',
		'body'   => $data,
		'path'   => $id . '/variations',
	) );
	return $this->do_request();
}

I made sure the product with ID $id exists, but I keep getting a message about the URL is not working, the localhost URL is:

POST: http://localhost/wordpress/wc-api/v2/products/$id/variations