我对 API REST 有这个问题。我创建了带有属性和选项的产品变体。有用!我的产品已经是 type = 变量。
但是,如果我在同一个产品 ID 上创建第二个产品变体 :( post('products/'.ID.'/variations',$data)
) 它不起作用。
我可以在产品变体列表 ( get('products/ID/variations')
) 中看到它,但在 wp 的后端我看到了 2 个变体:第一个有术语,第二个没有。
有什么帮助吗?
这是所有产品变体的 LIST 的响应(我可以看到两个变体的属性):
^ array:2 [ 0 => {#1679 +"id": 27485 +"date_created": "2021-08-12T10:01:26" +"date_created_gmt": "2021-08-12T08:01:26" +"date_modified": "2021-08-12T10:03:08" +"date_modified_gmt": "2021-08-12T08:03:08" +"description": "" +"permalink": "https://wp.demo....it/prodotto/carl-gustafs-lampada/?attribute_pa_taglia=s" +"sku": "1657 - 2190" +"price": "4.53" +"regular_price": "5.34" +"sale_price": "4.53" +"attributes": array:1 [ 0 => {#1669 +"id": 47 +"name": "Taglia" +"option": "S" } ] } } 1 => {#1674 +"id": 27484 +"date_created": "2021-08-12T10:00:26" +"date_created_gmt": "2021-08-12T08:00:26" +"date_modified": "2021-08-12T10:00:26" +"date_modified_gmt": "2021-08-12T08:00:26" +"description": "" +"permalink": "https://wp.demo...it/prodotto/carl-gustafs-lampada/?attribute_pa_taglia=xxl" +"sku": "1657 - 2189" +"price": "3.21" +"regular_price": "3.21" +"sale_price": "" +"attributes": array:1 [ 0 => {#1172 +"id": 47 +"name": "Taglia" +"option": "XXL" } ] } ]