Save custom attributes of product in woocommerce

I have some custom attributes for each product in woocommerce, I can edit them at the Attributes tab. I can also read them using this code

$product = new WC_Product($product_id);
$v = $product->get_attribute(‘myattr_name’);

But I don’t understand how to set this attribute value. Googling not helps. Do you know? I am looking for something like this

$product->set_attribute(‘myattr_name’, $new_value);

But as I can see, there is no such method.

Read more here:: Save custom attributes of product in woocommerce

Leave a Reply

Your email address will not be published. Required fields are marked *