WC_Product_Data_Store_CPT::update_attributes PHP Method

update_attributes() protected method

Update attributes which are a mix of terms and meta data.
Since: 2.7.0
protected update_attributes ( &$product )
    protected function update_attributes(&$product)
    {
        $attributes = $product->get_attributes();
        $meta_values = array();
        if ($attributes) {
            foreach ($attributes as $attribute_key => $attribute) {
                $value = '';
                if (is_null($attribute)) {
                    if (taxonomy_exists($attribute_key)) {
                        // Handle attributes that have been unset.
                        wp_set_object_terms($product->get_id(), array(), $attribute_key);
                    }
                    continue;
                } elseif ($attribute->is_taxonomy()) {
                    wp_set_object_terms($product->get_id(), wp_list_pluck($attribute->get_terms(), 'term_id'), $attribute->get_name());
                } else {
                    $value = wc_implode_text_attributes($attribute->get_options());
                }
                // Store in format WC uses in meta.
                $meta_values[$attribute_key] = array('name' => $attribute->get_name(), 'value' => $value, 'position' => $attribute->get_position(), 'is_visible' => $attribute->get_visible() ? 1 : 0, 'is_variation' => $attribute->get_variation() ? 1 : 0, 'is_taxonomy' => $attribute->is_taxonomy() ? 1 : 0);
            }
        }
        update_post_meta($product->get_id(), '_product_attributes', $meta_values);
    }