Magento 2: How to Get Guest Email Address in Checkout?

You can get guest and customer other information in your custom js like customerinfo.js in Magento_Checkout/js/model/quote:

define(
[
'jquery',
'Magento_Checkout/js/view/payment/default',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/action/place-order',
],
function ($,Component,quote,placeOrderAction) {
'use strict';
return Component.extend({
defaults: {
template: 'Company_Module/custompayment/form_template'
},
getEmail: function () {
if(quote.guestEmail) return quote.guestEmail;
else return window.checkoutConfig.customerData.email;
},
getLastName: function () {
return quote.billingAddress().lastname;
},
getFirstName: function () {
return quote.billingAddress().firstname;
},
getAddress: function () {
return quote.billingAddress().street[0]+", "+quote.billingAddress().postcode+" "+quote.billingAddress().city+", Maroc";
},
getPhone: function () {
return quote.billingAddress().telephone;
},
});
}
);
You can get guest's email id without login in checkout page, use avobe code.
Through this process you will able to gather customer's info which is improve your conversions.
Recent Posts

Leave a Comment

quick inquiry in magentoguys
REQUEST A QUOTE x

captcha txt
Not readable? Change text. 100% Privacy - We Will Never Spam You!

Start typing and press Enter to search

new-magento-2.3-features-releaseMagento 2.3 Brings in Amazing New Features to Explore