mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fixes AXO module.
This commit is contained in:
parent
995621ba21
commit
2f1c36af40
7 changed files with 55 additions and 22 deletions
|
@ -587,9 +587,6 @@ class AxoManager {
|
|||
cardComponentData() {
|
||||
return {
|
||||
fields: {
|
||||
phoneNumber: {
|
||||
prefill: this.billingView.inputValue('phone')
|
||||
},
|
||||
cardholderName: {} // optionally pass this to show the card holder name
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ class FormFieldGroup {
|
|||
return '';
|
||||
}
|
||||
|
||||
if (typeof this.fields[fieldKey].valueCallback === 'function') {
|
||||
return this.fields[fieldKey].valueCallback(this.data);
|
||||
}
|
||||
|
||||
const path = this.fields[fieldKey].valuePath;
|
||||
|
||||
if (!path) {
|
||||
|
@ -64,7 +68,7 @@ class FormFieldGroup {
|
|||
Object.keys(this.fields).forEach((key) => {
|
||||
const field = this.fields[key];
|
||||
|
||||
if (this.active) {
|
||||
if (this.active && !field.showInput) {
|
||||
this.hideField(field.selector);
|
||||
} else {
|
||||
this.showField(field.selector);
|
||||
|
@ -106,6 +110,7 @@ class FormFieldGroup {
|
|||
}
|
||||
|
||||
inputElement(name) {
|
||||
console.log('inputElement', name);
|
||||
const baseSelector = this.fields[name].selector;
|
||||
|
||||
const select = document.querySelector(baseSelector + ' select');
|
||||
|
|
|
@ -14,6 +14,11 @@ class BillingView {
|
|||
return '';
|
||||
}
|
||||
const selectElement = document.querySelector(selectSelector);
|
||||
|
||||
if (!selectElement) {
|
||||
return ${key};
|
||||
}
|
||||
|
||||
const option = selectElement.querySelector(`option[value="${key}"]`);
|
||||
return option ? option.textContent : key;
|
||||
}
|
||||
|
@ -37,7 +42,6 @@ class BillingView {
|
|||
<div>${data.value('postCode')} ${data.value('city')}</div>
|
||||
<div>${valueOfSelect('#billing_state', data.value('stateCode'))}</div>
|
||||
<div>${valueOfSelect('#billing_country', data.value('countryCode'))}</div>
|
||||
<div>${data.value('phone')}</div>
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
|
@ -80,11 +84,7 @@ class BillingView {
|
|||
company: {
|
||||
'selector': '#billing_company_field',
|
||||
'valuePath': null,
|
||||
},
|
||||
// phone: {
|
||||
// 'selector': '#billing_phone_field',
|
||||
// 'valuePath': null,
|
||||
// },
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ class ShippingView {
|
|||
return '';
|
||||
}
|
||||
const selectElement = document.querySelector(selectSelector);
|
||||
|
||||
if (!selectElement) {
|
||||
return ${key};
|
||||
}
|
||||
|
||||
const option = selectElement.querySelector(`option[value="${key}"]`);
|
||||
return option ? option.textContent : key;
|
||||
}
|
||||
|
@ -36,6 +41,7 @@ class ShippingView {
|
|||
<div>${data.value('postCode')} ${data.value('city')}</div>
|
||||
<div>${valueOfSelect('#shipping_state', data.value('stateCode'))}</div>
|
||||
<div>${valueOfSelect('#shipping_country', data.value('countryCode'))}</div>
|
||||
<div>${data.value('phone')}</div>
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
|
@ -80,6 +86,20 @@ class ShippingView {
|
|||
shipDifferentAddress: {
|
||||
'selector': '#ship-to-different-address',
|
||||
'valuePath': null,
|
||||
},
|
||||
phone: {
|
||||
'selector': '#billing_phone_field', // There is no shipping phone field.
|
||||
'valueCallback': function (data) {
|
||||
let phone = '';
|
||||
const cc = data?.shipping?.phoneNumber?.countryCode;
|
||||
const number = data?.shipping?.phoneNumber?.nationalNumber;
|
||||
|
||||
if (cc) {
|
||||
phone = `+${cc} `;
|
||||
}
|
||||
phone += number;
|
||||
return phone;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue