diff --git a/src/Hooks/WooMetaboxes.php b/src/Hooks/WooMetaboxes.php index 52c7048..63dd17f 100644 --- a/src/Hooks/WooMetaboxes.php +++ b/src/Hooks/WooMetaboxes.php @@ -111,17 +111,15 @@ public function save_product_meta( ): void { // As the hook seems to be run twice for some reason, this should // prevent the function to run twice during the same HTTP request. - global $nineteen_eighty_four_woo_dk_meta_update_has_run; - if ( isset( $nineteen_eighty_four_woo_dk_meta_update_has_run ) ) { + if ( defined( '1984_DK_WOO_META_UPDATE_HAS_RUN' ) ) { return; } + define( '1984_DK_WOO_META_UPDATE_HAS_RUN', true ); + self::set_product_sync_meta_from_post( $wc_product, 'price' ); self::set_product_sync_meta_from_post( $wc_product, 'stock' ); self::set_product_sync_meta_from_post( $wc_product, 'name' ); - - $nineteen_eighty_four_woo_dk_meta_update_has_run = true; - global $nineteen_eighty_four_woo_dk_meta_update_has_run; } /** diff --git a/src/Hooks/WooUpdateProduct.php b/src/Hooks/WooUpdateProduct.php index e2ad497..50b7afb 100644 --- a/src/Hooks/WooUpdateProduct.php +++ b/src/Hooks/WooUpdateProduct.php @@ -64,7 +64,7 @@ public static function on_product_update( return; } - if ( defined( 'DOING_DK_SYNC' ) ) { + if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) { return; } @@ -104,7 +104,7 @@ public static function before_post_delete( int $post_id ): void { return; } - if ( defined( 'DOING_DK_SYNC' ) ) { + if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) { return; } @@ -156,7 +156,7 @@ public static function post_status_change( return; } - if ( defined( 'DOING_DK_SYNC' ) ) { + if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) { return; } diff --git a/src/Import/Currencies.php b/src/Import/Currencies.php index 35a5d00..d6a7b62 100644 --- a/src/Import/Currencies.php +++ b/src/Import/Currencies.php @@ -22,11 +22,11 @@ class Currencies { * Fetches all the currency rates from DK */ public static function save_all_from_dk(): void { - if ( defined( 'DOING_DK_SYNC' ) ) { + if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) { return; } - define( 'DOING_DK_SYNC', true ); + define( '1984_DK_WOO_DOING_SYNC', true ); $json_objects = self::get_all_from_dk(); diff --git a/src/Import/Products.php b/src/Import/Products.php index 9d794fc..9841468 100644 --- a/src/Import/Products.php +++ b/src/Import/Products.php @@ -44,8 +44,8 @@ class Products { * This should be run at least nightly as a wp-cron job. */ public static function save_all_from_dk(): void { - if ( ! defined( 'DOING_DK_SYNC' ) ) { - define( 'DOING_DK_SYNC', true ); + if ( ! defined( '1984_DK_WOO_DOING_SYNC' ) ) { + define( '1984_DK_WOO_DOING_SYNC', true ); } $json_objects = self::get_all_from_dk();