Answer the question
In order to leave comments, you need to log in
How to programmatically update a product attribute?
Unable to update product attribute normally. Tried a lot of options, it doesn't work.
$product = new WC_Product_Simple(39587);
$attribute = new WC_Product_Attribute();
$attribute->set_id(0);
$attribute->set_name("pa_size");
$attribute->set_options([1689]); //id атрибута
$attribute->set_position(0);
$attribute->set_visible(1);
$attribute->set_variation(0);
$attributes["pa_size"] = $attribute;
$product->set_attributes($attributes);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question