I want to delete all variations using REST API without passing variation ID. I didn't see any instructions in wooCommerce REST API doc.
1 Answer
I solved it by using an alternative method. The two requests created in this method. First, to call the product than pass the response variation ID's to another batch request, It will delete all the variations but still there is a limit of maximum 100 variation ID's. It won't delete more than 100 variations in a single request.
If anyone knows the better method, please share.
WooCommerce.get("products/794")
.then((response) => {
WooCommerce.post("products/"+response.data.id+"/variations/batch", response.data.variations)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
})
.catch((error) => {
console.log(error.response.data);
});