mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Filter enabled payment methods
This commit is contained in:
parent
68644c3d62
commit
7ebf94a600
2 changed files with 19 additions and 2 deletions
|
@ -1,17 +1,29 @@
|
|||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
import { StylingHooks } from '../../../../../../data';
|
||||
import { PaymentHooks, StylingHooks } from '../../../../../../data';
|
||||
import { CheckboxStylingSection } from '../Layout';
|
||||
|
||||
const SectionPaymentMethods = ( { location } ) => {
|
||||
const { paymentMethods, setPaymentMethods, choices } =
|
||||
StylingHooks.usePaymentMethodProps( location );
|
||||
|
||||
const methods = PaymentHooks.usePaymentMethods();
|
||||
const methodIds = [];
|
||||
methods.all.forEach( ( method ) => {
|
||||
if ( method.enabled === true ) {
|
||||
methodIds.push( method.id );
|
||||
}
|
||||
} );
|
||||
|
||||
const filteredChoices = choices.filter( ( choice ) => {
|
||||
return methodIds.includes( choice.paymentMethod );
|
||||
} );
|
||||
|
||||
return (
|
||||
<CheckboxStylingSection
|
||||
name="payment-methods"
|
||||
title={ __( 'Payment Methods', 'woocommerce-paypal-payments' ) }
|
||||
options={ choices }
|
||||
options={ filteredChoices }
|
||||
value={ paymentMethods }
|
||||
onChange={ setPaymentMethods }
|
||||
/>
|
||||
|
|
|
@ -109,23 +109,28 @@ export const STYLING_PAYMENT_METHODS = {
|
|||
label: __( 'PayPal', 'woocommerce-paypal-payments' ),
|
||||
checked: true,
|
||||
disabled: true,
|
||||
paymentMethod: 'ppcp-gateway',
|
||||
},
|
||||
venmo: {
|
||||
value: 'venmo',
|
||||
label: __( 'Venmo', 'woocommerce-paypal-payments' ),
|
||||
isFunding: true,
|
||||
paymentMethod: 'venmo',
|
||||
},
|
||||
paylater: {
|
||||
value: 'paylater',
|
||||
label: __( 'Pay Later', 'woocommerce-paypal-payments' ),
|
||||
isFunding: true,
|
||||
paymentMethod: 'pay-later',
|
||||
},
|
||||
googlepay: {
|
||||
value: 'googlepay',
|
||||
label: __( 'Google Pay', 'woocommerce-paypal-payments' ),
|
||||
paymentMethod: 'ppcp-googlepay',
|
||||
},
|
||||
applepay: {
|
||||
value: 'applepay',
|
||||
label: __( 'Apple Pay', 'woocommerce-paypal-payments' ),
|
||||
paymentMethod: 'ppcp-applepay',
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue