mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add "Keep updated with PayPal" toggle in the new settings UI
This commit is contained in:
parent
1df2efd6cd
commit
b540db4954
6 changed files with 43 additions and 0 deletions
|
@ -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;
|
|
@ -5,6 +5,7 @@ import OrderIntent from './Blocks/OrderIntent';
|
|||
import SavePaymentMethods from './Blocks/SavePaymentMethods';
|
||||
import InvoicePrefix from './Blocks/InvoicePrefix';
|
||||
import PayNowExperience from './Blocks/PayNowExperience';
|
||||
import KeepUpdated from './Blocks/KeepUpdated';
|
||||
|
||||
const CommonSettings = ( { ownBradOnly } ) => (
|
||||
<SettingsCard
|
||||
|
@ -20,6 +21,7 @@ const CommonSettings = ( { ownBradOnly } ) => (
|
|||
<OrderIntent />
|
||||
<SavePaymentMethods ownBradOnly={ ownBradOnly } />
|
||||
<PayNowExperience />
|
||||
<KeepUpdated />
|
||||
</SettingsCard>
|
||||
);
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ const useHooks = () => {
|
|||
const [ payNowExperience, setPayNowExperience ] =
|
||||
usePersistent( 'enablePayNow' );
|
||||
const [ logging, setLogging ] = usePersistent( 'enableLogging' );
|
||||
const [ keepUpdated, setKeepUpdated ] = usePersistent( 'keepUpdated' );
|
||||
|
||||
const [ disabledCards, setDisabledCards ] =
|
||||
usePersistent( 'disabledCards' );
|
||||
|
@ -82,6 +83,8 @@ const useHooks = () => {
|
|||
setPayNowExperience,
|
||||
logging,
|
||||
setLogging,
|
||||
keepUpdated,
|
||||
setKeepUpdated,
|
||||
subtotalAdjustment,
|
||||
setSubtotalAdjustment,
|
||||
brandName,
|
||||
|
@ -126,6 +129,8 @@ export const useSettings = () => {
|
|||
setPayNowExperience,
|
||||
logging,
|
||||
setLogging,
|
||||
keepUpdated,
|
||||
setKeepUpdated,
|
||||
subtotalAdjustment,
|
||||
setSubtotalAdjustment,
|
||||
brandName,
|
||||
|
@ -155,6 +160,8 @@ export const useSettings = () => {
|
|||
setPayNowExperience,
|
||||
logging,
|
||||
setLogging,
|
||||
keepUpdated,
|
||||
setKeepUpdated,
|
||||
subtotalAdjustment,
|
||||
setSubtotalAdjustment,
|
||||
brandName,
|
||||
|
|
|
@ -42,6 +42,7 @@ const defaultPersistent = Object.freeze( {
|
|||
saveCardDetails: false, // Enable card vaulting
|
||||
enablePayNow: false, // Enable Pay Now experience
|
||||
enableLogging: false, // Enable debug logging
|
||||
keepUpdated: false, // Enable to receive PayPal-related updates
|
||||
|
||||
// String arrays.
|
||||
disabledCards: [], // Disabled credit card types
|
||||
|
|
|
@ -82,6 +82,7 @@ class SettingsModel extends AbstractDataModel {
|
|||
'save_card_details' => false,
|
||||
'enable_pay_now' => false,
|
||||
'enable_logging' => false,
|
||||
'keep_updated' => true,
|
||||
|
||||
// Array of string values.
|
||||
'disabled_cards' => array(),
|
||||
|
|
|
@ -86,6 +86,10 @@ class SettingsRestEndpoint extends RestEndpoint {
|
|||
'js_name' => 'enableLogging',
|
||||
'sanitize' => 'to_boolean',
|
||||
),
|
||||
'keep_updated' => array(
|
||||
'js_name' => 'keepUpdated',
|
||||
'sanitize' => 'to_boolean',
|
||||
),
|
||||
'disabled_cards' => array(
|
||||
'js_name' => 'disabledCards',
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue