2019-06-12 03:56:10 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2020-01-06 15:16:38 +00:00
|
|
|
import { __, _n, _x, sprintf } from '@wordpress/i18n';
|
2019-06-12 03:56:10 +00:00
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
|
|
|
import { compose } from '@wordpress/compose';
|
2019-12-02 17:39:22 +00:00
|
|
|
import { Button, FormToggle } from '@wordpress/components';
|
2019-06-12 03:56:10 +00:00
|
|
|
import { withDispatch } from '@wordpress/data';
|
2019-11-05 00:05:20 +00:00
|
|
|
import { keys, get, pickBy } from 'lodash';
|
2019-06-12 03:56:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce dependencies
|
|
|
|
*/
|
2019-12-03 23:13:42 +00:00
|
|
|
import { formatValue } from 'lib/number-format';
|
2020-02-14 02:23:21 +00:00
|
|
|
import {
|
|
|
|
getSetting,
|
|
|
|
CURRENCY as currency,
|
|
|
|
} from '@woocommerce/wc-admin-settings';
|
2019-06-12 03:56:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-03-06 19:20:54 +00:00
|
|
|
import {
|
|
|
|
H,
|
|
|
|
Card,
|
|
|
|
SelectControl,
|
|
|
|
Form,
|
|
|
|
TextControl,
|
|
|
|
} from '@woocommerce/components';
|
2019-06-12 03:56:10 +00:00
|
|
|
import withSelect from 'wc-api/with-select';
|
2019-07-01 18:13:29 +00:00
|
|
|
import { recordEvent } from 'lib/tracks';
|
2019-12-03 23:32:13 +00:00
|
|
|
import { formatCurrency } from 'lib/currency-format';
|
2019-10-23 15:17:38 +00:00
|
|
|
import Plugins from 'dashboard/task-list/tasks/steps/plugins';
|
|
|
|
import { pluginNames } from 'wc-api/onboarding/constants';
|
2019-12-10 19:01:21 +00:00
|
|
|
import { getCurrencyRegion } from 'dashboard/utils';
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2019-09-23 21:47:08 +00:00
|
|
|
const wcAdminAssetUrl = getSetting( 'wcAdminAssetUrl', '' );
|
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
class BusinessDetails extends Component {
|
2019-11-05 00:05:20 +00:00
|
|
|
constructor( props ) {
|
2019-06-12 03:56:10 +00:00
|
|
|
super();
|
2019-11-05 00:05:20 +00:00
|
|
|
const profileItems = get( props, 'profileItems', {} );
|
2020-02-14 02:23:21 +00:00
|
|
|
const businessExtensions = get(
|
|
|
|
profileItems,
|
|
|
|
'business_extensions',
|
|
|
|
false
|
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
this.initialValues = {
|
2019-11-05 00:05:20 +00:00
|
|
|
other_platform: profileItems.other_platform || '',
|
2020-03-06 19:20:54 +00:00
|
|
|
other_platform_name: profileItems.other_platform_name || '',
|
2019-11-05 00:05:20 +00:00
|
|
|
product_count: profileItems.product_count || '',
|
|
|
|
selling_venues: profileItems.selling_venues || '',
|
|
|
|
revenue: profileItems.revenue || '',
|
|
|
|
'facebook-for-woocommerce': businessExtensions
|
|
|
|
? businessExtensions.includes( 'facebook-for-woocommerce' )
|
|
|
|
: true,
|
|
|
|
'mailchimp-for-woocommerce': businessExtensions
|
|
|
|
? businessExtensions.includes( 'mailchimp-for-woocommerce' )
|
|
|
|
: true,
|
2019-06-12 03:56:10 +00:00
|
|
|
};
|
|
|
|
|
2019-10-23 15:17:38 +00:00
|
|
|
this.state = {
|
|
|
|
installExtensions: false,
|
|
|
|
isInstallingExtensions: false,
|
|
|
|
extensionInstallError: false,
|
|
|
|
};
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
this.extensions = [
|
|
|
|
'facebook-for-woocommerce',
|
|
|
|
'mailchimp-for-woocommerce',
|
|
|
|
];
|
2019-08-08 05:25:55 +00:00
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
this.onContinue = this.onContinue.bind( this );
|
2019-08-08 05:25:55 +00:00
|
|
|
this.validate = this.validate.bind( this );
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
async onContinue( values ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
const {
|
|
|
|
createNotice,
|
|
|
|
goToNextStep,
|
|
|
|
isError,
|
|
|
|
updateProfileItems,
|
|
|
|
} = this.props;
|
|
|
|
const {
|
|
|
|
other_platform: otherPlatform,
|
2020-03-06 19:20:54 +00:00
|
|
|
other_platform_name: otherPlatformName,
|
2020-02-14 02:23:21 +00:00
|
|
|
product_count: productCount,
|
|
|
|
revenue,
|
|
|
|
selling_venues: sellingVenues,
|
|
|
|
} = values;
|
2019-08-08 05:25:55 +00:00
|
|
|
const businessExtensions = this.getBusinessExtensions( values );
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2019-07-01 18:13:29 +00:00
|
|
|
recordEvent( 'storeprofiler_store_business_details_continue', {
|
2020-02-14 02:23:21 +00:00
|
|
|
product_number: productCount,
|
|
|
|
already_selling: sellingVenues !== 'no',
|
2019-09-23 21:47:08 +00:00
|
|
|
currency: currency.code,
|
2019-08-08 15:38:47 +00:00
|
|
|
revenue,
|
2020-02-14 02:23:21 +00:00
|
|
|
used_platform: otherPlatform,
|
2020-03-06 19:20:54 +00:00
|
|
|
used_platform_name: otherPlatformName,
|
2019-10-23 15:17:38 +00:00
|
|
|
install_facebook: values[ 'facebook-for-woocommerce' ],
|
|
|
|
install_mailchimp: values[ 'mailchimp-for-woocommerce' ],
|
2019-07-01 18:13:29 +00:00
|
|
|
} );
|
|
|
|
|
2019-08-08 15:38:47 +00:00
|
|
|
const _updates = {
|
2020-02-14 02:23:21 +00:00
|
|
|
other_platform: otherPlatform,
|
2020-03-06 19:20:54 +00:00
|
|
|
other_platform_name:
|
|
|
|
otherPlatform === 'other' ? otherPlatformName : '',
|
2020-02-14 02:23:21 +00:00
|
|
|
product_count: productCount,
|
2019-08-08 15:38:47 +00:00
|
|
|
revenue,
|
2020-02-14 02:23:21 +00:00
|
|
|
selling_venues: sellingVenues,
|
2019-07-15 11:09:31 +00:00
|
|
|
business_extensions: businessExtensions,
|
2019-08-08 15:38:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Remove possible empty values like `revenue` and `other_platform`.
|
|
|
|
const updates = {};
|
2020-02-14 02:23:21 +00:00
|
|
|
Object.keys( _updates ).forEach( ( key ) => {
|
2019-08-08 15:38:47 +00:00
|
|
|
if ( _updates[ key ] !== '' ) {
|
|
|
|
updates[ key ] = _updates[ key ];
|
|
|
|
}
|
2019-07-04 15:56:28 +00:00
|
|
|
} );
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2019-08-08 15:38:47 +00:00
|
|
|
await updateProfileItems( updates );
|
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
if ( ! isError ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
if ( businessExtensions.length === 0 ) {
|
2019-10-23 15:17:38 +00:00
|
|
|
goToNextStep();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState( {
|
|
|
|
installExtensions: true,
|
|
|
|
isInstallingExtensions: true,
|
|
|
|
} );
|
2019-06-12 03:56:10 +00:00
|
|
|
} else {
|
2019-07-23 03:26:46 +00:00
|
|
|
createNotice(
|
|
|
|
'error',
|
2020-02-14 02:23:21 +00:00
|
|
|
__(
|
|
|
|
'There was a problem updating your business details.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
)
|
2019-07-23 03:26:46 +00:00
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
validate( values ) {
|
|
|
|
const errors = {};
|
|
|
|
|
2020-03-06 19:20:54 +00:00
|
|
|
Object.keys( values ).forEach( ( name ) => {
|
2020-02-14 02:23:21 +00:00
|
|
|
if ( name === 'other_platform' ) {
|
2019-08-08 05:25:55 +00:00
|
|
|
if (
|
|
|
|
! values.other_platform.length &&
|
2020-02-14 02:23:21 +00:00
|
|
|
[ 'other', 'brick-mortar-other' ].includes(
|
|
|
|
values.selling_venues
|
|
|
|
)
|
2019-08-08 05:25:55 +00:00
|
|
|
) {
|
2020-02-14 02:23:21 +00:00
|
|
|
errors.other_platform = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
2019-08-08 05:25:55 +00:00
|
|
|
}
|
2020-03-06 19:20:54 +00:00
|
|
|
} else if ( name === 'other_platform_name' ) {
|
|
|
|
if (
|
|
|
|
! values.other_platform_name &&
|
|
|
|
values.other_platform === 'other'
|
|
|
|
) {
|
|
|
|
errors.other_platform_name = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
|
|
|
}
|
2020-02-14 02:23:21 +00:00
|
|
|
} else if ( name === 'revenue' ) {
|
2019-08-08 15:38:47 +00:00
|
|
|
if (
|
|
|
|
! values.revenue.length &&
|
2020-02-14 02:23:21 +00:00
|
|
|
[
|
|
|
|
'other',
|
|
|
|
'brick-mortar',
|
|
|
|
'brick-mortar-other',
|
|
|
|
'other-woocommerce',
|
|
|
|
].includes( values.selling_venues )
|
2019-08-08 15:38:47 +00:00
|
|
|
) {
|
2020-02-14 02:23:21 +00:00
|
|
|
errors.revenue = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
2019-08-08 15:38:47 +00:00
|
|
|
}
|
2020-02-14 02:23:21 +00:00
|
|
|
} else if (
|
|
|
|
! this.extensions.includes( name ) &&
|
|
|
|
! values[ name ].length
|
|
|
|
) {
|
|
|
|
errors[ name ] = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
2019-08-08 05:25:55 +00:00
|
|
|
}
|
|
|
|
} );
|
2019-07-15 11:09:31 +00:00
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
return errors;
|
2019-07-15 11:09:31 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
getBusinessExtensions( values ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
return keys( pickBy( values ) ).filter( ( name ) =>
|
|
|
|
this.extensions.includes( name )
|
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 19:01:21 +00:00
|
|
|
convertCurrency( value ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
const region = getCurrencyRegion(
|
|
|
|
this.props.settings.woocommerce_default_country
|
|
|
|
);
|
|
|
|
if ( region === 'US' ) {
|
2019-12-10 19:01:21 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// These are rough exchange rates from USD. Precision is not paramount.
|
|
|
|
// The keys here should match the keys in `getCurrencyData`.
|
|
|
|
const exchangeRates = {
|
|
|
|
US: 1,
|
|
|
|
EU: 0.9,
|
|
|
|
IN: 71.24,
|
|
|
|
GB: 0.76,
|
|
|
|
BR: 4.19,
|
|
|
|
VN: 23172.5,
|
|
|
|
ID: 14031.0,
|
|
|
|
BD: 84.87,
|
|
|
|
PK: 154.8,
|
|
|
|
RU: 63.74,
|
|
|
|
TR: 5.75,
|
|
|
|
MX: 19.37,
|
|
|
|
CA: 1.32,
|
|
|
|
};
|
|
|
|
|
|
|
|
const exchangeRate = exchangeRates[ region ] || exchangeRates.US;
|
|
|
|
const digits = exchangeRate.toString().split( '.' )[ 0 ].length;
|
|
|
|
const multiplier = Math.pow( 10, 2 + digits );
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
return Math.round( ( value * exchangeRate ) / multiplier ) * multiplier;
|
2019-12-10 19:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
numberFormat( value ) {
|
|
|
|
return formatValue( 'number', value );
|
|
|
|
}
|
|
|
|
|
|
|
|
getNumberRangeString( min, max = false, format = this.numberFormat ) {
|
2019-06-12 03:56:10 +00:00
|
|
|
if ( ! max ) {
|
2019-10-21 00:48:30 +00:00
|
|
|
return sprintf(
|
2020-02-14 02:23:21 +00:00
|
|
|
_x(
|
|
|
|
'%s+',
|
|
|
|
'store product count or revenue',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-12-10 19:01:21 +00:00
|
|
|
format( min )
|
2019-10-21 00:48:30 +00:00
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return sprintf(
|
2020-02-14 02:23:21 +00:00
|
|
|
_x(
|
|
|
|
'%1$s - %2$s',
|
|
|
|
'store product count or revenue range',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-12-10 19:01:21 +00:00
|
|
|
format( min ),
|
|
|
|
format( max )
|
2019-06-12 03:56:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
renderBusinessExtensionHelpText( values ) {
|
2019-10-23 15:17:38 +00:00
|
|
|
const { isInstallingExtensions } = this.state;
|
2019-08-08 05:25:55 +00:00
|
|
|
const extensions = this.getBusinessExtensions( values );
|
2019-07-04 15:56:28 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
if ( extensions.length === 0 ) {
|
2019-07-04 15:56:28 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-10-23 15:17:38 +00:00
|
|
|
const extensionsList = extensions
|
2020-02-14 02:23:21 +00:00
|
|
|
.map( ( extension ) => {
|
2019-10-23 15:17:38 +00:00
|
|
|
return pluginNames[ extension ];
|
|
|
|
} )
|
|
|
|
.join( ', ' );
|
|
|
|
|
|
|
|
if ( isInstallingExtensions ) {
|
2020-01-06 15:16:38 +00:00
|
|
|
return (
|
|
|
|
<p>
|
|
|
|
{ sprintf(
|
|
|
|
_n(
|
|
|
|
'Installing the following plugin: %s',
|
|
|
|
'Installing the following plugins: %s',
|
|
|
|
extensions.length,
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
extensionsList
|
|
|
|
) }
|
|
|
|
</p>
|
|
|
|
);
|
2019-10-23 15:17:38 +00:00
|
|
|
}
|
|
|
|
|
2019-07-04 15:56:28 +00:00
|
|
|
return (
|
|
|
|
<p>
|
2020-01-06 15:16:38 +00:00
|
|
|
{ sprintf(
|
|
|
|
_n(
|
|
|
|
'The following plugin will be installed for free: %s',
|
|
|
|
'The following plugins will be installed for free: %s',
|
|
|
|
extensions.length,
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
extensionsList
|
|
|
|
) }
|
2019-07-04 15:56:28 +00:00
|
|
|
</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
renderBusinessExtensions( values, getInputProps ) {
|
2019-10-23 15:17:38 +00:00
|
|
|
const { installExtensions } = this.state;
|
|
|
|
const { goToNextStep } = this.props;
|
|
|
|
const extensionsToInstall = this.getBusinessExtensions( values );
|
2019-07-04 15:56:28 +00:00
|
|
|
const extensionBenefits = [
|
|
|
|
{
|
2019-10-23 15:17:38 +00:00
|
|
|
slug: 'facebook-for-woocommerce',
|
2019-07-04 15:56:28 +00:00
|
|
|
title: __( 'Market on Facebook', 'woocommerce-admin' ),
|
|
|
|
icon: 'onboarding/facebook.png',
|
|
|
|
description: __(
|
|
|
|
'Grow your business by targeting the right people and driving sales with Facebook.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
2019-10-23 15:17:38 +00:00
|
|
|
slug: 'mailchimp-for-woocommerce',
|
2020-02-14 02:23:21 +00:00
|
|
|
title: __(
|
|
|
|
'Contact customers with Mailchimp',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-07-04 15:56:28 +00:00
|
|
|
icon: 'onboarding/mailchimp.png',
|
|
|
|
description: __(
|
|
|
|
'Send targeted campaigns, recover abandoned carts and much more with Mailchimp.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
];
|
2019-08-08 05:25:55 +00:00
|
|
|
|
2019-07-04 15:56:28 +00:00
|
|
|
return (
|
2019-10-23 15:17:38 +00:00
|
|
|
<Fragment>
|
|
|
|
<div className="woocommerce-profile-wizard__benefits">
|
2020-02-14 02:23:21 +00:00
|
|
|
{ extensionBenefits.map( ( benefit ) => (
|
|
|
|
<div
|
|
|
|
className="woocommerce-profile-wizard__benefit"
|
|
|
|
key={ benefit.title }
|
|
|
|
>
|
2019-10-23 15:17:38 +00:00
|
|
|
<div className="woocommerce-profile-wizard__business-extension">
|
2020-02-14 02:23:21 +00:00
|
|
|
<img
|
|
|
|
src={ wcAdminAssetUrl + benefit.icon }
|
|
|
|
alt=""
|
|
|
|
/>
|
2019-10-23 15:17:38 +00:00
|
|
|
</div>
|
|
|
|
<div className="woocommerce-profile-wizard__benefit-content">
|
2020-02-14 02:23:21 +00:00
|
|
|
<H className="woocommerce-profile-wizard__benefit-title">
|
|
|
|
{ benefit.title }
|
|
|
|
</H>
|
2019-10-23 15:17:38 +00:00
|
|
|
<p>{ benefit.description }</p>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-profile-wizard__benefit-toggle">
|
|
|
|
<FormToggle
|
|
|
|
checked={ values[ benefit.slug ] }
|
|
|
|
{ ...getInputProps( benefit.slug ) }
|
|
|
|
/>
|
|
|
|
</div>
|
2019-07-04 15:56:28 +00:00
|
|
|
</div>
|
2019-10-23 15:17:38 +00:00
|
|
|
) ) }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{ installExtensions && (
|
2020-01-23 07:11:40 +00:00
|
|
|
<div className="woocommerce-profile-wizard__card-actions">
|
|
|
|
<Plugins
|
|
|
|
onComplete={ () => {
|
|
|
|
goToNextStep();
|
|
|
|
} }
|
|
|
|
onSkip={ () => {
|
|
|
|
goToNextStep();
|
|
|
|
} }
|
|
|
|
onError={ () => {
|
|
|
|
this.setState( {
|
|
|
|
extensionInstallError: true,
|
|
|
|
isInstallingExtensions: false,
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
autoInstall
|
|
|
|
pluginSlugs={ extensionsToInstall }
|
|
|
|
/>
|
|
|
|
</div>
|
2019-10-23 15:17:38 +00:00
|
|
|
) }
|
|
|
|
</Fragment>
|
2019-07-04 15:56:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
render() {
|
2019-10-23 15:17:38 +00:00
|
|
|
const { isInstallingExtensions, extensionInstallError } = this.state;
|
2019-06-12 03:56:10 +00:00
|
|
|
const productCountOptions = [
|
2019-10-23 23:33:10 +00:00
|
|
|
{
|
|
|
|
key: '0',
|
2020-02-14 02:23:21 +00:00
|
|
|
label: __(
|
|
|
|
"I don't have any products yet.",
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-10-23 23:33:10 +00:00
|
|
|
},
|
2019-06-12 03:56:10 +00:00
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: '1-10',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: this.getNumberRangeString( 1, 10 ),
|
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: '11-100',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: this.getNumberRangeString( 11, 100 ),
|
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: '101-1000',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: this.getNumberRangeString( 101, 1000 ),
|
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: '1000+',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: this.getNumberRangeString( 1000 ),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2019-08-08 15:38:47 +00:00
|
|
|
const revenueOptions = [
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'none',
|
2019-12-03 23:32:13 +00:00
|
|
|
label: sprintf(
|
|
|
|
/* translators: %s: $0 revenue amount */
|
|
|
|
__( "%s (I'm just getting started)", 'woocommerce-admin' ),
|
|
|
|
formatCurrency( 0 )
|
|
|
|
),
|
2019-08-08 15:38:47 +00:00
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'up-to-2500',
|
2019-12-03 23:32:13 +00:00
|
|
|
label: sprintf(
|
|
|
|
/* translators: %s: A given revenue amount, e.g., $2500 */
|
|
|
|
__( 'Up to %s', 'woocommerce-admin' ),
|
2019-12-10 19:01:21 +00:00
|
|
|
formatCurrency( this.convertCurrency( 2500 ) )
|
2019-12-03 23:32:13 +00:00
|
|
|
),
|
2019-08-08 15:38:47 +00:00
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: '2500-10000',
|
2019-12-10 19:01:21 +00:00
|
|
|
label: this.getNumberRangeString(
|
|
|
|
this.convertCurrency( 2500 ),
|
|
|
|
this.convertCurrency( 10000 ),
|
|
|
|
formatCurrency
|
|
|
|
),
|
2019-08-08 15:38:47 +00:00
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: '10000-50000',
|
2019-12-10 19:01:21 +00:00
|
|
|
label: this.getNumberRangeString(
|
|
|
|
this.convertCurrency( 10000 ),
|
|
|
|
this.convertCurrency( 50000 ),
|
|
|
|
formatCurrency
|
|
|
|
),
|
2019-08-08 15:38:47 +00:00
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: '50000-250000',
|
2019-12-10 19:01:21 +00:00
|
|
|
label: this.getNumberRangeString(
|
|
|
|
this.convertCurrency( 50000 ),
|
|
|
|
this.convertCurrency( 250000 ),
|
|
|
|
formatCurrency
|
|
|
|
),
|
2019-08-08 15:38:47 +00:00
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'more-than-250000',
|
2019-12-03 23:32:13 +00:00
|
|
|
label: sprintf(
|
|
|
|
/* translators: %s: A given revenue amount, e.g., $250000 */
|
|
|
|
__( 'More than %s', 'woocommerce-admin' ),
|
2019-12-10 19:01:21 +00:00
|
|
|
formatCurrency( this.convertCurrency( 250000 ) )
|
2019-08-08 15:38:47 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
const sellingVenueOptions = [
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'no',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __( 'No', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'other',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __( 'Yes, on another platform', 'woocommerce-admin' ),
|
|
|
|
},
|
2019-12-27 16:30:59 +00:00
|
|
|
{
|
|
|
|
key: 'other-woocommerce',
|
2020-02-14 02:23:21 +00:00
|
|
|
label: __(
|
|
|
|
'Yes, I own a different store powered by WooCommerce',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-12-27 16:30:59 +00:00
|
|
|
},
|
2019-06-12 03:56:10 +00:00
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'brick-mortar',
|
2020-02-14 02:23:21 +00:00
|
|
|
label: __(
|
|
|
|
'Yes, in person at physical stores and/or events',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-06-12 03:56:10 +00:00
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'brick-mortar-other',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __(
|
2019-08-08 18:41:26 +00:00
|
|
|
'Yes, on another platform and in person at physical stores and/or events',
|
2019-06-12 03:56:10 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const otherPlatformOptions = [
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'shopify',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __( 'Shopify', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'bigcommerce',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __( 'BigCommerce', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'magento',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __( 'Magento', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'wix',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __( 'Wix', 'woocommerce-admin' ),
|
|
|
|
},
|
2020-03-06 19:20:54 +00:00
|
|
|
{
|
|
|
|
key: 'amazon',
|
|
|
|
label: __( 'Amazon', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'ebay',
|
|
|
|
label: __( 'eBay', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'etsy',
|
|
|
|
label: __( 'Etsy', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'squarespace',
|
|
|
|
label: __( 'Squarespace', 'woocommerce-admin' ),
|
|
|
|
},
|
2019-06-12 03:56:10 +00:00
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'other',
|
2019-06-12 03:56:10 +00:00
|
|
|
label: __( 'Other', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
2019-08-08 05:25:55 +00:00
|
|
|
<Form
|
|
|
|
initialValues={ this.initialValues }
|
|
|
|
onSubmitCallback={ this.onContinue }
|
|
|
|
validate={ this.validate }
|
|
|
|
>
|
2019-10-04 13:46:27 +00:00
|
|
|
{ ( { getInputProps, handleSubmit, values, isValidForm } ) => {
|
2019-08-08 05:25:55 +00:00
|
|
|
// Show extensions when the currently selling elsewhere checkbox has been answered.
|
2020-02-14 02:23:21 +00:00
|
|
|
const showExtensions = values.selling_venues !== '';
|
2019-08-08 05:25:55 +00:00
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<H className="woocommerce-profile-wizard__header-title">
|
2020-02-14 02:23:21 +00:00
|
|
|
{ __(
|
|
|
|
'Tell us about your business',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
</H>
|
2019-08-08 18:41:26 +00:00
|
|
|
<p>
|
|
|
|
{ __(
|
|
|
|
"We'd love to know if you are just getting started or you already have a business in place.",
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
|
|
|
</p>
|
2019-08-08 05:25:55 +00:00
|
|
|
<Card>
|
|
|
|
<Fragment>
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2020-02-14 02:23:21 +00:00
|
|
|
label={ __(
|
2020-03-06 19:20:54 +00:00
|
|
|
'How many products do you plan to display?',
|
2020-02-14 02:23:21 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
options={ productCountOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'product_count' ) }
|
|
|
|
/>
|
|
|
|
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2020-02-14 02:23:21 +00:00
|
|
|
label={ __(
|
|
|
|
'Currently selling elsewhere?',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
options={ sellingVenueOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'selling_venues' ) }
|
|
|
|
/>
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
{ [
|
|
|
|
'other',
|
|
|
|
'brick-mortar',
|
|
|
|
'brick-mortar-other',
|
|
|
|
'other-woocommerce',
|
|
|
|
].includes( values.selling_venues ) && (
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2020-02-14 02:23:21 +00:00
|
|
|
label={ __(
|
|
|
|
"What's your current annual revenue?",
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-08-08 15:38:47 +00:00
|
|
|
options={ revenueOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'revenue' ) }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
{ [
|
|
|
|
'other',
|
|
|
|
'brick-mortar-other',
|
|
|
|
].includes( values.selling_venues ) && (
|
2020-03-06 19:20:54 +00:00
|
|
|
<Fragment>
|
|
|
|
<SelectControl
|
|
|
|
label={ __(
|
|
|
|
'Which platform is the store using?',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
|
|
|
options={ otherPlatformOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps(
|
|
|
|
'other_platform'
|
|
|
|
) }
|
|
|
|
/>
|
|
|
|
{ values.other_platform ===
|
|
|
|
'other' && (
|
|
|
|
<TextControl
|
|
|
|
label={ __(
|
|
|
|
'What is the platform name?',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
|
|
|
required
|
|
|
|
{ ...getInputProps(
|
|
|
|
'other_platform_name'
|
|
|
|
) }
|
|
|
|
/>
|
2020-02-14 02:23:21 +00:00
|
|
|
) }
|
2020-03-06 19:20:54 +00:00
|
|
|
</Fragment>
|
2019-08-08 05:25:55 +00:00
|
|
|
) }
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
{ showExtensions &&
|
|
|
|
this.renderBusinessExtensions(
|
|
|
|
values,
|
|
|
|
getInputProps
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
|
2019-10-23 15:17:38 +00:00
|
|
|
{ ! extensionInstallError && (
|
|
|
|
<Button
|
|
|
|
isPrimary
|
|
|
|
className="woocommerce-profile-wizard__continue"
|
|
|
|
onClick={ handleSubmit }
|
|
|
|
disabled={ ! isValidForm }
|
|
|
|
isBusy={ isInstallingExtensions }
|
|
|
|
>
|
2020-02-14 02:23:21 +00:00
|
|
|
{ __(
|
|
|
|
'Continue',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-10-23 15:17:38 +00:00
|
|
|
</Button>
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
</Fragment>
|
|
|
|
</Card>
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
{ showExtensions &&
|
|
|
|
this.renderBusinessExtensionHelpText( values ) }
|
2019-08-08 05:25:55 +00:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
} }
|
|
|
|
</Form>
|
2019-06-12 03:56:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
2020-02-14 02:23:21 +00:00
|
|
|
withSelect( ( select ) => {
|
|
|
|
const { getProfileItems, getProfileItemsError, getSettings } = select(
|
|
|
|
'wc-api'
|
|
|
|
);
|
2019-12-10 19:01:21 +00:00
|
|
|
|
|
|
|
const settings = getSettings( 'general' );
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2019-11-05 00:05:20 +00:00
|
|
|
return {
|
|
|
|
isError: Boolean( getProfileItemsError() ),
|
|
|
|
profileItems: getProfileItems(),
|
2019-12-10 19:01:21 +00:00
|
|
|
settings,
|
2019-11-05 00:05:20 +00:00
|
|
|
};
|
2019-06-12 03:56:10 +00:00
|
|
|
} ),
|
2020-02-14 02:23:21 +00:00
|
|
|
withDispatch( ( dispatch ) => {
|
2019-07-23 03:26:46 +00:00
|
|
|
const { updateProfileItems } = dispatch( 'wc-api' );
|
|
|
|
const { createNotice } = dispatch( 'core/notices' );
|
2019-06-12 03:56:10 +00:00
|
|
|
|
|
|
|
return {
|
2019-07-23 03:26:46 +00:00
|
|
|
createNotice,
|
2019-06-12 03:56:10 +00:00
|
|
|
updateProfileItems,
|
|
|
|
};
|
|
|
|
} )
|
|
|
|
)( BusinessDetails );
|