Improve WC Shipping & Tax logic (https://github.com/woocommerce/woocommerce-admin/pull/6547)
* Improve WC Shipping & Tax logic * Add changelog * Simplify return statement * Add test for filtering selected extensions * Fix broken test
This commit is contained in:
parent
6b3fe5c475
commit
fda300ff4f
|
@ -117,6 +117,35 @@ UPDATE `wp_options` SET `option_value`=UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7
|
||||||
```
|
```
|
||||||
- No note should have been added.
|
- No note should have been added.
|
||||||
|
|
||||||
|
### Improve WC Shipping & Tax logic #6547
|
||||||
|
|
||||||
|
**Scenario 1** - Exclude the WooCommerce Shipping mention if the user is not in the US
|
||||||
|
|
||||||
|
1. Start OBW and enter an address that is not in the US
|
||||||
|
2. Choose "food and drink" from the Industry (this forces Business Details to display "Free features" tab)
|
||||||
|
3. When you get to the "Business Details", click "Free features"
|
||||||
|
4. Expand "Add recommended business features to my site" by clicking the down arrow.
|
||||||
|
5. Confirm that "WooCommerce Shipping" is not listed
|
||||||
|
|
||||||
|
**Scenario 2**- Exclude the WooCommerce Shipping mention if the user is in the US but only selected digital products in the Product Types step
|
||||||
|
|
||||||
|
1. Start OBW and enter an address that is in the US.
|
||||||
|
2. Choose "food and drink" from the Industry (this forces Business Details to display the "Free features" tab)
|
||||||
|
3. Choose "Downloads" from the Product Types step.
|
||||||
|
4. When you get to the Business Details step, expand "Add recommended business features to my site" by clicking the down arrow.
|
||||||
|
5. Confirm that "WooCommerce Shipping" is not listed
|
||||||
|
|
||||||
|
**Scenario 3** - Include WooCommerce Tax if the user is in one of the following countries: US | FR | GB | DE | CA | PL | AU | GR | BE | PT | DK | SE
|
||||||
|
|
||||||
|
1. Start OBW and enter an address that is in one of the following countries
|
||||||
|
|
||||||
|
US | FR | GB | DE | CA | PL | AU | GR | BE | PT | DK | SE
|
||||||
|
|
||||||
|
2. Continue to the Business Details step.
|
||||||
|
3. Expand "Add recommended business features to my site" by clicking the down arrow.
|
||||||
|
4. Confirm that "WooCommerce Tax" is listed.
|
||||||
|
>>>>>>> bbeebaf91 (Add changelog)
|
||||||
|
|
||||||
### Use wc filter to get status tabs for tools category #6525
|
### Use wc filter to get status tabs for tools category #6525
|
||||||
|
|
||||||
1. Register a new tab via the filter.
|
1. Register a new tab via the filter.
|
||||||
|
|
|
@ -36,6 +36,26 @@ import './style.scss';
|
||||||
const BUSINESS_DETAILS_TAB_NAME = 'business-details';
|
const BUSINESS_DETAILS_TAB_NAME = 'business-details';
|
||||||
const FREE_FEATURES_TAB_NAME = 'free-features';
|
const FREE_FEATURES_TAB_NAME = 'free-features';
|
||||||
|
|
||||||
|
export const filterBusinessExtensions = ( extensionInstallationOptions ) => {
|
||||||
|
return (
|
||||||
|
Object.keys( extensionInstallationOptions )
|
||||||
|
.filter(
|
||||||
|
( key ) =>
|
||||||
|
extensionInstallationOptions[ key ] &&
|
||||||
|
key !== 'install_extensions'
|
||||||
|
)
|
||||||
|
.map( ( key ) => {
|
||||||
|
// Remove anything after :
|
||||||
|
// Please refer to selective-extensions-bundle/index.js
|
||||||
|
// installableExtensions variable
|
||||||
|
// this is to allow duplicate slugs (Tax & Shipping for example)
|
||||||
|
return key.split( ':' )[ 0 ];
|
||||||
|
} )
|
||||||
|
// remove duplicate
|
||||||
|
.filter( ( item, index, arr ) => arr.indexOf( item ) === index )
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
class BusinessDetails extends Component {
|
class BusinessDetails extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -69,12 +89,8 @@ class BusinessDetails extends Component {
|
||||||
|
|
||||||
const { getCurrencyConfig } = this.context;
|
const { getCurrencyConfig } = this.context;
|
||||||
|
|
||||||
const businessExtensions = Object.keys(
|
const businessExtensions = filterBusinessExtensions(
|
||||||
extensionInstallationOptions
|
extensionInstallationOptions
|
||||||
).filter(
|
|
||||||
( key ) =>
|
|
||||||
extensionInstallationOptions[ key ] &&
|
|
||||||
key !== 'install_extensions'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
recordEvent( 'storeprofiler_store_business_features_continue', {
|
recordEvent( 'storeprofiler_store_business_features_continue', {
|
||||||
|
@ -88,7 +104,9 @@ class BusinessDetails extends Component {
|
||||||
extensionInstallationOptions
|
extensionInstallationOptions
|
||||||
).every( ( val ) => val ),
|
).every( ( val ) => val ),
|
||||||
install_woocommerce_services:
|
install_woocommerce_services:
|
||||||
extensionInstallationOptions[ 'woocommerce-services' ],
|
extensionInstallationOptions[
|
||||||
|
'woocommerce-services:shipping'
|
||||||
|
] || extensionInstallationOptions[ 'woocommerce-services:tax' ],
|
||||||
install_mailchimp:
|
install_mailchimp:
|
||||||
extensionInstallationOptions[ 'mailchimp-for-woocommerce' ],
|
extensionInstallationOptions[ 'mailchimp-for-woocommerce' ],
|
||||||
install_mailpoet: extensionInstallationOptions.mailpoet,
|
install_mailpoet: extensionInstallationOptions.mailpoet,
|
||||||
|
@ -413,6 +431,7 @@ class BusinessDetails extends Component {
|
||||||
onSubmit={ this.onContinue }
|
onSubmit={ this.onContinue }
|
||||||
country={ country }
|
country={ country }
|
||||||
industry={ profileItems.industry }
|
industry={ profileItems.industry }
|
||||||
|
productTypes={ profileItems.product_types }
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -68,7 +68,7 @@ const installableExtensions = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
slug: 'woocommerce-services',
|
slug: 'woocommerce-services:shipping',
|
||||||
description: generatePluginDescriptionWithLink(
|
description: generatePluginDescriptionWithLink(
|
||||||
__(
|
__(
|
||||||
'Print shipping labels with {{link}}WooCommerce Shipping{{/link}}',
|
'Print shipping labels with {{link}}WooCommerce Shipping{{/link}}',
|
||||||
|
@ -76,6 +76,40 @@ const installableExtensions = [
|
||||||
),
|
),
|
||||||
'shipping'
|
'shipping'
|
||||||
),
|
),
|
||||||
|
isVisible: ( countryCode, industry, productTypes ) => {
|
||||||
|
return (
|
||||||
|
countryCode === 'US' ||
|
||||||
|
( countryCode === 'US' &&
|
||||||
|
productTypes.length === 1 &&
|
||||||
|
productTypes[ 0 ] === 'downloads' )
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
slug: 'woocommerce-services:tax',
|
||||||
|
description: generatePluginDescriptionWithLink(
|
||||||
|
__(
|
||||||
|
'Get automated sales tax with {{link}}WooCommerce Tax{{/link}}',
|
||||||
|
'woocommerce-admin'
|
||||||
|
),
|
||||||
|
'tax'
|
||||||
|
),
|
||||||
|
isVisible: ( countryCode ) => {
|
||||||
|
return [
|
||||||
|
'US',
|
||||||
|
'FR',
|
||||||
|
'GB',
|
||||||
|
'DE',
|
||||||
|
'CA',
|
||||||
|
'PL',
|
||||||
|
'AU',
|
||||||
|
'GR',
|
||||||
|
'BE',
|
||||||
|
'PT',
|
||||||
|
'DK',
|
||||||
|
'SE',
|
||||||
|
].includes( countryCode );
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
slug: 'jetpack',
|
slug: 'jetpack',
|
||||||
|
@ -258,13 +292,15 @@ const BundleExtensionCheckbox = ( { onChange, description, isChecked } ) => {
|
||||||
* @param {Array} plugins list of plugins
|
* @param {Array} plugins list of plugins
|
||||||
* @param {string} country Woo store country
|
* @param {string} country Woo store country
|
||||||
* @param {Array} industry List of selected industries
|
* @param {Array} industry List of selected industries
|
||||||
|
* @param {Array} productTypes List of selected product types
|
||||||
*/
|
*/
|
||||||
const getVisiblePlugins = ( plugins, country, industry ) => {
|
const getVisiblePlugins = ( plugins, country, industry, productTypes ) => {
|
||||||
const countryCode = getCountryCode( country );
|
const countryCode = getCountryCode( country );
|
||||||
|
|
||||||
return plugins.filter(
|
return plugins.filter(
|
||||||
( plugin ) =>
|
( plugin ) =>
|
||||||
! plugin.isVisible || plugin.isVisible( countryCode, industry )
|
! plugin.isVisible ||
|
||||||
|
plugin.isVisible( countryCode, industry, productTypes )
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -273,6 +309,7 @@ export const SelectiveExtensionsBundle = ( {
|
||||||
onSubmit,
|
onSubmit,
|
||||||
country,
|
country,
|
||||||
industry,
|
industry,
|
||||||
|
productTypes,
|
||||||
} ) => {
|
} ) => {
|
||||||
const [ showExtensions, setShowExtensions ] = useState( false );
|
const [ showExtensions, setShowExtensions ] = useState( false );
|
||||||
const [ values, setValues ] = useState( {} );
|
const [ values, setValues ] = useState( {} );
|
||||||
|
@ -283,7 +320,8 @@ export const SelectiveExtensionsBundle = ( {
|
||||||
const plugins = getVisiblePlugins(
|
const plugins = getVisiblePlugins(
|
||||||
curr.plugins,
|
curr.plugins,
|
||||||
country,
|
country,
|
||||||
industry
|
industry,
|
||||||
|
productTypes
|
||||||
).reduce( ( pluginAcc, { slug } ) => {
|
).reduce( ( pluginAcc, { slug } ) => {
|
||||||
return { ...pluginAcc, [ slug ]: true };
|
return { ...pluginAcc, [ slug ]: true };
|
||||||
}, {} );
|
}, {} );
|
||||||
|
@ -370,7 +408,8 @@ export const SelectiveExtensionsBundle = ( {
|
||||||
{ getVisiblePlugins(
|
{ getVisiblePlugins(
|
||||||
plugins,
|
plugins,
|
||||||
country,
|
country,
|
||||||
industry
|
industry,
|
||||||
|
productTypes
|
||||||
).map( ( { description, slug } ) => (
|
).map( ( { description, slug } ) => (
|
||||||
<BundleExtensionCheckbox
|
<BundleExtensionCheckbox
|
||||||
key={ slug }
|
key={ slug }
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
import { filterBusinessExtensions } from '../flows/selective-bundle';
|
||||||
|
|
||||||
|
describe( 'BusinessDetails', () => {
|
||||||
|
test( 'filtering extensions', () => {
|
||||||
|
const extensions = {
|
||||||
|
'creative-mail-by-constant-contact': true,
|
||||||
|
'facebook-for-woocommerce': true,
|
||||||
|
install_extensions: true,
|
||||||
|
jetpack: true,
|
||||||
|
'kliken-marketing-for-google': true,
|
||||||
|
'mailchimp-for-woocommerce': true,
|
||||||
|
'woocommerce-payments': true,
|
||||||
|
'woocommerce-services:shipping': true,
|
||||||
|
'woocommerce-services:tax': true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedExtensions = [
|
||||||
|
'creative-mail-by-constant-contact',
|
||||||
|
'facebook-for-woocommerce',
|
||||||
|
'jetpack',
|
||||||
|
'kliken-marketing-for-google',
|
||||||
|
'mailchimp-for-woocommerce',
|
||||||
|
'woocommerce-payments',
|
||||||
|
'woocommerce-services',
|
||||||
|
];
|
||||||
|
|
||||||
|
const filteredExtensions = filterBusinessExtensions( extensions );
|
||||||
|
|
||||||
|
expect( filteredExtensions ).toEqual( expectedExtensions );
|
||||||
|
} );
|
||||||
|
} );
|
|
@ -48,6 +48,14 @@ export const pluginNames = {
|
||||||
'WooCommerce Shipping & Tax',
|
'WooCommerce Shipping & Tax',
|
||||||
'woocommerce-admin'
|
'woocommerce-admin'
|
||||||
),
|
),
|
||||||
|
'woocommerce-services:shipping': __(
|
||||||
|
'WooCommerce Shipping & Tax',
|
||||||
|
'woocommerce-admin'
|
||||||
|
),
|
||||||
|
'woocommerce-services:tax': __(
|
||||||
|
'WooCommerce Shipping & Tax',
|
||||||
|
'woocommerce-admin'
|
||||||
|
),
|
||||||
'woocommerce-shipstation-integration': __(
|
'woocommerce-shipstation-integration': __(
|
||||||
'WooCommerce ShipStation Gateway',
|
'WooCommerce ShipStation Gateway',
|
||||||
'woocommerce-admin'
|
'woocommerce-admin'
|
||||||
|
|
|
@ -83,6 +83,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
|
||||||
- Fix: Add gross sales column to CSV export #6567
|
- Fix: Add gross sales column to CSV export #6567
|
||||||
- Dev: Add filter to profile wizard steps #6564
|
- Dev: Add filter to profile wizard steps #6564
|
||||||
- Tweak: Adjust targeting store age for the Add First Product note #6554
|
- Tweak: Adjust targeting store age for the Add First Product note #6554
|
||||||
|
- Tweak: Improve WC Shipping & Tax logic #6547
|
||||||
- Dev: Add nav intro modal tests #6518
|
- Dev: Add nav intro modal tests #6518
|
||||||
- Dev: Use wc filter to get status tabs for tools category #6525
|
- Dev: Use wc filter to get status tabs for tools category #6525
|
||||||
- Tweak: Remove mobile activity panel toggle #6539
|
- Tweak: Remove mobile activity panel toggle #6539
|
||||||
|
|
|
@ -75,7 +75,7 @@ export async function unselectAllFeaturesAndContinue(
|
||||||
await waitForElementCount(
|
await waitForElementCount(
|
||||||
page,
|
page,
|
||||||
'.components-checkbox-control__input',
|
'.components-checkbox-control__input',
|
||||||
shouldWCPayBeListed ? 9 : 8
|
shouldWCPayBeListed ? 10 : 7
|
||||||
);
|
);
|
||||||
const wcPayLabel = await getElementByText( 'a', 'WooCommerce Payments' );
|
const wcPayLabel = await getElementByText( 'a', 'WooCommerce Payments' );
|
||||||
if ( shouldWCPayBeListed ) {
|
if ( shouldWCPayBeListed ) {
|
||||||
|
|
Loading…
Reference in New Issue