I have a program that sends products to the woocommerce backed website. I succesfully have it sending single products but variable products are only 90% of the way there.

When I send it I create the parent product, then I create the sub products. I update the meta of the parent product and set the _product_attributes meta value correctly. In fact if I look in the back end of the website I get the following sort of view:

enter image description here

What you may notice is that the variations have "Any Size" instead of stating which size they are linked to. I manually did the top one to confirm the problem and it indeed fixed the issue. However, I am trying to find what actually happens in the database when a product is "linked" in this way. I have tried to compare the parent post in the posts and the postmeta and the child product in the post and the postmeta tables and for the life of me I have spent more than 6 hours and can't find the issue.

I even created a product directly in wordpress and noticed that what I want happens when Link all variations is clicked. But again I would rather not get sucked in to the spaghetti code to try and find what field I am missing if anyone knows this already.

I hope you can help, please let me know if you require more information.


Well I have found the issue. I thought that I had it sussed when I was adding in the _attribute_size to my postmeta for the variations. However, i had miss read it for close to 5 hours as it should have been attribute_size (size being the name of the attribute that I was adding).

Feel stupid however, this answer may be useful to others who are trying to do the same sort of thing.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.