mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Add filter for rendering cardholder name field
This commit is contained in:
parent
a50ac455ee
commit
8d9e32baeb
2 changed files with 7 additions and 5 deletions
|
@ -184,10 +184,12 @@ class CreditCardRenderer {
|
|||
});
|
||||
|
||||
if (cardField.isEligible()) {
|
||||
const nameFieldContainer = document.getElementById('ppcp-credit-card-gateway-card-name').parentNode;
|
||||
const nameFieldContainer = document.getElementById('ppcp-credit-card-gateway-card-name')?.parentNode;
|
||||
if(nameFieldContainer) {
|
||||
const nameField = cardField.NameField();
|
||||
nameField.render(nameFieldContainer);
|
||||
document.getElementById("ppcp-credit-card-gateway-card-name").remove();
|
||||
}
|
||||
|
||||
const numberFieldContainer = document.getElementById('ppcp-credit-card-gateway-card-number').parentNode;
|
||||
const numberField = cardField.NumberField();
|
||||
|
|
|
@ -62,7 +62,7 @@ class CardFieldsModule implements ModuleInterface {
|
|||
add_filter(
|
||||
'woocommerce_credit_card_form_fields',
|
||||
function( $default_fields, $id ) {
|
||||
if ( CreditCardGateway::ID === $id ) {
|
||||
if ( CreditCardGateway::ID === $id && apply_filters( 'woocommerce_paypal_payments_enable_cardholder_name_field', false ) ) {
|
||||
$default_fields['card-name-field'] = '<p class="form-row form-row-wide"><label for="ppcp-credit-card-gateway-card-name"><input class="ppcp-credit-card-gateway-card-name" type="text" id="ppcp-credit-card-gateway-card-name" name="ppcp-credit-card-gateway-card-name"/></p>';
|
||||
|
||||
// Moves new item to first position.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue