diff --git a/plugins/woocommerce-admin/changelogs/fix-wc31285-disable-coupon-notice-for-new-installs b/plugins/woocommerce-admin/changelogs/fix-wc31285-disable-coupon-notice-for-new-installs new file mode 100644 index 00000000000..7d17175a289 --- /dev/null +++ b/plugins/woocommerce-admin/changelogs/fix-wc31285-disable-coupon-notice-for-new-installs @@ -0,0 +1,4 @@ +Significance: patch +Type: Fix + +Prevent coupon move notice for new installs. #7995 diff --git a/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php b/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php index c1fd11a35c8..dcabd72f0a9 100644 --- a/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php +++ b/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php @@ -33,6 +33,7 @@ class CouponPageMoved { add_action( 'admin_init', [ $this, 'possibly_add_note' ] ); add_action( 'admin_init', [ $this, 'redirect_to_coupons' ] ); + add_action( 'woocommerce_admin_newly_installed', [ $this, 'disable_legacy_menu_for_new_install' ] ); } /** @@ -45,6 +46,11 @@ class CouponPageMoved { return false; } + // Don't add the notice if the legacy coupon menu is already disabled. + if ( ! self::should_display_legacy_menu() ) { + return false; + } + // Don't add the notice if it's been hidden by the user before. if ( self::has_dismissed_note() ) { return false; @@ -55,11 +61,6 @@ class CouponPageMoved { return false; } - // If new navigation feature is enabled. - if ( Features::is_enabled( 'navigation' ) ) { - return false; - } - return isset( $_GET[ self::$query_key ] ) && (bool) $_GET[ self::$query_key ]; // phpcs:ignore WordPress.Security.NonceVerification } @@ -148,4 +149,11 @@ class CouponPageMoved { wp_safe_redirect( self::get_management_url( 'coupons' ) ); exit; } + + /** + * Disable legacy coupon menu when installing for the first time. + */ + public function disable_legacy_menu_for_new_install() { + $this->display_legacy_menu( false ); + } }