From 8b6cb86dbb08a3871fd8d3fb7bb7d916c98933ff Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Fri, 27 Sep 2024 19:11:35 +0400 Subject: [PATCH] Add Custom Placeholder Handling when rendering the card fields --- modules/ppcp-card-fields/resources/js/Render.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/ppcp-card-fields/resources/js/Render.js b/modules/ppcp-card-fields/resources/js/Render.js index 146396288..a0efd78bd 100644 --- a/modules/ppcp-card-fields/resources/js/Render.js +++ b/modules/ppcp-card-fields/resources/js/Render.js @@ -8,11 +8,17 @@ function renderField( cardField, inputField ) { // Insert the PayPal card field after the original input field. const styles = cardFieldStyles( inputField ); - cardField( { style: { input: styles } } ).render( inputField.parentNode ); + const fieldOptions = {style: { input: styles },}; - // Hide the original input field. - hide( inputField, true ); - inputField.hidden = true; + if ( inputField.getAttribute( 'placeholder' ) ) { + fieldOptions.placeholder = inputField.getAttribute( 'placeholder' ); + } + + cardField( fieldOptions ).render( inputField.parentNode ); + + // Hide the original input field. + hide( inputField, true ); + inputField.hidden = true; } export function renderFields( cardFields ) {