From fd4a4a5604de63d835fb2bd71cc2cdf388042ab8 Mon Sep 17 00:00:00 2001
From: Ilyas Foo
Date: Thu, 31 Mar 2022 12:23:26 +0800
Subject: [PATCH 01/25] Add is_offline flag and split payment sections
---
packages/js/data/src/plugins/types.ts | 1 +
.../fills/PaymentGatewaySuggestions/index.js | 24 +++++++++++++++----
.../PaymentGatewaySuggestions/test/index.js | 2 ++
.../DefaultPaymentGateways.php | 2 ++
4 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/packages/js/data/src/plugins/types.ts b/packages/js/data/src/plugins/types.ts
index 0988f81972a..54a0299ba39 100644
--- a/packages/js/data/src/plugins/types.ts
+++ b/packages/js/data/src/plugins/types.ts
@@ -39,6 +39,7 @@ export type Plugin = {
recommendation_priority?: number;
is_visible?: boolean;
is_local_partner?: boolean;
+ is_offline?: boolean;
};
type PaypalOnboardingState = 'unknown' | 'start' | 'progressive' | 'onboarded';
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
index a908df8304f..a74092fb4a5 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
@@ -179,7 +179,7 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
return gateway;
}, [ isResolving, query, paymentGateways ] );
- const [ wcPayGateway, enabledGateways, additionalGateways ] = useMemo(
+ const [ wcPayGateway, enabledGateways, offlineGateways, additionalGateways ] = useMemo(
() =>
Array.from( paymentGateways.values() )
.sort( ( a, b ) => {
@@ -196,7 +196,7 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
} )
.reduce(
( all, gateway ) => {
- const [ wcPay, enabled, additional ] = all;
+ const [ wcPay, enabled, offline, additional ] = all;
// WCPay is handled separately when not installed and configured
if (
@@ -207,13 +207,15 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
wcPay.push( gateway );
} else if ( gateway.enabled ) {
enabled.push( gateway );
+ } else if ( gateway.is_offline ) {
+ offline.push( gateway );
} else {
additional.push( gateway );
}
return all;
},
- [ [], [], [] ]
+ [ [], [], [], [] ]
),
[ paymentGateways ]
);
@@ -250,14 +252,26 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
{ !! additionalGateways.length && (
) }
+
+ { !! offlineGateways.length && (
+
+ ) }
);
};
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/test/index.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/test/index.js
index eae438fe47b..386dd514510 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/test/index.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/test/index.js
@@ -49,6 +49,7 @@ const paymentGatewaySuggestions = [
image:
'http://localhost:8888/wp-content/plugins/woocommerce-admin/images/onboarding/cod.svg',
is_visible: true,
+ is_offline: true,
},
{
id: 'bacs',
@@ -57,6 +58,7 @@ const paymentGatewaySuggestions = [
image:
'http://localhost:8888/wp-content/plugins/woocommerce-admin/images/onboarding/bacs.svg',
is_visible: true,
+ is_offline: true,
},
{
id: 'woocommerce_payments:non-us',
diff --git a/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php b/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php
index 1b1a76e74e2..64ef1e33512 100644
--- a/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php
+++ b/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php
@@ -198,6 +198,7 @@ class DefaultPaymentGateways {
'is_visible' => array(
self::get_rules_for_cbd( false ),
),
+ 'is_offline' => true,
),
array(
'id' => 'bacs',
@@ -207,6 +208,7 @@ class DefaultPaymentGateways {
'is_visible' => array(
self::get_rules_for_cbd( false ),
),
+ 'is_offline' => true,
),
array(
'id' => 'woocommerce_payments',
From fb89df5f2c1594f2810986a9587da308e334a354 Mon Sep 17 00:00:00 2001
From: Ilyas Foo
Date: Thu, 31 Mar 2022 12:26:22 +0800
Subject: [PATCH 02/25] Rename set up button to get started
---
.../fills/PaymentGatewaySuggestions/components/Action.js | 2 +-
.../PaymentGatewaySuggestions/components/List/test/list.js | 4 ++--
.../PaymentGatewaySuggestions/components/Setup/Configure.js | 2 +-
.../components/Setup/test/configure.js | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Action.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Action.js
index e16ff3644b1..90c0486ecbc 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Action.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Action.js
@@ -24,7 +24,7 @@ export const Action = ( {
markConfigured,
onSetUp = () => {},
onSetupCallback,
- setupButtonText = __( 'Set up', 'woocommerce' ),
+ setupButtonText = __( 'Get started', 'woocommerce-admin' ),
} ) => {
const [ isBusy, setIsBusy ] = useState( false );
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/test/list.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/test/list.js
index 8e7d4caca25..6bd6e4e07e0 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/test/list.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/test/list.js
@@ -49,7 +49,7 @@ describe( 'PaymentGatewaySuggestions > List', () => {
expect( queryByRole( 'button' ) ).toHaveTextContent( 'Enable' );
} );
- it( 'should display the "Set up" button when setup is required', () => {
+ it( 'should display the "Get started" button when setup is required', () => {
const props = {
...defaultProps,
paymentGateways: [
@@ -63,7 +63,7 @@ describe( 'PaymentGatewaySuggestions > List', () => {
const { queryByRole } = render(
);
- expect( queryByRole( 'button' ) ).toHaveTextContent( 'Set up' );
+ expect( queryByRole( 'button' ) ).toHaveTextContent( 'Get started' );
} );
it( 'should display the SetupRequired component when appropriate', () => {
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/Configure.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/Configure.js
index 528d62f63a3..5b5e45b5f92 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/Configure.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/Configure.js
@@ -156,7 +156,7 @@ export const Configure = ( { markConfigured, paymentGateway } ) => {
) }
>
);
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/test/configure.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/test/configure.js
index daacf3cc803..81d63b0930e 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/test/configure.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Setup/test/configure.js
@@ -81,7 +81,7 @@ describe( 'Configure', () => {
const { container } = render( );
const button = container.querySelector( 'a' );
- expect( button.textContent ).toBe( 'Set up' );
+ expect( button.textContent ).toBe( 'Get started' );
expect( button.href ).toBe( mockGateway.settingsUrl );
} );
} );
From a3bd1e5109d7fc95a57883ce3334c7eb7bbb0ad2 Mon Sep 17 00:00:00 2001
From: Ilyas Foo
Date: Thu, 31 Mar 2022 13:57:38 +0800
Subject: [PATCH 03/25] Add see more button
---
.../components/List/List.js | 8 ++++++-
.../fills/PaymentGatewaySuggestions/index.js | 24 +++++++++++++++++--
.../payment-gateway-suggestions.scss | 9 +++++++
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js
index 9375f94938a..924ae456415 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
-import { Card, CardHeader } from '@wordpress/components';
+import { Card, CardHeader, CardFooter } from '@wordpress/components';
/**
* Internal dependencies
@@ -15,6 +15,7 @@ export const List = ( {
markConfigured,
recommendation,
paymentGateways,
+ footerLink,
} ) => {
return (
@@ -30,6 +31,11 @@ export const List = ( {
/>
);
} ) }
+ { footerLink ? (
+ { footerLink }
+ ) : (
+ ''
+ ) }
);
};
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
index a74092fb4a5..1d2f5160e71 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
@@ -13,6 +13,8 @@ import { useMemo, useCallback, useEffect } from '@wordpress/element';
import { registerPlugin } from '@wordpress/plugins';
import { WooOnboardingTask } from '@woocommerce/onboarding';
import { getNewPath } from '@woocommerce/navigation';
+import { Button } from '@wordpress/components';
+import ExternalIcon from 'gridicons/dist/external';
/**
* Internal dependencies
@@ -24,6 +26,9 @@ import { getPluginSlug } from '~/utils';
import './plugins/Bacs';
import './payment-gateway-suggestions.scss';
+const SEE_MORE_LINK =
+ 'https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_source=payments_recommendations';
+
const comparePaymentGatewaysByPriority = ( a, b ) =>
a.recommendation_priority - b.recommendation_priority;
@@ -179,7 +184,12 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
return gateway;
}, [ isResolving, query, paymentGateways ] );
- const [ wcPayGateway, enabledGateways, offlineGateways, additionalGateways ] = useMemo(
+ const [
+ wcPayGateway,
+ enabledGateways,
+ offlineGateways,
+ additionalGateways,
+ ] = useMemo(
() =>
Array.from( paymentGateways.values() )
.sort( ( a, b ) => {
@@ -258,7 +268,17 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
recommendation={ recommendation }
paymentGateways={ additionalGateways }
markConfigured={ markConfigured }
- />
+ footerLink={
+
+ }
+ >
) }
{ !! offlineGateways.length && (
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/payment-gateway-suggestions.scss b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/payment-gateway-suggestions.scss
index 0716dc3d3fa..8e408b15e20 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/payment-gateway-suggestions.scss
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/payment-gateway-suggestions.scss
@@ -22,6 +22,15 @@
margin: 0;
}
+
+ .components-card__footer {
+ a.components-button {
+ .gridicon {
+ margin-left: 4px;
+ }
+ }
+ }
+
.woocommerce-task-payment__recommended-pill {
border: 1px solid $studio-gray-5;
border-radius: 28px;
From 0f554436da200fce975928e2ebfed714ddb80d1b Mon Sep 17 00:00:00 2001
From: Ilyas Foo
Date: Mon, 4 Apr 2022 18:12:20 +0800
Subject: [PATCH 04/25] Broke wcpay task to different sections, added toggle
component, added other payment methods toggle
---
.../components/List/List.js | 2 +-
.../components/Toggle/Toggle.js | 41 +++++++
.../components/Toggle/Toggle.scss | 9 ++
.../components/Toggle/index.js | 1 +
.../fills/PaymentGatewaySuggestions/index.js | 100 ++++++++++--------
5 files changed, 108 insertions(+), 45 deletions(-)
create mode 100644 plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js
create mode 100644 plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.scss
create mode 100644 plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/index.js
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js
index 924ae456415..d9442b284f7 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/List/List.js
@@ -19,7 +19,7 @@ export const List = ( {
} ) => {
return (
- { heading }
+ { heading ? { heading } : null }
{ paymentGateways.map( ( paymentGateway ) => {
const { id } = paymentGateway;
return (
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js
new file mode 100644
index 00000000000..d87e6fa6ff9
--- /dev/null
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js
@@ -0,0 +1,41 @@
+/**
+ * External dependencies
+ */
+import { Button } from '@wordpress/components';
+import ChevronUpIcon from 'gridicons/dist/chevron-up';
+import ChevronDownIcon from 'gridicons/dist/chevron-down';
+import { useState } from '@wordpress/element';
+
+/**
+ * Internal dependencies
+ */
+import './Toggle.scss';
+
+export const Toggle = ( { children, heading } ) => {
+ const [ isOpen, setIsOpen ] = useState( false );
+ const onToggle = () => {
+ setIsOpen( ! isOpen );
+ };
+
+ return (
+
+
+ { isOpen ? children : null }
+
+ );
+};
+
+// export default Toggle;
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.scss b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.scss
new file mode 100644
index 00000000000..b1605309872
--- /dev/null
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.scss
@@ -0,0 +1,9 @@
+.woocommerce-task-payments {
+ .toggle-button {
+ margin: $gap-small 0;
+
+ .gridicon {
+ margin-left: 4px;
+ }
+ }
+}
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/index.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/index.js
new file mode 100644
index 00000000000..87fdc434811
--- /dev/null
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/index.js
@@ -0,0 +1 @@
+export { Toggle } from './Toggle';
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
index 1d2f5160e71..99d9f2effea 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
@@ -21,6 +21,7 @@ import ExternalIcon from 'gridicons/dist/external';
*/
import { List, Placeholder as ListPlaceholder } from './components/List';
import { Setup, Placeholder as SetupPlaceholder } from './components/Setup';
+import { Toggle } from './components/Toggle/Toggle';
import { WCPaySuggestion } from './components/WCPay';
import { getPluginSlug } from '~/utils';
import './plugins/Bacs';
@@ -230,6 +231,8 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
[ paymentGateways ]
);
+ const isEligibleWCPay = !! wcPayGateway.length;
+
if ( query.id && ! currentGateway ) {
return ;
}
@@ -243,54 +246,63 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
);
}
+ const enabledSection = !! enabledGateways.length && (
+
+ );
+
+ const additionalSection = !! additionalGateways.length && (
+
+ { __( 'See more', 'woocommerce' ) }
+
+
+ }
+ >
+ );
+
+ const offlineSection = !! offlineGateways.length && (
+
+ );
+
return (
{ ! paymentGateways.size && }
- { !! wcPayGateway.length && (
-
- ) }
-
- { !! enabledGateways.length && (
-
- ) }
-
- { !! additionalGateways.length && (
-
- { __( 'See more', 'woocommerce-admin' ) }
-
-
- }
- >
- ) }
-
- { !! offlineGateways.length && (
-
+ { isEligibleWCPay ? (
+ <>
+
+
+ { enabledSection }
+ { additionalSection }
+ { offlineSection }
+
+ >
+ ) : (
+ <>
+ { enabledSection }
+ { additionalSection }
+ { offlineSection }
+ >
) }
);
From 5ff23bf10331accfefb98a9910eb065ec3c8ab65 Mon Sep 17 00:00:00 2001
From: Ilyas Foo
Date: Mon, 4 Apr 2022 18:38:07 +0800
Subject: [PATCH 05/25] Add tracks and small refactor to toggle
---
.../components/Toggle/Toggle.js | 17 +++++++++--------
.../fills/PaymentGatewaySuggestions/index.js | 18 +++++++++++++++++-
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js
index d87e6fa6ff9..d096360b166 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/components/Toggle/Toggle.js
@@ -11,29 +11,30 @@ import { useState } from '@wordpress/element';
*/
import './Toggle.scss';
-export const Toggle = ( { children, heading } ) => {
- const [ isOpen, setIsOpen ] = useState( false );
- const onToggle = () => {
- setIsOpen( ! isOpen );
+export const Toggle = ( { children, heading, onToggle } ) => {
+ const [ isShow, setIsShow ] = useState( false );
+ const onClick = () => {
+ onToggle( isShow );
+ setIsShow( ! isShow );
};
return (
- { isOpen ? children : null }
+ { isShow ? children : null }
);
};
diff --git a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
index 99d9f2effea..99d4df681a6 100644
--- a/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
+++ b/plugins/woocommerce-admin/client/tasks/fills/PaymentGatewaySuggestions/index.js
@@ -161,6 +161,16 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
[ paymentGateways ]
);
+ const trackSeeMore = () => {
+ recordEvent( 'tasklist_payment_see_more', {} );
+ };
+
+ const trackToggle = ( isShow ) => {
+ recordEvent( 'tasklist_payment_show_toggle', {
+ toggle: isShow ? 'hide' : 'show',
+ } );
+ };
+
const recommendation = useMemo(
() =>
Array.from( paymentGateways.values() )
@@ -265,7 +275,12 @@ export const PaymentGatewaySuggestions = ( { onComplete, query } ) => {
paymentGateways={ additionalGateways }
markConfigured={ markConfigured }
footerLink={
-