Add "Keep updated with PayPal" toggle in the new settings UI

This commit is contained in:
Himad M 2025-05-29 13:53:02 -04:00
parent 1df2efd6cd
commit b540db4954
No known key found for this signature in database
GPG key ID: 5FC769E9888A7B98
6 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,28 @@
import { __ } from '@wordpress/i18n';
import { ControlToggleButton } from '../../../../../ReusableComponents/Controls';
import { SettingsHooks } from '../../../../../../data';
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
const KeepUpdated = () => {
const { keepUpdated, setKeepUpdated } = SettingsHooks.useSettings();
return (
<SettingsBlock className="ppcp--pay-now-experience">
<ControlToggleButton
label={ __(
'Keep updated with PayPal',
'woocommerce-paypal-payments'
) }
description={ __(
'Receive updates on PayPal features, promotions, and news.',
'woocommerce-paypal-payments'
) }
onChange={ setKeepUpdated }
value={ keepUpdated }
/>
</SettingsBlock>
);
};
export default KeepUpdated;

View file

@ -5,6 +5,7 @@ import OrderIntent from './Blocks/OrderIntent';
import SavePaymentMethods from './Blocks/SavePaymentMethods'; import SavePaymentMethods from './Blocks/SavePaymentMethods';
import InvoicePrefix from './Blocks/InvoicePrefix'; import InvoicePrefix from './Blocks/InvoicePrefix';
import PayNowExperience from './Blocks/PayNowExperience'; import PayNowExperience from './Blocks/PayNowExperience';
import KeepUpdated from './Blocks/KeepUpdated';
const CommonSettings = ( { ownBradOnly } ) => ( const CommonSettings = ( { ownBradOnly } ) => (
<SettingsCard <SettingsCard
@ -20,6 +21,7 @@ const CommonSettings = ( { ownBradOnly } ) => (
<OrderIntent /> <OrderIntent />
<SavePaymentMethods ownBradOnly={ ownBradOnly } /> <SavePaymentMethods ownBradOnly={ ownBradOnly } />
<PayNowExperience /> <PayNowExperience />
<KeepUpdated />
</SettingsCard> </SettingsCard>
); );

View file

@ -63,6 +63,7 @@ const useHooks = () => {
const [ payNowExperience, setPayNowExperience ] = const [ payNowExperience, setPayNowExperience ] =
usePersistent( 'enablePayNow' ); usePersistent( 'enablePayNow' );
const [ logging, setLogging ] = usePersistent( 'enableLogging' ); const [ logging, setLogging ] = usePersistent( 'enableLogging' );
const [ keepUpdated, setKeepUpdated ] = usePersistent( 'keepUpdated' );
const [ disabledCards, setDisabledCards ] = const [ disabledCards, setDisabledCards ] =
usePersistent( 'disabledCards' ); usePersistent( 'disabledCards' );
@ -82,6 +83,8 @@ const useHooks = () => {
setPayNowExperience, setPayNowExperience,
logging, logging,
setLogging, setLogging,
keepUpdated,
setKeepUpdated,
subtotalAdjustment, subtotalAdjustment,
setSubtotalAdjustment, setSubtotalAdjustment,
brandName, brandName,
@ -126,6 +129,8 @@ export const useSettings = () => {
setPayNowExperience, setPayNowExperience,
logging, logging,
setLogging, setLogging,
keepUpdated,
setKeepUpdated,
subtotalAdjustment, subtotalAdjustment,
setSubtotalAdjustment, setSubtotalAdjustment,
brandName, brandName,
@ -155,6 +160,8 @@ export const useSettings = () => {
setPayNowExperience, setPayNowExperience,
logging, logging,
setLogging, setLogging,
keepUpdated,
setKeepUpdated,
subtotalAdjustment, subtotalAdjustment,
setSubtotalAdjustment, setSubtotalAdjustment,
brandName, brandName,

View file

@ -42,6 +42,7 @@ const defaultPersistent = Object.freeze( {
saveCardDetails: false, // Enable card vaulting saveCardDetails: false, // Enable card vaulting
enablePayNow: false, // Enable Pay Now experience enablePayNow: false, // Enable Pay Now experience
enableLogging: false, // Enable debug logging enableLogging: false, // Enable debug logging
keepUpdated: false, // Enable to receive PayPal-related updates
// String arrays. // String arrays.
disabledCards: [], // Disabled credit card types disabledCards: [], // Disabled credit card types

View file

@ -82,6 +82,7 @@ class SettingsModel extends AbstractDataModel {
'save_card_details' => false, 'save_card_details' => false,
'enable_pay_now' => false, 'enable_pay_now' => false,
'enable_logging' => false, 'enable_logging' => false,
'keep_updated' => true,
// Array of string values. // Array of string values.
'disabled_cards' => array(), 'disabled_cards' => array(),

View file

@ -86,6 +86,10 @@ class SettingsRestEndpoint extends RestEndpoint {
'js_name' => 'enableLogging', 'js_name' => 'enableLogging',
'sanitize' => 'to_boolean', 'sanitize' => 'to_boolean',
), ),
'keep_updated' => array(
'js_name' => 'keepUpdated',
'sanitize' => 'to_boolean',
),
'disabled_cards' => array( 'disabled_cards' => array(
'js_name' => 'disabledCards', 'js_name' => 'disabledCards',
), ),