Skip to content

Commit 7b6a433

Browse files
authored
Merge pull request #888 from mollie/release/7.5.2-beta
Release/7.5.2 beta
2 parents cff3308 + f6e195a commit 7b6a433

24 files changed

+507
-106
lines changed

mollie-payments-for-woocommerce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Mollie Payments for WooCommerce
44
* Plugin URI: https://www.mollie.com
55
* Description: Accept payments in WooCommerce with the official Mollie plugin
6-
* Version: 7.5.1
6+
* Version: 7.5.2-beta
77
* Author: Mollie
88
* Author URI: https://www.mollie.com
99
* Requires at least: 5.0

public/images/bancomatpay.svg

Lines changed: 11 additions & 0 deletions
Loading

resources/js/blocks/molliePaymentMethod.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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}</>;

resources/js/mollieBillie.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

resources/js/mollieBlockIndex.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,30 @@ import molliePaymentMethod from './blocks/molliePaymentMethod'
77
}
88
window.onload = (event) => {
99
const { registerPaymentMethod } = wc.wcBlocksRegistry;
10+
const { checkoutData, defaultFields } = wc.wcSettings.allSettings;
11+
const { billing_address, shipping_address } = checkoutData;
1012
const { ajaxUrl, filters, gatewayData, availableGateways } = mollieBlockData.gatewayData;
1113
const {useEffect} = wp.element;
1214
const isAppleSession = typeof window.ApplePaySession === "function"
1315
const isBlockEditor = !!wp?.blockEditor;
1416

1517
function getCompanyField() {
16-
let shippingCompany = document.getElementById('shipping-company');
17-
let billingCompany = document.getElementById('billing-company');
18+
let shippingCompany = shipping_address.company ?? false;
19+
let billingCompany = billing_address.company ?? false;
1820
return shippingCompany ? shippingCompany : billingCompany;
1921
}
2022

2123
function getPhoneField()
2224
{
23-
const shippingPhone = document.getElementById('shipping-phone');
24-
const billingPhone = document.getElementById('billing-phone');
25+
const shippingPhone = shipping_address.phone ?? false;
26+
const billingPhone = billing_address.phone ?? false
2527
return billingPhone || shippingPhone;
2628
}
27-
function isFieldVisible(field)
28-
{
29-
return field && field.style.display !== 'none';
30-
}
31-
let companyField = getCompanyField();
32-
const isCompanyFieldVisible = companyField && isFieldVisible(companyField);
33-
const companyNameString = companyField && companyField.parentNode.querySelector('label') ? companyField.parentNode.querySelector('label').innerHTML : false;
34-
let phoneField = getPhoneField();
35-
const isPhoneFieldVisible = phoneField && isFieldVisible(phoneField);
36-
const phoneString = phoneField && phoneField.parentNode.querySelector('label') ? phoneField.parentNode.querySelector('label').innerHTML : false;
29+
30+
const isCompanyFieldVisible = getCompanyField();
31+
const companyNameString = defaultFields.company.label
32+
const isPhoneFieldVisible = getPhoneField();
33+
const phoneString = defaultFields.phone.label
3734
let requiredFields = {
3835
'companyNameString': companyNameString,
3936
'phoneString': phoneString,

src/Assets/AssetsModule.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,6 @@ protected function registerFrontendScripts(string $pluginUrl, string $pluginPath
276276
(string) filemtime($this->getPluginPath($pluginPath, '/public/js/gatewaySurcharge.min.js')),
277277
true
278278
);
279-
wp_register_script(
280-
'mollie-billie-classic-handles',
281-
$this->getPluginUrl($pluginUrl, '/public/js/mollieBillie.min.js'),
282-
['underscore', 'jquery'],
283-
(string) filemtime($this->getPluginPath($pluginPath, '/public/js/mollieBillie.min.js')),
284-
true
285-
);
286279
}
287280

288281
public function registerBlockScripts(string $pluginUrl, string $pluginPath): void

0 commit comments

Comments
 (0)