Automattic\WooCommerce\Internal\Admin

CategoryLookup::on_edit()publicWC 1.0

When a product category gets edited, see if we need to sync the table.

Метод класса: CategoryLookup{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$CategoryLookup = new CategoryLookup();
$CategoryLookup->on_edit( $category_id );
$category_id(int) (обязательный)
Term ID being edited.

Код CategoryLookup::on_edit() WC 8.7.0

public function on_edit( $category_id ) {
	global $wpdb;

	if ( ! isset( $this->edited_product_cats[ $category_id ] ) ) {
		return;
	}

	$category_object = get_term( $category_id, 'product_cat' );
	$prev_parent     = $this->edited_product_cats[ $category_id ];
	$new_parent      = $category_object->parent;

	// No edits - no need to modify relationships.
	if ( $prev_parent === $new_parent ) {
		return;
	}

	$this->delete( $category_id, $prev_parent );
	$this->update( $category_id );
}