Show save card checkbox checked and disabled if subscription in cart

This commit is contained in:
Emili Castells Guasch 2024-06-04 18:17:33 +02:00
parent cb96f888a0
commit 559d0654a2
2 changed files with 13 additions and 2 deletions

View file

@ -1,7 +1,7 @@
import {useEffect} from '@wordpress/element';
import {usePayPalCardFields} from "@paypal/react-paypal-js";
export const CheckoutHandler = ({getCardFieldsForm, getSavePayment, saveCardText, is_vaulting_enabled}) => {
export const CheckoutHandler = ({getCardFieldsForm, getSavePayment, hasSubscriptionProducts, saveCardText, is_vaulting_enabled}) => {
const {cardFieldsForm} = usePayPalCardFields();
useEffect(() => {
@ -14,7 +14,14 @@ export const CheckoutHandler = ({getCardFieldsForm, getSavePayment, saveCardText
return (
<>
<input type="checkbox" id="save" name="save" onChange={(e) => getSavePayment(e.target.checked)}/>
<input
type="checkbox"
id="save"
name="save"
onChange={(e) => getSavePayment(e.target.checked)}
defaultChecked={hasSubscriptionProducts}
disabled={hasSubscriptionProducts}
/>
<label htmlFor="save">{saveCardText}</label>
</>
)