E
E
Egor2015-11-05 12:08:12
PHP
Egor, 2015-11-05 12:08:12

How to add attribute to woocommerce from existing ones?

In the admin, I created an attribute for example Manufacturers and added several values.
When I add in code

$att = array(
 'pa_proizvoditel' => Array(
   'name' => 'pa_proizvoditel',
   'value' => 'test',
   'position' => 0,
   'is_visible' => 1,
   'is_variation' => 0,
   'is_taxonomy' => 1),

update_post_meta( $post_id, '_product_attributes', $att);

The field is added, but empty. You have to manually select or write the value. Is there a way to add it right away?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question