I want to create a new product with woocommerce api. I have a color attribute and i'd like to recognize product from sku for example codeblack.
My problem is how to do this.
While creating a product with tilte,description,sku etc it's ok. To create a product with attributes, i added 'type' => 'variable'
.
Now i have attributes, i enabled variations but i cannot give value to my variation.
Here's my code
$client->products->create(
array(
'title' => 'Premium Quality',
'type' => 'variable',
'sku' => 'code',
'regular_price' => '29.98',
'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
'images' => array(
array(
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
'position' => 0
),
array(
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
'position' => 1
)
),
'attributes' => array(
array(
'name'=>'color',
'slug'=>'color',
'position'=>'0',
'visible'=>'true',
'variation'=>'true',
'options'=>array('red','black')
)
),
'variations' => array(
array(
'sku' => 'codered',
'regular_price' => '29.98',
'attributes' => array(
array(
'name'=>'color',
'options'=>'red'
)
)
),
array(
'sku' => 'codeblack',
'regular_price' => '29.98',
'attributes' => array(
array(
'name'=>'color',
'options'=>'black'
)
)
)
)
)
);
but i can't to matching them with variations
Could you please help me?