Woocommerce add to simple product attribute programmatically [closed]

wp_set_object_terms( $productID, 'black', 'pa_color', true );

$att_color = Array('pa_color' =>Array(
       'name'=>'pa_color',
       'value'=>'black',
       'is_visible' => '1',
       'is_taxonomy' => '1'
     ));

update_post_meta( $productID, '_product_attributes', $att_color);

Leave a Comment