diff --git a/modules/ppcp-axo/resources/js/AxoManager.js b/modules/ppcp-axo/resources/js/AxoManager.js index 140dea944..6fbdb8d73 100644 --- a/modules/ppcp-axo/resources/js/AxoManager.js +++ b/modules/ppcp-axo/resources/js/AxoManager.js @@ -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); diff --git a/modules/ppcp-axo/resources/js/Components/DomElement.js b/modules/ppcp-axo/resources/js/Components/DomElement.js index 8e789d485..30cadcb2a 100644 --- a/modules/ppcp-axo/resources/js/Components/DomElement.js +++ b/modules/ppcp-axo/resources/js/Components/DomElement.js @@ -1,5 +1,3 @@ -import {setVisible} from "../../../../ppcp-button/resources/js/modules/Helper/Hiding"; - class DomElement { constructor(config) { diff --git a/modules/ppcp-axo/resources/js/Connection/Fastlane.js b/modules/ppcp-axo/resources/js/Connection/Fastlane.js index 9f2993081..8e1c76949 100644 --- a/modules/ppcp-axo/resources/js/Connection/Fastlane.js +++ b/modules/ppcp-axo/resources/js/Connection/Fastlane.js @@ -18,6 +18,7 @@ class Fastlane { resolve(); }) .catch((error) => { + console.error(error) reject(); }); }); diff --git a/modules/ppcp-axo/resources/js/Views/BillingView.js b/modules/ppcp-axo/resources/js/Views/BillingView.js index e7d517f62..aba44afcf 100644 --- a/modules/ppcp-axo/resources/js/Views/BillingView.js +++ b/modules/ppcp-axo/resources/js/Views/BillingView.js @@ -90,6 +90,10 @@ class BillingView { company: { 'selector': '#billing_company_field', 'valuePath': null, + }, + phone: { + 'selector': '#billing_phone_field', + 'valuePath': 'billing.phoneNumber' } } }); diff --git a/modules/ppcp-axo/resources/js/Views/ShippingView.js b/modules/ppcp-axo/resources/js/Views/ShippingView.js index cc9550951..4f0a18f8d 100644 --- a/modules/ppcp-axo/resources/js/Views/ShippingView.js +++ b/modules/ppcp-axo/resources/js/Views/ShippingView.js @@ -40,6 +40,7 @@ class ShippingView {