Merge branch 'trunk' into PCP-3030-fastlane-improvements-for-kadence-theme

This commit is contained in:
Emili Castells 2024-04-30 16:14:26 +02:00 committed by GitHub
commit e99c1ea75f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 27 additions and 4 deletions

View file

@ -6,6 +6,7 @@ import BillingView from "./Views/BillingView";
import CardView from "./Views/CardView";
import PayPalInsights from "./Insights/PayPalInsights";
import {disable,enable} from "../../../ppcp-button/resources/js/modules/Helper/ButtonDisabler";
import {getCurrentPaymentMethod} from "../../../ppcp-button/resources/js/modules/Helper/CheckoutMethodState";
class AxoManager {
@ -154,6 +155,13 @@ class AxoManager {
this.cardView.refresh();
});
// Prevents sending checkout form when pressing Enter key on input field
// and triggers customer lookup
this.$('form.woocommerce-checkout input').on('keydown', async (ev) => {
if(ev.key === 'Enter' && getCurrentPaymentMethod() === 'ppcp-axo-gateway' ) {
ev.preventDefault();
}
});
}
rerender() {
@ -222,6 +230,8 @@ class AxoManager {
}
if (scenario.axoProfileViews) {
this.el.billingAddressContainer.hide();
this.shippingView.activate();
this.billingView.activate();
this.cardView.activate();
@ -520,6 +530,10 @@ class AxoManager {
page_type: 'checkout'
});
await this.lookupCustomerByEmail();
}
async lookupCustomerByEmail() {
const lookupResponse = await this.fastlane.identity.lookupCustomerByEmail(this.emailInput.value);
if (lookupResponse.customerContextId) {
@ -537,7 +551,8 @@ class AxoManager {
// Add addresses
this.setShipping(authResponse.profileData.shippingAddress);
this.setBilling({
address: authResponse.profileData.card.paymentSource.card.billingAddress
address: authResponse.profileData.card.paymentSource.card.billingAddress,
phoneNumber: authResponse.profileData.shippingAddress.phoneNumber.nationalNumber ?? ''
});
this.setCard(authResponse.profileData.card);

View file

@ -1,5 +1,3 @@
import {setVisible} from "../../../../ppcp-button/resources/js/modules/Helper/Hiding";
class DomElement {
constructor(config) {

View file

@ -18,6 +18,7 @@ class Fastlane {
resolve();
})
.catch((error) => {
console.error(error)
reject();
});
});

View file

@ -90,6 +90,10 @@ class BillingView {
company: {
'selector': '#billing_company_field',
'valuePath': null,
},
phone: {
'selector': '#billing_phone_field',
'valuePath': 'billing.phoneNumber'
}
}
});

View file

@ -40,6 +40,7 @@ class ShippingView {
<h3>Shipping</h3>
<a href="javascript:void(0)" ${this.el.changeShippingAddressLink.attributes}>Edit</a>
</div>
<div>${data.value('email')}</div>
<div>${data.value('company')}</div>
<div>${data.value('firstName')} ${data.value('lastName')}</div>
<div>${data.value('street1')}</div>
@ -52,6 +53,9 @@ class ShippingView {
`;
},
fields: {
email: {
'valuePath': 'email',
},
firstName: {
'key': 'firstName',
'selector': '#shipping_first_name_field',