Solution
/**
* 2016-04-20
* How to get the current customer's email on the frontend checkout screen?
* https://mage2.pro/t/1295
* @returns {String}
*/
email: function() {
/**
* 2016-04-20
* How to programmatically check on the frontend checkout screen client side (with JavaScript) whether the customer is authenticated (logged in)?
* https://mage2.pro/t/1303
*/
return (
window.isCustomerLoggedIn
? window.customerData.email
/**
* 2016-06-01
* Брать надо именно getValidatedEmailValue(), а не getInputFieldEmailValue():
*
* What is the difference between «Magento_Checkout/js/checkout-data»'s
* getValidatedEmailValue() and getInputFieldEmailValue() methods?
* https://mage2.pro/t/1733
*
* How are the «Magento_Checkout/js/checkout-data»'s
* setValidatedEmailValue() and setInputFieldEmailValue() methods
* implemeted and used? https://mage2.pro/t/1734
*/
: checkoutData.getValidatedEmailValue()
);
},
Decription
1. A registered customer case
You can just use the window.customerData
object:
window.customerData.email
2. A guest customer case
The both guest case methods do not work when a registered customer uses an address from his address book. For a registered customer see the solution above.
Use the Magento_Checkout/js/checkout-data
object.
checkoutData.getValidatedEmailValue()
checkoutData.getInputFieldEmailValue()
Details: