I try to add a post meta for the product attribute but its not showing in product. It creates but blank both field names and values. How should I fix this? there are no errors
Sample Code for updating/insert woocommerce product attributes
update_post_meta( $post->ID , '_product_attributes', [
'name' => 'Size',
'value' => 'S|M|L',
'position' => 0,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 1
] );
I didn't see that missing array needed. Solution below.
update_post_meta( $post->ID , '_product_attributes', [
'size' => [
'name' => 'Size',
'value' => 'S|M|L',
'position' => 0,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 1
]
] );