Woocommerce updating taxonomy attribute labels
-
I have a an attribute that is a taxonomy, i need to update the attribute label. Here is what i’ve done iso far
$args = array(
‘category’ => array(‘chinese’),
‘orderby’ => ‘name’,
);
$products = wc_get_products($args);
foreach($products as $product)
{
$attribute = $product->get_attributes();foreach($attribute as $attributeItem)
{if($attributeItem->is_taxonomy())
{
$attributeItem->get_taxonomy_object()->attribute_label = “new-label”; //set new label}
}
$product->set_attributes($attribute);
$product-save();
}If i read back the product attribute, the label is not updated (reading the old label), i need to update the attribute label and save it to the database so that when the value gets read back, it reflects the newly updated label.
What am i missing ?
- The topic ‘Woocommerce updating taxonomy attribute labels’ is closed to new replies.