2019-10-11 12:55:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-10-21 03:11:21 +00:00
|
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
import { get } from 'lodash';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WooCommerce dependencies
|
|
|
|
|
*/
|
2019-11-22 17:07:26 +00:00
|
|
|
|
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
|
|
|
|
|
import { updateQueryString } from '@woocommerce/navigation';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Internal dependencies
|
|
|
|
|
*/
|
|
|
|
|
import Appearance from './tasks/appearance';
|
|
|
|
|
import Connect from './tasks/connect';
|
2019-12-31 08:50:45 +00:00
|
|
|
|
import { getProductIdsForCart } from 'dashboard/utils';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
import Products from './tasks/products';
|
|
|
|
|
import Shipping from './tasks/shipping';
|
|
|
|
|
import Tax from './tasks/tax';
|
|
|
|
|
import Payments from './tasks/payments';
|
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
|
export function getAllTasks( {
|
|
|
|
|
profileItems,
|
|
|
|
|
options,
|
|
|
|
|
query,
|
|
|
|
|
toggleCartModal,
|
2020-05-25 00:26:08 +00:00
|
|
|
|
installedPlugins,
|
2020-02-14 02:23:21 +00:00
|
|
|
|
} ) {
|
2019-10-11 12:55:35 +00:00
|
|
|
|
const {
|
|
|
|
|
hasPhysicalProducts,
|
|
|
|
|
hasProducts,
|
2020-01-09 02:05:03 +00:00
|
|
|
|
isAppearanceComplete,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
isTaxComplete,
|
|
|
|
|
shippingZonesCount,
|
|
|
|
|
} = getSetting( 'onboarding', {
|
|
|
|
|
hasPhysicalProducts: false,
|
|
|
|
|
hasProducts: false,
|
2020-01-09 02:05:03 +00:00
|
|
|
|
isAppearanceComplete: false,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
isTaxComplete: false,
|
|
|
|
|
shippingZonesCount: 0,
|
|
|
|
|
} );
|
|
|
|
|
|
2020-05-25 00:26:08 +00:00
|
|
|
|
const productIds = getProductIdsForCart(
|
|
|
|
|
profileItems,
|
|
|
|
|
true,
|
|
|
|
|
installedPlugins
|
|
|
|
|
);
|
|
|
|
|
const remainingProductIds = getProductIdsForCart(
|
|
|
|
|
profileItems,
|
|
|
|
|
false,
|
|
|
|
|
installedPlugins
|
|
|
|
|
);
|
2019-12-31 08:50:45 +00:00
|
|
|
|
|
2019-10-11 12:55:35 +00:00
|
|
|
|
const paymentsCompleted = get(
|
|
|
|
|
options,
|
2019-11-25 16:15:22 +00:00
|
|
|
|
[ 'woocommerce_task_list_payments', 'completed' ],
|
2019-10-11 12:55:35 +00:00
|
|
|
|
false
|
|
|
|
|
);
|
2020-05-04 11:33:11 +00:00
|
|
|
|
const paymentsSkipped = get(
|
|
|
|
|
options,
|
|
|
|
|
[ 'woocommerce_task_list_payments', 'skipped' ],
|
|
|
|
|
false
|
|
|
|
|
);
|
2019-10-11 12:55:35 +00:00
|
|
|
|
|
2019-10-21 03:11:21 +00:00
|
|
|
|
const tasks = [
|
2019-12-31 08:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
key: 'purchase',
|
|
|
|
|
title: __( 'Purchase & install extensions', 'woocommerce-admin' ),
|
|
|
|
|
content: __(
|
|
|
|
|
'Purchase, install, and manage your extensions directly from your dashboard',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
icon: 'extension',
|
|
|
|
|
container: null,
|
2020-02-14 02:23:21 +00:00
|
|
|
|
onClick: () =>
|
|
|
|
|
remainingProductIds.length ? toggleCartModal() : null,
|
2019-12-31 08:50:45 +00:00
|
|
|
|
visible: productIds.length,
|
|
|
|
|
completed: ! remainingProductIds.length,
|
|
|
|
|
},
|
2019-10-11 12:55:35 +00:00
|
|
|
|
{
|
|
|
|
|
key: 'connect',
|
2020-02-14 02:23:21 +00:00
|
|
|
|
title: __(
|
|
|
|
|
'Connect your store to WooCommerce.com',
|
|
|
|
|
'woocommerce-admin'
|
|
|
|
|
),
|
2019-10-11 12:55:35 +00:00
|
|
|
|
content: __(
|
|
|
|
|
'Install and manage your extensions directly from your Dashboard',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
icon: 'extension',
|
|
|
|
|
container: <Connect query={ query } />,
|
2020-02-14 02:23:21 +00:00
|
|
|
|
visible:
|
|
|
|
|
profileItems.items_purchased && ! profileItems.wccom_connected,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
completed: profileItems.wccom_connected,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'products',
|
|
|
|
|
title: __( 'Add your first product', 'woocommerce-admin' ),
|
|
|
|
|
content: __(
|
|
|
|
|
'Add products manually, import from a sheet or migrate from another platform',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
icon: 'add_box',
|
|
|
|
|
container: <Products />,
|
|
|
|
|
completed: hasProducts,
|
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'appearance',
|
|
|
|
|
title: __( 'Personalize your store', 'woocommerce-admin' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
|
content: __(
|
|
|
|
|
'Create a custom homepage and upload your logo',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
2019-10-11 12:55:35 +00:00
|
|
|
|
icon: 'palette',
|
|
|
|
|
container: <Appearance />,
|
2020-01-09 02:05:03 +00:00
|
|
|
|
completed: isAppearanceComplete,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'shipping',
|
|
|
|
|
title: __( 'Set up shipping', 'woocommerce-admin' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
|
content: __(
|
|
|
|
|
'Configure some basic shipping rates to get started',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
2019-10-11 12:55:35 +00:00
|
|
|
|
icon: 'local_shipping',
|
|
|
|
|
container: <Shipping />,
|
|
|
|
|
completed: shippingZonesCount > 0,
|
2019-10-17 14:39:59 +00:00
|
|
|
|
visible:
|
2020-02-14 02:23:21 +00:00
|
|
|
|
( profileItems.product_types &&
|
|
|
|
|
profileItems.product_types.includes( 'physical' ) ) ||
|
2019-10-17 14:39:59 +00:00
|
|
|
|
hasPhysicalProducts,
|
2019-10-11 12:55:35 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'tax',
|
|
|
|
|
title: __( 'Set up tax', 'woocommerce-admin' ),
|
|
|
|
|
content: __(
|
|
|
|
|
'Choose how to configure tax rates - manually or automatically',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
icon: 'account_balance',
|
|
|
|
|
container: <Tax />,
|
|
|
|
|
completed: isTaxComplete,
|
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'payments',
|
|
|
|
|
title: __( 'Set up payments', 'woocommerce-admin' ),
|
|
|
|
|
content: __(
|
|
|
|
|
'Select which payment providers you’d like to use and configure them',
|
|
|
|
|
'wooocommerce-admin'
|
|
|
|
|
),
|
|
|
|
|
icon: 'payment',
|
|
|
|
|
container: <Payments />,
|
2020-05-04 11:33:11 +00:00
|
|
|
|
completed: paymentsCompleted || paymentsSkipped,
|
2019-10-29 18:03:07 +00:00
|
|
|
|
onClick: () => {
|
2020-05-04 11:33:11 +00:00
|
|
|
|
if ( paymentsCompleted || paymentsSkipped ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
|
window.location = getAdminLink(
|
|
|
|
|
'admin.php?page=wc-settings&tab=checkout'
|
|
|
|
|
);
|
2019-10-29 18:03:07 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
updateQueryString( { task: 'payments' } );
|
|
|
|
|
},
|
2019-10-11 12:55:35 +00:00
|
|
|
|
visible: true,
|
|
|
|
|
},
|
|
|
|
|
];
|
2019-10-21 03:11:21 +00:00
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
|
return applyFilters(
|
|
|
|
|
'woocommerce_admin_onboarding_task_list',
|
|
|
|
|
tasks,
|
|
|
|
|
query
|
|
|
|
|
);
|
2019-10-11 12:55:35 +00:00
|
|
|
|
}
|