Skip to content

Commit 75c9245

Browse files
wjrosadaledupreez
andauthored
Fix OC promotional inbox note CTA (#4512)
* Fix OC promotional banner CTA * Scrolling down to OC setting * Renaming OC component * Changelog and readme entries * Fix tests * Fix changelog and readme entries * Adding headingRef as a useEffect dependency * Making the activate now link constant private * Making the class final * Update client/settings/advanced-settings-section/optimized-checkout-feature.js Co-authored-by: daledupreez <[email protected]> * Change highlight query param name * Update changelog.txt Co-authored-by: daledupreez <[email protected]> * Readme entry update * Fix tests --------- Co-authored-by: daledupreez <[email protected]>
1 parent 37917fc commit 75c9245

File tree

7 files changed

+34
-16
lines changed

7 files changed

+34
-16
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.8.0 - xxxx-xx-xx =
4+
* Fix - Update the Optimized Checkout promotional inbox note to link to the relevant section in the Stripe settings page
45
* Add - Makes the Optimized Checkout feature available for all merchants by default
56
* Add - Adds a new bulk action option to the subscriptions listing screen to check for detached payment methods
67
* Dev - Use product type constants that were added in WooCommerce 9.7

client/settings/advanced-settings-section/__tests__/single-payment-element-feature.test.js renamed to client/settings/advanced-settings-section/__tests__/optimized-checkout-feature.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { render, screen } from '@testing-library/react';
22
import React, { useContext } from 'react';
33
import userEvent from '@testing-library/user-event';
4-
import SinglePaymentElementFeature from 'wcstripe/settings/advanced-settings-section/single-payment-element-feature';
4+
import OptimizedCheckoutFeature from 'wcstripe/settings/advanced-settings-section/optimized-checkout-feature';
55
import UpeToggleContext from 'wcstripe/settings/upe-toggle/context';
66

77
jest.useFakeTimers();
88

99
describe( 'Single Payment Element feature setting', () => {
1010
it( 'should render', () => {
11-
render( <SinglePaymentElementFeature /> );
11+
render( <OptimizedCheckoutFeature /> );
1212

1313
expect(
1414
screen.queryByText(
@@ -29,7 +29,7 @@ describe( 'Single Payment Element feature setting', () => {
2929
render(
3030
<div>
3131
<UpdateUpeDisabledFlagMock />
32-
<SinglePaymentElementFeature />
32+
<OptimizedCheckoutFeature />
3333
</div>
3434
);
3535

client/settings/advanced-settings-section/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SettingsSection from '../settings-section';
66
import CardBody from '../card-body';
77
import DebugMode from './debug-mode';
88
import LoadableSettingsSection from 'wcstripe/settings/loadable-settings-section';
9-
import SinglePaymentElementFeature from 'wcstripe/settings/advanced-settings-section/single-payment-element-feature';
9+
import OptimizedCheckoutFeature from 'wcstripe/settings/advanced-settings-section/optimized-checkout-feature';
1010

1111
const AdvancedSettingsDescription = () => (
1212
<>
@@ -28,7 +28,7 @@ const AdvancedSettings = () => {
2828
<Card>
2929
<CardBody>
3030
<DebugMode />
31-
{ isOcAvailable && <SinglePaymentElementFeature /> }
31+
{ isOcAvailable && <OptimizedCheckoutFeature /> }
3232
</CardBody>
3333
</Card>
3434
</LoadableSettingsSection>

client/settings/advanced-settings-section/single-payment-element-feature.js renamed to client/settings/advanced-settings-section/optimized-checkout-feature.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {
55
ExternalLink,
66
TextControl,
77
} from '@wordpress/components';
8-
import React, { useEffect, useState } from 'react';
8+
import React, { useEffect, useRef, useState } from 'react';
9+
import { getQuery } from '@woocommerce/navigation';
910
import { useIsOCEnabled, useIsUpeEnabled, useOCTitle } from '../../data';
1011

11-
const SinglePaymentElementFeature = () => {
12+
const OptimizedCheckoutFeature = () => {
1213
const [ isOCEnabled, setIsOCEnabled ] = useIsOCEnabled();
1314
const [ OCTitle, setOCTitle ] = useOCTitle();
1415
const [ isUpeEnabled ] = useIsUpeEnabled();
16+
const headingRef = useRef( null );
1517

1618
useEffect( () => {
1719
if ( ! isUpeEnabled ) {
@@ -27,6 +29,20 @@ const SinglePaymentElementFeature = () => {
2729
setLocalOCTitle( OCTitle );
2830
}, [ OCTitle ] );
2931

32+
useEffect( () => {
33+
if ( ! headingRef.current ) {
34+
return;
35+
}
36+
37+
const { highlight } = getQuery();
38+
if ( highlight === 'enable-optimized-checkout' ) {
39+
headingRef.current.scrollIntoView( {
40+
behavior: 'smooth',
41+
block: 'start',
42+
} );
43+
}
44+
}, [ headingRef ] );
45+
3046
const handleTitleChange = ( value ) => {
3147
setLocalOCTitle( value );
3248
};
@@ -45,7 +61,7 @@ const SinglePaymentElementFeature = () => {
4561

4662
return (
4763
<>
48-
<h4>
64+
<h4 ref={ headingRef }>
4965
{ __(
5066
'Enable Optimized Checkout Suite (recommended)',
5167
'woocommerce-gateway-stripe'
@@ -89,4 +105,4 @@ const SinglePaymentElementFeature = () => {
89105
);
90106
};
91107

92-
export default SinglePaymentElementFeature;
108+
export default OptimizedCheckoutFeature;

includes/notes/class-wc-stripe-oc-promotion-note.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Class WC_Stripe_OC_Promotion_Note
1616
*/
17-
class WC_Stripe_OC_Promotion_Note {
17+
final class WC_Stripe_OC_Promotion_Note {
1818
use NoteTraits;
1919

2020
/**
@@ -23,9 +23,9 @@ class WC_Stripe_OC_Promotion_Note {
2323
const NOTE_NAME = 'wc-stripe-oc-promotion-note';
2424

2525
/**
26-
* Link to learn more about OC.
26+
* Link to activate OC in store.
2727
*/
28-
const LEARN_MORE_LINK = 'https://woocommerce.com/document/stripe/admin-experience/optimized-checkout-suite/';
28+
private const ACTIVATE_NOW_LINK = '?page=wc-settings&tab=checkout&section=stripe&panel=settings&highlight=enable-optimized-checkout';
2929

3030
/**
3131
* Get the note.
@@ -41,8 +41,8 @@ public static function get_note() {
4141
$note->set_source( 'woocommerce-gateway-stripe' );
4242
$note->add_action(
4343
self::NOTE_NAME,
44-
__( 'Learn more', 'woocommerce-gateway-stripe' ),
45-
self::LEARN_MORE_LINK,
44+
__( 'Activate now', 'woocommerce-gateway-stripe' ),
45+
self::ACTIVATE_NOW_LINK,
4646
$note_class::E_WC_ADMIN_NOTE_UNACTIONED,
4747
true
4848
);

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.8.0 - xxxx-xx-xx =
114+
* Fix - Update the Optimized Checkout promotional inbox note to link to the relevant section in the Stripe settings page
114115
* Add - Makes the Optimized Checkout feature available for all merchants by default
115116
* Add - Adds a new bulk action option to the subscriptions listing screen to check for detached payment methods
116117
* Dev - Use product type constants that were added in WooCommerce 9.7

tests/phpunit/Notes/WC_Stripe_OC_Promotion_Note_Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function test_get_note() {
2525

2626
list( $learn_more_action ) = $note->get_actions();
2727
$this->assertSame( 'wc-stripe-oc-promotion-note', $learn_more_action->name );
28-
$this->assertSame( 'Learn more', $learn_more_action->label );
29-
$this->assertSame( 'https://woocommerce.com/document/stripe/admin-experience/optimized-checkout-suite/', $learn_more_action->query );
28+
$this->assertSame( 'Activate now', $learn_more_action->label );
29+
$this->assertSame( '?page=wc-settings&tab=checkout&section=stripe&panel=settings&highlight=enable-optimized-checkout', $learn_more_action->query );
3030
}
3131
}

0 commit comments

Comments
 (0)