Add multiple attribute values to product via php
-
Hello,
I’m trying to add multiple attributes with multiple values to a product using php, but no luck. Only last attribute value is added to the list.$values_attr="option1,option2,option3"; $attribute_values = explode(",", $values_attr); foreach($attribute_values as $attribute) { wp_set_object_terms($post_id, $attribute, "pa_test_attr", false); } $product_attributes['pa_test_attr'] = array( 'name' => "pa_test_attr", 'value' => $attribute_values, 'position' => 0, 'is_visible' => 0, 'is_variation' => 0, 'is_taxonomy' => 1 ); update_post_meta($post_id, '_product_attributes', $product_attributes);
What could be the issue? Thank you!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Add multiple attribute values to product via php’ is closed to new replies.