4

Please, how to get guest informations like email, address, phone ... in checkout?

  • 1
    The Magento stores this additional details for guest customer, only then customer fill this items on the checkout step and they will be stored in quote. You can't get this details before guest customer fill them. – joni jones Jun 14 '16 at 20:33
  • Mind to add this as an answer @jonijones?! – Anna Völkl Jun 18 '16 at 10:51
  • @AnnaVölkl, if it will be helpful, I can create answer with more details. – joni jones Jun 19 '16 at 19:30
4

This is the solution, you can get guest and customer informations in checkout , inject Magento_Checkout/js/model/quote on your view method.

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: 'Path/to/your/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;
            },

        });
    }
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.