Extract repeat logic into new helper method

This commit is contained in:
Philipp Stracker 2024-09-09 12:16:02 +02:00
parent 36522f685c
commit fc4d2baa67
No known key found for this signature in database

View file

@ -1,6 +1,20 @@
import { cardFieldStyles } from './CardFieldsHelper';
import { hide } from '../../../ppcp-button/resources/js/modules/Helper/Hiding';
function renderField( cardField, inputField ) {
if ( ! inputField || inputField.hidden || ! cardField ) {
return;
}
// Insert the PayPal card field after the original input field.
const styles = cardFieldStyles( inputField );
cardField( { style: { input: styles } } ).render( inputField.parentNode );
// Hide the original input field.
hide( inputField, true );
inputField.hidden = true;
}
export function renderFields( cardFields ) {
const nameField = document.getElementById(
'ppcp-credit-card-gateway-card-name'