Open gabrielgiorisatto opened 3 years ago
I have the same issue
I have found that when using the REST API it is possible to add a variable product, with an option list that is empty. Then, subsequently when adding the variation, you are allowed to set the variable to any value. Here are example bodies for each request:
Product - POST /wp-json/wc/v3/products
{ "name": "Workshop Example", "type": "variable", "description": "", "sku": "W13002", "price": "2150", "attributes": [ { "name": "WorkshopId", "variation": true, "options":[] } ], "stock_status": "instock" }
Product Variable - POST /wp-json/wc/v3/products/14609/variations/batch
{ "create": [ { "regular_price": "2250", "stock_status": "instock", "attributes": [ { "name": "WorkshopId","option":"a0U6900001XL7G0"} ] }, { "regular_price": "2250", "stock_status": "instock", "attributes": [ { "name": "WorkshopId","option":"a0UMz000000BXa9"} ] } } ] }
The good news is that this works. The bad news is that after the data is passed in, the UI for managing the product and product variations is broken (any future save done by administrators wipes out the WorkshopId that I've placed using the REST API).
Could we get a fix by woocommerce to allow for non-predefined product variations?
I'm trying to create a variable product with the REST API (Node.Js). The problem is that I don't have all the "options" when creating the variable product. When I send a POST to create a variation, the variation is not created unless I update the variable product adding the "option" of the variation. Is this really the only way of adding a variation? Why the variation post does not add the option to the "parent" product?