Skip to content

Commit

Permalink
Adding a further check for the product update hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aldavigdis committed Jul 9, 2024
1 parent f8fe39d commit 878d371
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/Hooks/WooUpdateProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ public static function on_product_update(
return;
}

if ( is_null( $wc_product ) || false === $wc_product ) {
return;
}

if (
'product_variation' ===
$wc_product->get_meta( '1984_dk_woo_origin', true, 'edit' )
) {
return;
}

if ( ! ProductHelper::should_sync( $wc_product ) ) {
return;
}
Expand Down Expand Up @@ -100,6 +111,13 @@ public static function before_post_delete( int $post_id ): void {
return;
}

if (
'product_variation' ===
$wc_product->get_meta( '1984_dk_woo_origin', true, 'edit' )
) {
return;
}

if (
in_array(
get_post_type( $post_id ),
Expand Down Expand Up @@ -137,8 +155,7 @@ public static function post_status_change(
}

if (
false ===
in_array(
! in_array(
get_post_type( $post ),
array( 'product', 'product_variation' ),
true
Expand All @@ -153,6 +170,13 @@ public static function post_status_change(
return;
}

if (
'product_variation' ===
$wc_product->get_meta( '1984_dk_woo_origin', true, 'edit' )
) {
return;
}

if ( ! ProductHelper::should_sync( $wc_product ) ) {
return;
}
Expand Down

0 comments on commit 878d371

Please sign in to comment.