Automattic\WooCommerce\Internal\Admin
CategoryLookup::on_edit
When a product category gets edited, see if we need to sync the table.
Method of the class: CategoryLookup{}
No Hooks.
Returns
null. Nothing (null).
Usage
$CategoryLookup = new CategoryLookup(); $CategoryLookup->on_edit( $category_id );
- $category_id(int) (required)
- Term ID being edited.
CategoryLookup::on_edit() CategoryLookup::on edit code WC 10.5.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 );
}