WC_Post_Data::edited_term()
When a term is edited, check for product attributes and update variations.
Метод класса: WC_Post_Data{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = WC_Post_Data::edited_term( $term_id, $tt_id, $taxonomy );
- $term_id(int) (обязательный)
- Term ID.
- $tt_id(int) (обязательный)
- Term taxonomy ID.
- $taxonomy(строка) (обязательный)
- Taxonomy slug.
Код WC_Post_Data::edited_term() WC Post Data::edited term WC 9.6.1
public static function edited_term( $term_id, $tt_id, $taxonomy ) { if ( ! is_null( self::$editing_term ) && strpos( $taxonomy, 'pa_' ) === 0 ) { $edited_term = get_term_by( 'id', $term_id, $taxonomy ); if ( $edited_term->slug !== self::$editing_term->slug ) { global $wpdb; $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND meta_value = %s;", $edited_term->slug, 'attribute_' . sanitize_title( $taxonomy ), self::$editing_term->slug ) ); $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = REPLACE( meta_value, %s, %s ) WHERE meta_key = '_default_attributes'", serialize( self::$editing_term->taxonomy ) . serialize( self::$editing_term->slug ), serialize( $edited_term->taxonomy ) . serialize( $edited_term->slug ) ) ); } } else { self::$editing_term = null; } }