Product Variations Deleted On Save (When changing product type)
-
So I created a product type that uses the Variable type as its base. It works great, wordpress treats it like a variable product. HOWEVER, there is a weird edge case that I’m working with and I can’t seem to figure out the solution:
If I create a product as a Variable product first, generate the variations, then save it. The variations work.
If I create a product as Variable-Clone product, generate variations, then save it. The variations work.
If I create a product as a Variable product, generate variations, then save it, then change the product type to Variable-Clone and save it again…. the variations get deleted. I checked it’s not like some ID changing thing where wordpress just doesn’t see the variations. I checked the database and the X number of products with post_type “product_variation” for that item are removed from the wp_posts table.
I just also ran the test and converted a product from Variable product to “Simple Product” and then back to Variable product and the same thing happens (so it’s not code on my end).
I’m guessing this is some kind of housekeeping to make sure there aren’t stray variable products sitting around causing issues. However, it really messes with my setup. Is there a way to fix this? If not can someone help me find where in the code it’s happening and I’ll just create a hook manually and maybe submit it to core (and just keep updating my own version until it gets accepted)
Thanks so much.
- The topic ‘Product Variations Deleted On Save (When changing product type)’ is closed to new replies.