From c973ff93c0b85802fa172a88b6b8bd7df9fccad8 Mon Sep 17 00:00:00 2001 From: Leif Singer Date: Tue, 16 Apr 2024 17:01:30 +0200 Subject: [PATCH] Fix Woo.com reference in the Inbox during onboarding (#46600) * Fix: Woo.com Reference in the Inbox During Onboarding * add changelog file * fix linting error --- .../changelog/fix-connect-to-woocommerce-note | 4 ++++ .../woocommerce/includes/class-wc-install.php | 1 + .../includes/wc-update-functions.php | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 plugins/woocommerce/changelog/fix-connect-to-woocommerce-note diff --git a/plugins/woocommerce/changelog/fix-connect-to-woocommerce-note b/plugins/woocommerce/changelog/fix-connect-to-woocommerce-note new file mode 100644 index 00000000000..69d95270014 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-connect-to-woocommerce-note @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix Woo.com reference in the inbox during onboarding. diff --git a/plugins/woocommerce/includes/class-wc-install.php b/plugins/woocommerce/includes/class-wc-install.php index a7b9920dd91..84fb2f015b4 100644 --- a/plugins/woocommerce/includes/class-wc-install.php +++ b/plugins/woocommerce/includes/class-wc-install.php @@ -250,6 +250,7 @@ class WC_Install { ), '8.9.0' => array( 'wc_update_890_add_launch_your_store_tour_option', + 'wc_update_890_update_connect_to_woocommerce_note', ), ); diff --git a/plugins/woocommerce/includes/wc-update-functions.php b/plugins/woocommerce/includes/wc-update-functions.php index b9bd901ea79..e48d0aae820 100644 --- a/plugins/woocommerce/includes/wc-update-functions.php +++ b/plugins/woocommerce/includes/wc-update-functions.php @@ -18,8 +18,11 @@ defined( 'ABSPATH' ) || exit; +use Automattic\WooCommerce\Admin\Notes\Note; +use Automattic\WooCommerce\Admin\Notes\Notes; use Automattic\WooCommerce\Database\Migrations\MigrationHelper; use Automattic\WooCommerce\Internal\Admin\Marketing\MarketingSpecs; +use Automattic\WooCommerce\Internal\Admin\Notes\WooSubscriptionsNotes; use Automattic\WooCommerce\Internal\AssignDefaultCategory; use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer; use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore; @@ -2673,3 +2676,22 @@ function wc_update_870_prevent_listing_of_transient_files_directory() { function wc_update_890_add_launch_your_store_tour_option() { update_option( 'woocommerce_show_lys_tour', 'yes' ); } + +/** + * If it exists, remove and recreate the inbox note that asks users to connect to `Woo.com` so that the domain name is changed to the updated `WooCommerce.com`. + */ +function wc_update_890_update_connect_to_woocommerce_note() { + $note = Notes::get_note_by_name( WooSubscriptionsNotes::CONNECTION_NOTE_NAME ); + if ( ! is_a( $note, 'Automattic\WooCommerce\Admin\Notes\Note' ) ) { + return; + } + if ( ! str_contains( $note->get_title(), 'Woo.com' ) ) { + return; + } + if ( $note->get_status() !== Note::E_WC_ADMIN_NOTE_SNOOZED && $note->get_status() !== Note::E_WC_ADMIN_NOTE_UNACTIONED ) { + return; + } + Notes::delete_notes_with_name( WooSubscriptionsNotes::CONNECTION_NOTE_NAME ); + $new_note = WooSubscriptionsNotes::get_note(); + $new_note->save(); +}