Я хотел добавить продукт с вариантами, используя API WordPress / WooCommerce.
Я могу успешно добавить продукт с изображениями и атрибутами, но не могу преобразовать эти атрибуты в варианты.
Вот код, который я использовал, используя формат JSON в почтальоне или любом клиенте API.
Я могу добавить товар с сохраненными атрибутами, связанными с товаром. Однако варианты не регистрируются и цена варианта не указывается.
{ "name": "Ship Your Idea",
"type": "variable",
"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.",
"regular_price":"24",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg"
}
],
"attributes": [
{
"id": 6,
"position": 0,
"visible": false,
"variation": true,
"options": [
"Black",
"Green"
]
},
{
"name": "Size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"S",
"M"
]
}
],
"default_attributes": [
{
"id": 6,
"option": "Black"
},
{
"name": "Size",
"option": "S",
"regular_price": "9.00"
}
]
}