Skip to content

Commit ce4cc17

Browse files
wjrosadaledupreez
andauthored
Removing the ability to edit the OC container title (#4559)
* Removing the ability to edit the OC container title * Removing additional references * Fix classic checkout title * Changelog and readme entries * Update changelog.txt Co-authored-by: daledupreez <[email protected]> * Changelog entry update * Removing the translation function calls --------- Co-authored-by: daledupreez <[email protected]>
1 parent 3e3b02a commit ce4cc17

File tree

10 files changed

+7
-85
lines changed

10 files changed

+7
-85
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+
* Update - Removes the ability to change the title for the Optimized Checkout payment element, as it is now set to "Stripe" by default
45
* Update - Copy for the Optimized Checkout settings and notices
56
* Dev - Implements WooCommerce constants for the tax statuses
67
* Add - Adds the current setting value for the Optimized Checkout to the Stripe System Status Report data

client/classic/upe/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,9 @@ jQuery( function ( $ ) {
315315
// Change the payment method container title when the Optimized Checkout is enabled
316316
if (
317317
getStripeServerData()?.isOCEnabled &&
318-
getStripeServerData()?.OCTitle &&
319318
$( 'input#payment_method_stripe' ).is( ':checked' )
320319
) {
321-
$( 'label[for=payment_method_stripe]' ).text(
322-
getStripeServerData()?.OCTitle
323-
);
320+
$( 'label[for=payment_method_stripe]' ).text( 'Stripe' );
324321
}
325322

326323
maybeClearBlikCodeValidation();

client/data/settings/hooks.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ export const useIsShortAccountStatementEnabled = makeSettingsHook(
166166
export const useDebugLog = makeSettingsHook( 'is_debug_log_enabled' );
167167
export const useIsUpeEnabled = makeSettingsHook( 'is_upe_enabled' );
168168
export const useIsOCEnabled = makeSettingsHook( 'is_oc_enabled' );
169-
export const useOCTitle = makeSettingsHook( 'oc_title', 'Stripe' );
170169
export const useIsPMCEnabled = makeReadOnlySettingsHook(
171170
'is_pmc_enabled',
172171
false

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import AdvancedSettings from '..';
55
import {
66
useDebugLog,
77
useIsUpeEnabled,
8-
useOCTitle,
98
useGetSavingError,
109
useSettings,
1110
useIsOCEnabled,
@@ -15,7 +14,6 @@ jest.mock( 'wcstripe/data', () => ( {
1514
useDebugLog: jest.fn(),
1615
useIsUpeEnabled: jest.fn(),
1716
useIsOCEnabled: jest.fn(),
18-
useOCTitle: jest.fn(),
1917
useGetSavingError: jest.fn(),
2018
useSettings: jest.fn(),
2119
} ) );
@@ -27,7 +25,6 @@ describe( 'AdvancedSettings', () => {
2725
useDebugLog.mockReturnValue( [ true, jest.fn() ] );
2826
useIsUpeEnabled.mockReturnValue( [ true, jest.fn() ] );
2927
useIsOCEnabled.mockReturnValue( [ false, jest.fn() ] );
30-
useOCTitle.mockReturnValue( 'Stripe' );
3128
useGetSavingError.mockReturnValue( null );
3229

3330
// Set `isLoading` to false so `LoadableSettingsSection` can render.
@@ -79,19 +76,4 @@ describe( 'AdvancedSettings', () => {
7976
)
8077
).toBeInTheDocument();
8178
} );
82-
83-
it( 'should display the Optimized Checkout title setting if the Optimized Checkout feature is enabled', () => {
84-
global.wc_stripe_settings_params = { is_oc_available: true };
85-
86-
useIsOCEnabled.mockReturnValue( [ true, jest.fn() ] );
87-
88-
render( <AdvancedSettings /> );
89-
90-
expect(
91-
screen.queryByText(
92-
'This will appear as the title of the Optimized Checkout Suite payment element on checkout.'
93-
)
94-
).toBeInTheDocument();
95-
expect( screen.queryByLabelText( 'Title' ) ).toBeInTheDocument();
96-
} );
9779
} );

client/settings/advanced-settings-section/optimized-checkout-feature.js

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import { __ } from '@wordpress/i18n';
22
import { createInterpolateElement } from '@wordpress/element';
3-
import {
4-
CheckboxControl,
5-
ExternalLink,
6-
TextControl,
7-
} from '@wordpress/components';
8-
import React, { useEffect, useRef, useState } from 'react';
3+
import { CheckboxControl, ExternalLink } from '@wordpress/components';
4+
import React, { useEffect, useRef } from 'react';
95
import { getQuery } from '@woocommerce/navigation';
10-
import { useIsOCEnabled, useIsUpeEnabled, useOCTitle } from '../../data';
6+
import { useIsOCEnabled, useIsUpeEnabled } from '../../data';
117

128
const OptimizedCheckoutFeature = () => {
139
const [ isOCEnabled, setIsOCEnabled ] = useIsOCEnabled();
14-
const [ OCTitle, setOCTitle ] = useOCTitle();
1510
const [ isUpeEnabled ] = useIsUpeEnabled();
1611
const headingRef = useRef( null );
1712

@@ -21,14 +16,6 @@ const OptimizedCheckoutFeature = () => {
2116
}
2217
}, [ isUpeEnabled, setIsOCEnabled ] );
2318

24-
// Local state for the title input to prevent value reset during typing
25-
const [ localOCTitle, setLocalOCTitle ] = useState( OCTitle );
26-
27-
// Update local state when store value changes
28-
useEffect( () => {
29-
setLocalOCTitle( OCTitle );
30-
}, [ OCTitle ] );
31-
3219
useEffect( () => {
3320
if ( ! headingRef.current ) {
3421
return;
@@ -43,22 +30,6 @@ const OptimizedCheckoutFeature = () => {
4330
}
4431
}, [ headingRef ] );
4532

46-
const handleTitleChange = ( value ) => {
47-
setLocalOCTitle( value );
48-
};
49-
50-
const handleTitleBlur = () => {
51-
const finalTitle = localOCTitle.trim() || OCTitle;
52-
setOCTitle( finalTitle );
53-
setLocalOCTitle( finalTitle );
54-
};
55-
56-
const handleTitleKeyDown = ( event ) => {
57-
if ( event.key === 'Enter' ) {
58-
handleTitleBlur();
59-
}
60-
};
61-
6233
return (
6334
<>
6435
<h4 ref={ headingRef }>
@@ -88,19 +59,6 @@ const OptimizedCheckoutFeature = () => {
8859
onChange={ setIsOCEnabled }
8960
disabled={ ! isUpeEnabled }
9061
/>
91-
{ isOCEnabled && (
92-
<TextControl
93-
help={ __(
94-
'This will appear as the title of the Optimized Checkout Suite payment element on checkout.',
95-
'woocommerce-gateway-stripe'
96-
) }
97-
label={ __( 'Title', 'woocommerce-gateway-stripe' ) }
98-
value={ localOCTitle }
99-
onChange={ handleTitleChange }
100-
onBlur={ handleTitleBlur }
101-
onKeyDown={ handleTitleKeyDown }
102-
/>
103-
) }
10462
</>
10563
);
10664
};

includes/admin/class-wc-rest-stripe-settings-controller.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ public function register_routes() {
8080
'type' => 'boolean',
8181
'validate_callback' => 'rest_validate_request_arg',
8282
],
83-
'oc_title' => [
84-
'description' => __( 'The default title to show above the Optimized Checkout element.', 'woocommerce-gateway-stripe' ),
85-
'type' => 'string',
86-
'validate_callback' => 'rest_validate_request_arg',
87-
],
8883
'amazon_pay_button_size' => [
8984
'description' => __( 'Express checkout button sizes.', 'woocommerce-gateway-stripe' ),
9085
'type' => 'string',
@@ -247,7 +242,6 @@ public function get_settings() {
247242
'is_debug_log_enabled' => 'yes' === $this->gateway->get_option( 'logging' ),
248243
'is_upe_enabled' => $is_upe_enabled,
249244
'is_oc_enabled' => 'yes' === $this->gateway->get_option( 'optimized_checkout_element' ),
250-
'oc_title' => $this->gateway->get_validated_option( 'optimized_checkout_element_title' ),
251245
'is_pmc_enabled' => 'yes' === $this->gateway->get_option( 'pmc_enabled' ),
252246
]
253247
);
@@ -541,7 +535,6 @@ private function update_payment_request_settings( WP_REST_Request $request ) {
541535
private function update_oc_settings( WP_REST_Request $request ) {
542536
$attributes = [
543537
'is_oc_enabled' => 'optimized_checkout_element',
544-
'oc_title' => 'optimized_checkout_element_title',
545538
];
546539
foreach ( $attributes as $request_key => $attribute ) {
547540
$value = $request->get_param( $request_key );

includes/payment-methods/class-wc-stripe-upe-payment-gateway.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ public function javascript_params() {
516516

517517
// Optimized Checkout feature flag + setting.
518518
$stripe_params['isOCEnabled'] = $this->oc_enabled;
519-
$stripe_params['OCTitle'] = $this->get_option( 'optimized_checkout_element_title', __( 'Stripe', 'woocommerce-gateway-stripe' ) );
520519

521520
// Single Payment Element payment method parent configuration ID
522521
$stripe_params['paymentMethodConfigurationParentId'] = WC_Stripe_Payment_Method_Configurations::get_parent_configuration_id();

includes/payment-methods/class-wc-stripe-upe-payment-method-cc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private function get_optimized_checkout_title( $payment_details = false ) {
166166

167167
// Block checkout and pay for order (checkout) page.
168168
if ( ( has_block( 'woocommerce/checkout' ) || ! empty( $_GET['pay_for_order'] ) ) && ! is_wc_endpoint_url( 'order-received' ) ) { // phpcs:ignore WordPress.Security.NonceVerification
169-
return $this->oc_title;
169+
return 'Stripe';
170170
}
171171

172172
return parent::get_title();

includes/payment-methods/class-wc-stripe-upe-payment-method.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ abstract class WC_Stripe_UPE_Payment_Method extends WC_Payment_Gateway {
119119
*/
120120
protected $oc_enabled;
121121

122-
/**
123-
* The default title for the Optimized Checkout element
124-
*
125-
* @var string
126-
*/
127-
protected $oc_title;
128-
129122
/**
130123
* Create instance of payment method
131124
*/
@@ -140,7 +133,6 @@ public function __construct() {
140133
$this->supports = [ 'products', 'refunds' ];
141134
$this->supports_deferred_intent = true;
142135
$this->oc_enabled = WC_Stripe_Feature_Flags::is_oc_available() && 'yes' === $this->get_option( 'optimized_checkout_element' );
143-
$this->oc_title = $this->get_option( 'optimized_checkout_element_title', __( 'Stripe', 'woocommerce-gateway-stripe' ) );
144136
}
145137

146138
/**

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+
* Update - Removes the ability to change the title for the Optimized Checkout payment element, as it is now set to "Stripe" by default
114115
* Update - Copy for the Optimized Checkout settings and notices
115116
* Dev - Implements WooCommerce constants for the tax statuses
116117
* Add - Adds the current setting value for the Optimized Checkout to the Stripe System Status Report data

0 commit comments

Comments
 (0)