Skip to content

Variable Product (Add variation without options) #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gabrielgiorisatto opened this issue Dec 17, 2020 · 2 comments
Open

Variable Product (Add variation without options) #252

gabrielgiorisatto opened this issue Dec 17, 2020 · 2 comments

Comments

@gabrielgiorisatto
Copy link

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?

@tepafril
Copy link

I have the same issue

@intercollector
Copy link

intercollector commented May 10, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants