Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace WCS&T tax onboarding with Woo Tax onboarding. #1462

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions includes/class-wc-calypso-bridge-addons-screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're already aware, but just precaution that background_installer only supports wp.org listed plugins, in case we're releasing this prior making the plugin public.


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;
}
}
3 changes: 2 additions & 1 deletion includes/class-wc-calypso-bridge-plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/free-trial/tax/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the Tax task uses wc_connect_taxes_enabled option to determine its completion status (ref).

In order to support the new option, we'll need to override the default Tax task class, here's ab example of how we did it for Products task: https://github.com/Automattic/wc-calypso-bridge/pull/963/files.

},
} );
updateAndPersistSettingsForGroup( 'general', {
Expand All @@ -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', {
Expand Down
2 changes: 1 addition & 1 deletion src/free-trial/tax/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 2 additions & 19 deletions src/free-trial/tax/woocommerce-tax/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { TaxChildProps } from '../utils';
export const Card: React.FC< TaxChildProps > = () => {
return (
<PartnerCard
name={ __( 'WooCommerce Tax', 'woocommerce' ) }
name={ __( 'Woo Tax', 'woocommerce' ) }
logo={ logo }
description={ __( 'Best for new stores', 'woocommerce' ) }
benefits={ [
Expand All @@ -31,29 +31,12 @@ export const Card: React.FC< TaxChildProps > = () => {
strong: <strong />,
},
} ),
interpolateComponents( {
mixedString: __(
'Powered by {{link}}Jetpack{{/link}}',
'woocommerce'
),
components: {
link: (
<Link
type="external"
href="https://woocommerce.com/products/jetpack/?utm_medium=product"
target="_blank"
>
<></>
</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: {
Expand Down
2 changes: 1 addition & 1 deletion src/free-trial/tax/woocommerce-tax/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: <AutomatedTaxes { ...stepProps } />,
Expand Down
Loading