@@ -191,6 +191,36 @@ const MollieComponent = (props) => {
191191
192192 } , [ activePaymentMethod , onCheckoutValidation , billing . billingData , shippingData . shippingAddress , item , phoneString , inputBirthdate , inputPhone ] ) ;
193193
194+ useEffect ( ( ) => {
195+ let phoneLabel = getPhoneField ( ) ?. labels ?. [ 0 ] ?? null ;
196+ if ( ! phoneLabel || phoneLabel . length === 0 ) {
197+ return
198+ }
199+ if ( activePaymentMethod === 'mollie_wc_gateway_bancomatpay' ) {
200+ phoneLabel . innerText = item . phonePlaceholder
201+ } else {
202+ if ( phoneString !== false ) {
203+ phoneLabel . innerText = phoneString
204+ }
205+ }
206+ let isPhoneEmpty = ( billing . billingData . phone === '' && shippingData . shippingAddress . phone === '' ) && inputPhone === '' ;
207+ const unsubscribeProcessing = onCheckoutValidation (
208+
209+ ( ) => {
210+ if ( activePaymentMethod === 'mollie_wc_gateway_bancomatpay' && isPhoneEmpty ) {
211+ return {
212+ errorMessage : item . errorMessage ,
213+ } ;
214+ }
215+ }
216+ ) ;
217+ return ( ) => {
218+ unsubscribeProcessing ( )
219+ } ;
220+
221+ } , [ activePaymentMethod , onCheckoutValidation , billing . billingData , shippingData . shippingAddress , item , phoneString , inputPhone ] ) ;
222+
223+
194224 onSubmitLocal = onSubmit
195225 const updateIssuer = ( changeEvent ) => {
196226 selectIssuer ( changeEvent . target . value )
@@ -214,7 +244,9 @@ const MollieComponent = (props) => {
214244 }
215245
216246 function fieldMarkup ( id , fieldType , label , action , value ) {
217- return < div > < label htmlFor = { id } dangerouslySetInnerHTML = { { __html : label } } > </ label > < input type = { fieldType } name = { id } id = { id } value = { value } onChange = { action } /> </ div >
247+ const className = "wc-block-components-text-input wc-block-components-address-form__" + id ;
248+ return < div >
249+ < input type = { fieldType } name = { id } id = { id } value = { value } onChange = { action } > </ input > < label htmlFor = { id } dangerouslySetInnerHTML = { { __html : label } } > </ label > </ div >
218250 }
219251
220252 if ( item . name === "mollie_wc_gateway_billie" ) {
@@ -231,7 +263,17 @@ const MollieComponent = (props) => {
231263 fields . push ( fieldMarkup ( "billing-birthdate" , "date" , birthdateField , updateBirthdate , inputBirthdate ) ) ;
232264 if ( ! isPhoneFieldVisible ) {
233265 const phoneField = item . phonePlaceholder ? item . phonePlaceholder : "Phone" ;
234- fields . push ( fieldMarkup ( "billing-phone" , "tel" , phoneField , updatePhone , inputPhone ) ) ;
266+ fields . push ( fieldMarkup ( "billing-phone-in3" , "tel" , phoneField , updatePhone , inputPhone ) ) ;
267+ }
268+
269+ return < > { fields } </ > ;
270+ }
271+
272+ if ( item . name === "mollie_wc_gateway_bancomatpay" ) {
273+ let fields = [ ] ;
274+ if ( ! isPhoneFieldVisible ) {
275+ const phoneField = item . phonePlaceholder ? item . phonePlaceholder : "Phone" ;
276+ fields . push ( fieldMarkup ( "billing-phone-bancomatpay" , "tel" , phoneField , updatePhone , inputPhone ) ) ;
235277 }
236278
237279 return < > { fields } </ > ;
0 commit comments