From de7716a24fb4b6cdad9a152a49ca42050058081c Mon Sep 17 00:00:00 2001 From: Gerhard Date: Tue, 16 Apr 2024 11:47:12 +0200 Subject: [PATCH 1/7] Replace WCS&T tax onboarding with Woo Tax onboarding. Add Woo Shipping & Woo Tax install functions to Addons page override for when core introduces this. Surpress Woo Shipping & Woo Tax messaging from WC core when they get added. --- .../class-wc-calypso-bridge-addons-screen.php | 44 ++++++++++++++++++- includes/class-wc-calypso-bridge-plugins.php | 3 +- ...c-calypso-bridge-admin-note-data-store.php | 2 + src/free-trial/tax/utils.ts | 2 +- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/includes/class-wc-calypso-bridge-addons-screen.php b/includes/class-wc-calypso-bridge-addons-screen.php index 68e824df..2889ef2b 100644 --- a/includes/class-wc-calypso-bridge-addons-screen.php +++ b/includes/class-wc-calypso-bridge-addons-screen.php @@ -68,8 +68,12 @@ public static function output() { return; } - if ( isset( $_GET['install-addon'] ) && 'woocommerce-services' === $_GET['install-addon'] ) { // WPCS: CSRF ok. - self::install_woocommerce_services_addon(); + if ( isset( $_GET['install-addon'] ) && 'woocommerce-tax' === $_GET['install-addon'] ) { // WPCS: CSRF ok. + self::install_woo_tax_addon(); + } + + if ( isset( $_GET['install-addon'] ) && 'woocommerce-shipping' === $_GET['install-addon'] ) { // WPCS: CSRF ok. + self::install_woo_shipping_addon(); } $sections = self::get_sections(); @@ -103,4 +107,40 @@ public static function output() { */ include_once WC_ABSPATH . 'includes/admin/views/html-admin-page-addons.php'; } + + /** + * Install Woo Tax from Extensions screens. + */ + public static function install_woo_tax_addon() { + check_admin_referer( 'install-addon_woocommerce-tax' ); + + $services_plugin_id = 'woocommerce-tax'; + $services_plugin = array( + 'name' => __( 'Woo Tax', 'woocommerce' ), + 'repo-slug' => 'woocommerce-tax', + ); + + WC_Install::background_installer( $services_plugin_id, $services_plugin ); + + wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) ); + exit; + } + + /** + * Install Woo Shipping from Extensions screens. + */ + public static function install_woo_shipping_addon() { + check_admin_referer( 'install-addon_woocommerce-shipping' ); + + $services_plugin_id = 'woocommerce-shipping'; + $services_plugin = array( + 'name' => __( 'Woo Shipping', 'woocommerce' ), + 'repo-slug' => 'woocommerce-shipping', + ); + + WC_Install::background_installer( $services_plugin_id, $services_plugin ); + + wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) ); + exit; + } } diff --git a/includes/class-wc-calypso-bridge-plugins.php b/includes/class-wc-calypso-bridge-plugins.php index 86a4a22e..5d0c59b0 100644 --- a/includes/class-wc-calypso-bridge-plugins.php +++ b/includes/class-wc-calypso-bridge-plugins.php @@ -22,7 +22,8 @@ class WC_Calypso_Bridge_Plugins { const WPCOM_ECOMMERCE_PLUGINS = array( 'woocommerce/woocommerce.php', 'facebook-for-woocommerce/facebook-for-woocommerce.php', - 'woocommerce-services/woocommerce-services.php', + 'woocommerce-tax/woocommerce-tax.php', + 'woocommerce-shipping/woocommerce-shipping.php', 'woocommerce-product-addons/woocommerce-product-addons.php', 'woocommerce-product-bundles/woocommerce-product-bundles.php', 'woocommerce-gift-cards/woocommerce-gift-cards.php', diff --git a/includes/notes/data/class-wc-calypso-bridge-admin-note-data-store.php b/includes/notes/data/class-wc-calypso-bridge-admin-note-data-store.php index d6f527e3..ac153dcb 100644 --- a/includes/notes/data/class-wc-calypso-bridge-admin-note-data-store.php +++ b/includes/notes/data/class-wc-calypso-bridge-admin-note-data-store.php @@ -164,6 +164,8 @@ protected function get_suppress_list() { 'wc-admin-selling-online-courses', // suppress for now, to be revisited. // Extensions. 'woocommerce-services', + 'woocommerce-tax', + 'woocommerce-shipping', 'gla-invalid-php-version', 'gla-64-bit', 'gla-wc-admin', diff --git a/src/free-trial/tax/utils.ts b/src/free-trial/tax/utils.ts index a3c3bf47..8c72b396 100644 --- a/src/free-trial/tax/utils.ts +++ b/src/free-trial/tax/utils.ts @@ -7,7 +7,7 @@ import { TaskType } from '@woocommerce/data'; /** * Plugins required to automate taxes. */ -export const AUTOMATION_PLUGINS = [ 'jetpack', 'woocommerce-services' ]; +export const AUTOMATION_PLUGINS = [ 'woocommerce-tax' ]; /** * Check if a store has a complete address given general settings. From 877af640151a8c71b9e751c89cc91d4e38706be0 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Tue, 16 Apr 2024 11:58:35 +0200 Subject: [PATCH 2/7] Update tax step wording to exclude Jetpack and reflect Woo Tax instead. --- src/free-trial/tax/woocommerce-tax/card.tsx | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/free-trial/tax/woocommerce-tax/card.tsx b/src/free-trial/tax/woocommerce-tax/card.tsx index 174952c6..47ad2ff6 100644 --- a/src/free-trial/tax/woocommerce-tax/card.tsx +++ b/src/free-trial/tax/woocommerce-tax/card.tsx @@ -17,7 +17,7 @@ import { TaxChildProps } from '../utils'; export const Card: React.FC< TaxChildProps > = () => { return ( = () => { strong: , }, } ), - interpolateComponents( { - mixedString: __( - 'Powered by {{link}}Jetpack{{/link}}', - 'woocommerce' - ), - components: { - link: ( - - <> - - ), - }, - } ), // eslint-disable-next-line @wordpress/i18n-translator-comments __( '100% free', 'woocommerce' ), ] } terms={ interpolateComponents( { mixedString: __( - 'By installing WooCommerce Tax and Jetpack you agree to the {{link}}Terms of Service{{/link}}.', + 'By installing Woo Tax you agree to the {{link}}Terms of Service{{/link}}.', 'woocommerce' ), components: { From a14424fb0e54e287d40036a928c0b4b2a34489d9 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Tue, 16 Apr 2024 13:00:23 +0200 Subject: [PATCH 3/7] Update Woo Tax name --- src/free-trial/tax/woocommerce-tax/setup.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/free-trial/tax/woocommerce-tax/setup.tsx b/src/free-trial/tax/woocommerce-tax/setup.tsx index 1dce0ff1..b2d525fc 100644 --- a/src/free-trial/tax/woocommerce-tax/setup.tsx +++ b/src/free-trial/tax/woocommerce-tax/setup.tsx @@ -106,7 +106,7 @@ export const Setup: React.FC< SetupProps > = ( { key: 'connect', label: __( 'Automate Taxes', 'woocommerce' ), description: __( - 'WooCommerce Tax can automate your sales tax calculations for you.', + 'Woo Tax can automate your sales tax calculations for you.', 'woocommerce' ), content: , From 1bed100156cce19bb54578936abf15ee192f75c3 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Tue, 16 Apr 2024 13:01:51 +0200 Subject: [PATCH 4/7] Fix typo --- src/free-trial/tax/woocommerce-tax/card.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/free-trial/tax/woocommerce-tax/card.tsx b/src/free-trial/tax/woocommerce-tax/card.tsx index 47ad2ff6..c0d8bdaa 100644 --- a/src/free-trial/tax/woocommerce-tax/card.tsx +++ b/src/free-trial/tax/woocommerce-tax/card.tsx @@ -17,7 +17,7 @@ import { TaxChildProps } from '../utils'; export const Card: React.FC< TaxChildProps > = () => { return ( Date: Tue, 16 Apr 2024 14:56:48 +0200 Subject: [PATCH 5/7] Update option name to the one Woo Tax uses `woo_tax_taxes_enabled` --- src/free-trial/tax/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/free-trial/tax/index.tsx b/src/free-trial/tax/index.tsx index ccb0eb77..11ad3597 100644 --- a/src/free-trial/tax/index.tsx +++ b/src/free-trial/tax/index.tsx @@ -112,7 +112,7 @@ export const Tax: React.FC< TaxProps > = ( { onComplete, query, task } ) => { updateAndPersistSettingsForGroup( 'tax', { tax: { ...taxSettings, - wc_connect_taxes_enabled: 'no', + woo_tax_taxes_enabled: 'no', }, } ); updateAndPersistSettingsForGroup( 'general', { @@ -138,7 +138,7 @@ export const Tax: React.FC< TaxProps > = ( { onComplete, query, task } ) => { updateAndPersistSettingsForGroup( 'tax', { tax: { ...taxSettings, - wc_connect_taxes_enabled: 'yes', + woo_tax_taxes_enabled: 'yes', }, } ), updateAndPersistSettingsForGroup( 'general', { From fea8a05869d550095c21389344446068b7178d9b Mon Sep 17 00:00:00 2001 From: Gerhard Date: Wed, 17 Apr 2024 09:11:46 +0200 Subject: [PATCH 6/7] Add since tag to new functions --- includes/class-wc-calypso-bridge-addons-screen.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/class-wc-calypso-bridge-addons-screen.php b/includes/class-wc-calypso-bridge-addons-screen.php index 2889ef2b..5cd97074 100644 --- a/includes/class-wc-calypso-bridge-addons-screen.php +++ b/includes/class-wc-calypso-bridge-addons-screen.php @@ -110,6 +110,8 @@ public static function output() { /** * Install Woo Tax from Extensions screens. + * + * @since x.x.x */ public static function install_woo_tax_addon() { check_admin_referer( 'install-addon_woocommerce-tax' ); @@ -128,6 +130,8 @@ public static function install_woo_tax_addon() { /** * Install Woo Shipping from Extensions screens. + * + * @since x.x.x */ public static function install_woo_shipping_addon() { check_admin_referer( 'install-addon_woocommerce-shipping' ); From 9792e1d12e6923128f3ea5537b2b75e3806ad751 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Wed, 17 Apr 2024 09:56:57 +0200 Subject: [PATCH 7/7] Update agreement wording for Tax step. --- src/free-trial/tax/woocommerce-tax/plugins.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/free-trial/tax/woocommerce-tax/plugins.tsx b/src/free-trial/tax/woocommerce-tax/plugins.tsx index a8d5b4c0..94f88553 100644 --- a/src/free-trial/tax/woocommerce-tax/plugins.tsx +++ b/src/free-trial/tax/woocommerce-tax/plugins.tsx @@ -57,9 +57,9 @@ export const Plugins: React.FC< SetupStepProps > = ( { nextStep(); }, [ isResolving ] ); - const agreementText = pluginsToActivate.includes( 'woocommerce-services' ) + const agreementText = pluginsToActivate.includes( 'woocommerce-tax' ) ? __( - 'By installing Jetpack and WooCommerce Tax you agree to the {{link}}Terms of Service{{/link}}.', + 'By installing Woo Tax you agree to the {{link}}Terms of Service{{/link}}.', 'woocommerce' ) : __(