2019-06-12 03:56:10 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
|
|
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';
|
2019-09-23 21:47:08 +00:00
|
|
|
import { getSetting, CURRENCY as currency } from '@woocommerce/wc-admin-settings';
|
2019-06-12 03:56:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2019-10-07 22:42:32 +00:00
|
|
|
import { H, Card, SelectControl, Form } 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', {} );
|
|
|
|
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 || '',
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
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 ) {
|
2019-07-23 03:26:46 +00:00
|
|
|
const { createNotice, goToNextStep, isError, updateProfileItems } = this.props;
|
2019-10-23 15:17:38 +00:00
|
|
|
const { other_platform, product_count, revenue, selling_venues } = 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', {
|
|
|
|
product_number: product_count,
|
|
|
|
already_selling: 'no' !== selling_venues,
|
2019-09-23 21:47:08 +00:00
|
|
|
currency: currency.code,
|
2019-08-08 15:38:47 +00:00
|
|
|
revenue,
|
2019-07-01 18:13:29 +00:00
|
|
|
used_platform: other_platform,
|
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 = {
|
2019-07-04 15:56:28 +00:00
|
|
|
other_platform,
|
|
|
|
product_count,
|
2019-08-08 15:38:47 +00:00
|
|
|
revenue,
|
2019-07-04 15:56:28 +00:00
|
|
|
selling_venues,
|
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 = {};
|
|
|
|
Object.keys( _updates ).forEach( key => {
|
|
|
|
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 ) {
|
2019-10-23 15:17:38 +00:00
|
|
|
if ( 0 === businessExtensions.length ) {
|
|
|
|
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',
|
|
|
|
__( 'There was a problem updating your business details.', 'woocommerce-admin' )
|
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
validate( values ) {
|
|
|
|
const errors = {};
|
|
|
|
|
|
|
|
Object.keys( values ).map( name => {
|
|
|
|
if ( 'other_platform' === name ) {
|
|
|
|
if (
|
|
|
|
! values.other_platform.length &&
|
|
|
|
[ 'other', 'brick-mortar-other' ].includes( values.selling_venues )
|
|
|
|
) {
|
|
|
|
errors.other_platform = __( 'This field is required', 'woocommerce-admin' );
|
|
|
|
}
|
2019-08-08 15:38:47 +00:00
|
|
|
} else if ( 'revenue' === name ) {
|
|
|
|
if (
|
|
|
|
! values.revenue.length &&
|
2019-12-27 16:30:59 +00:00
|
|
|
[ 'other', 'brick-mortar', 'brick-mortar-other', 'other-woocommerce' ].includes(
|
|
|
|
values.selling_venues
|
|
|
|
)
|
2019-08-08 15:38:47 +00:00
|
|
|
) {
|
|
|
|
errors.revenue = __( 'This field is required', 'woocommerce-admin' );
|
|
|
|
}
|
2019-08-08 05:25:55 +00:00
|
|
|
} else if ( ! this.extensions.includes( name ) && ! values[ name ].length ) {
|
|
|
|
errors[ name ] = __( 'This field is required', 'woocommerce-admin' );
|
|
|
|
}
|
|
|
|
} );
|
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 ) {
|
|
|
|
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 ) {
|
|
|
|
const region = getCurrencyRegion( this.props.settings.woocommerce_default_country );
|
|
|
|
if ( 'US' === region ) {
|
|
|
|
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 );
|
|
|
|
|
|
|
|
return Math.round( value * exchangeRate / multiplier ) * multiplier;
|
|
|
|
}
|
|
|
|
|
|
|
|
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(
|
|
|
|
_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(
|
2019-10-21 00:48:30 +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
|
|
|
|
|
|
|
if ( 0 === extensions.length ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-10-23 15:17:38 +00:00
|
|
|
const extensionsList = extensions
|
|
|
|
.map( extension => {
|
|
|
|
return pluginNames[ extension ];
|
|
|
|
} )
|
|
|
|
.join( ', ' );
|
|
|
|
|
|
|
|
if ( isInstallingExtensions ) {
|
|
|
|
return <p>{ sprintf( __( 'Installing the following plugins: %s' ), extensionsList ) }</p>;
|
|
|
|
}
|
|
|
|
|
2019-07-04 15:56:28 +00:00
|
|
|
return (
|
|
|
|
<p>
|
2019-10-23 15:17:38 +00:00
|
|
|
{ sprintf( __( 'The following plugins will be installed for free: %s' ), 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',
|
2019-07-04 15:56:28 +00:00
|
|
|
title: __( 'Contact customers with Mailchimp', 'woocommerce-admin' ),
|
|
|
|
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">
|
|
|
|
{ extensionBenefits.map( benefit => (
|
|
|
|
<div className="woocommerce-profile-wizard__benefit" key={ benefit.title }>
|
|
|
|
<div className="woocommerce-profile-wizard__business-extension">
|
|
|
|
<img src={ wcAdminAssetUrl + benefit.icon } alt="" />
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-profile-wizard__benefit-content">
|
|
|
|
<H className="woocommerce-profile-wizard__benefit-title">{ benefit.title }</H>
|
|
|
|
<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 && (
|
|
|
|
<Plugins
|
|
|
|
onComplete={ () => {
|
|
|
|
goToNextStep();
|
|
|
|
} }
|
|
|
|
onSkip={ () => {
|
|
|
|
goToNextStep();
|
|
|
|
} }
|
|
|
|
onError={ () => {
|
|
|
|
this.setState( {
|
|
|
|
extensionInstallError: true,
|
|
|
|
isInstallingExtensions: false,
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
autoInstall
|
|
|
|
pluginSlugs={ extensionsToInstall }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
</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',
|
|
|
|
label: __( "I don't have any products yet.", 'woocommerce-admin' ),
|
|
|
|
},
|
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',
|
|
|
|
label: __( 'Yes, I own a different store powered by WooCommerce', 'woocommerce-admin' ),
|
|
|
|
},
|
2019-06-12 03:56:10 +00:00
|
|
|
{
|
2019-10-07 22:42:32 +00:00
|
|
|
key: 'brick-mortar',
|
2019-08-08 18:41:26 +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' ),
|
|
|
|
},
|
|
|
|
{
|
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.
|
|
|
|
const showExtensions = '' !== values.selling_venues;
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<H className="woocommerce-profile-wizard__header-title">
|
2019-08-08 18:41:26 +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
|
2019-10-29 18:15:36 +00:00
|
|
|
label={ __( 'How many products do you plan to sell?', '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
|
2019-08-08 05:25:55 +00:00
|
|
|
label={ __( 'Currently selling elsewhere?', 'woocommerce-admin' ) }
|
|
|
|
options={ sellingVenueOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'selling_venues' ) }
|
|
|
|
/>
|
|
|
|
|
2019-12-27 16:30:59 +00:00
|
|
|
{ [ 'other', 'brick-mortar', 'brick-mortar-other', 'other-woocommerce' ].includes(
|
2019-08-08 15:38:47 +00:00
|
|
|
values.selling_venues
|
|
|
|
) && (
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2019-08-08 15:38:47 +00:00
|
|
|
label={ __( "What's your current annual revenue?", 'woocommerce-admin' ) }
|
|
|
|
options={ revenueOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'revenue' ) }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
{ [ 'other', 'brick-mortar-other' ].includes( values.selling_venues ) && (
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2019-08-08 05:25:55 +00:00
|
|
|
label={ __( 'Which platform is the store using?', 'woocommerce-admin' ) }
|
|
|
|
options={ otherPlatformOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'other_platform' ) }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
|
|
|
|
{ showExtensions && this.renderBusinessExtensions( values, getInputProps ) }
|
|
|
|
|
2019-10-23 15:17:38 +00:00
|
|
|
{ ! extensionInstallError && (
|
|
|
|
<Button
|
|
|
|
isPrimary
|
|
|
|
className="woocommerce-profile-wizard__continue"
|
|
|
|
onClick={ handleSubmit }
|
|
|
|
disabled={ ! isValidForm }
|
|
|
|
isBusy={ isInstallingExtensions }
|
|
|
|
>
|
|
|
|
{ __( 'Continue', 'woocommerce-admin' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
</Fragment>
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
{ showExtensions && this.renderBusinessExtensionHelpText( values ) }
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
} }
|
|
|
|
</Form>
|
2019-06-12 03:56:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withSelect( select => {
|
2019-12-10 19:01:21 +00:00
|
|
|
const { getProfileItems, getProfileItemsError, getSettings } = select( 'wc-api' );
|
|
|
|
|
|
|
|
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
|
|
|
} ),
|
|
|
|
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 );
|