wc_update_attribute()
Update an attribute.
For available args see wc_create_attribute().
Хуков нет.
Возвращает
int|WP_Error
.
Использование
wc_update_attribute( $id, $args );
- $id(int) (обязательный)
- Attribute ID.
- $args(массив) (обязательный)
- Attribute arguments.
Список изменений
С версии 3.2.0 | Введена. |
Код wc_update_attribute() wc update attribute WC 8.7.0
function wc_update_attribute( $id, $args ) { global $wpdb; $attribute = wc_get_attribute( $id ); $args['id'] = $attribute ? $attribute->id : 0; if ( $args['id'] && empty( $args['name'] ) ) { $args['name'] = $attribute->name; } $args['old_slug'] = $wpdb->get_var( $wpdb->prepare( " SELECT attribute_name FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = %d ", $args['id'] ) ); return wc_create_attribute( $args ); }