新api的文档可以在这里找到Woocommerce Rest API
您可以通过将数据发布到wp json端点来创建Woocommerce产品/wp-json/wc/v1/products
(Documentation Here)
$data = [
\'name\' => \'Premium Quality\',
\'type\' => \'simple\',
\'regular_price\' => \'21.99\',
\'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.\',
\'categories\' => [
[
\'id\' => 9
],
[
\'id\' => 14
]
],
\'images\' => [
[
\'src\' => \'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg\',
\'position\' => 0
],
[
\'src\' => \'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg\',
\'position\' => 1
]
]
];
print_r($woocommerce->post(\'products\', $data));
这将使用基于WP REST API的新REST API
第一个变化是端点,在我们当前的API中,您可以使用以下方式获取订单:
https://your-woo-store.com/wc-api/v3/orders
新的REST API将使用:
https://your-woo-store.com/wp-json/wc/v1/orders