Onboarding: Use ShipStation for AU, GB, and CA (https://github.com/woocommerce/woocommerce-admin/pull/3200)

* Add shipstation to allowed plugins list

* Use shipstation for qualifying countries

* Add default value for onError prop in Plugins component
This commit is contained in:
Joshua T Flowers 2019-11-12 10:44:39 +08:00 committed by GitHub
parent 642b17c1aa
commit 4fb1945917
5 changed files with 46 additions and 18 deletions

View File

@ -7,12 +7,13 @@ import apiFetch from '@wordpress/api-fetch';
import { Component } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { filter } from 'lodash';
import interpolateComponents from 'interpolate-components';
import { withDispatch } from '@wordpress/data';
/**
* WooCommerce dependencies
*/
import { Card, Stepper } from '@woocommerce/components';
import { Card, Link, Stepper } from '@woocommerce/components';
import { getHistory, getNewPath } from '@woocommerce/navigation';
import { getSetting } from '@woocommerce/wc-admin-settings';
@ -143,6 +144,9 @@ class Shipping extends Component {
getSteps() {
const { countryCode } = this.props;
const plugins = [ 'GB', 'CA', 'AU' ].includes( countryCode )
? [ 'woocommerce-shipstation-integration' ]
: [ 'jetpack', 'woocommerce-services' ];
const steps = [
{
@ -180,21 +184,39 @@ class Shipping extends Component {
{
key: 'label_printing',
label: __( 'Enable shipping label printing', 'woocommerce-admin' ),
description: __(
'With WooCommerce Services and Jetpack you can save time at the ' +
'Post Office by printing your shipping labels at home',
'woocommerce-admin'
),
description: [ 'GB', 'CA', 'AU' ].includes( countryCode )
? interpolateComponents( {
mixedString: __(
'We recommend using ShipStation to save time at the post office by printing your shipping ' +
'labels at home. Try ShipStation free for 30 days. {{link}}Learn more{{/link}}.',
'woocommerce-admin'
),
components: {
link: (
<Link
href="https://docs.woocommerce.com/document/shipstation-for-woocommerce/"
target="_blank"
type="external"
/>
),
},
} )
: __(
'With WooCommerce Services and Jetpack you can save time at the ' +
'Post Office by printing your shipping labels at home',
'woocommerce-admin'
),
content: (
<Plugins
onComplete={ () => {
recordEvent( 'tasklist_shipping_label_printing', { install: true } );
recordEvent( 'tasklist_shipping_label_printing', { install: true, plugins } );
this.completeStep();
} }
onSkip={ () => {
recordEvent( 'tasklist_shipping_label_printing', { install: false } );
recordEvent( 'tasklist_shipping_label_printing', { install: false, plugins } );
getHistory().push( getNewPath( {}, '/', {} ) );
} }
pluginSlugs={ plugins }
{ ...this.props }
/>
),

View File

@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
import { Button } from 'newspack-components';
import { Component, Fragment } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { difference } from 'lodash';
import { difference, noop } from 'lodash';
import PropTypes from 'prop-types';
import { withDispatch } from '@wordpress/data';
@ -146,6 +146,7 @@ Plugins.propTypes = {
Plugins.defaultProps = {
autoInstall: false,
onError: noop,
pluginSlugs: [ 'jetpack', 'woocommerce-services' ],
};

View File

@ -12,4 +12,8 @@ export const pluginNames = {
'woocommerce-services': __( 'WooCommerce Services', 'woocommerce-admin' ),
'mailchimp-for-woocommerce': __( 'Mailchimp for WooCommerce', 'woocommerce-admin' ),
'facebook-for-woocommerce': __( 'Facebook for WooCommerce', 'woocommerce-admin' ),
'woocommerce-shipstation-integration': __(
'WooCommerce ShipStation Gateway',
'woocommerce-admin'
),
};

View File

@ -109,7 +109,7 @@ Stepper.propTypes = {
/**
* Description displayed beneath the label.
*/
description: PropTypes.string,
description: PropTypes.oneOfType( [ PropTypes.string, PropTypes.array ] ),
/**
* Optionally mark a step complete regardless of step index.
*/

View File

@ -469,15 +469,16 @@ class Onboarding {
return apply_filters(
'woocommerce_onboarding_plugins_whitelist',
array(
'facebook-for-woocommerce' => 'facebook-for-woocommerce/facebook-for-woocommerce.php',
'mailchimp-for-woocommerce' => 'mailchimp-for-woocommerce/mailchimp-woocommerce.php',
'jetpack' => 'jetpack/jetpack.php',
'woocommerce-services' => 'woocommerce-services/woocommerce-services.php',
'woocommerce-gateway-stripe' => 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php',
'facebook-for-woocommerce' => 'facebook-for-woocommerce/facebook-for-woocommerce.php',
'mailchimp-for-woocommerce' => 'mailchimp-for-woocommerce/mailchimp-woocommerce.php',
'jetpack' => 'jetpack/jetpack.php',
'woocommerce-services' => 'woocommerce-services/woocommerce-services.php',
'woocommerce-gateway-stripe' => 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php',
'woocommerce-gateway-paypal-express-checkout' => 'woocommerce-gateway-paypal-express-checkout/woocommerce-gateway-paypal-express-checkout.php',
'klarna-checkout-for-woocommerce' => 'klarna-checkout-for-woocommerce/klarna-checkout-for-woocommerce.php',
'klarna-payments-for-woocommerce' => 'klarna-payments-for-woocommerce/klarna-payments-for-woocommerce.php',
'woocommerce-square' => 'woocommerce-square/woocommerce-square.php',
'klarna-checkout-for-woocommerce' => 'klarna-checkout-for-woocommerce/klarna-checkout-for-woocommerce.php',
'klarna-payments-for-woocommerce' => 'klarna-payments-for-woocommerce/klarna-payments-for-woocommerce.php',
'woocommerce-square' => 'woocommerce-square/woocommerce-square.php',
'woocommerce-shipstation-integration' => 'woocommerce-shipstation-integration/woocommerce-shipstation.php',
)
);
}