5

I want to apply a functionality that enables , dynamic billing address to be changed as per changing shipping address in checkout page magento 2. How to get shipping address from quote object in custom js file magento 2 ?

Appreciate your help.

1 Answer 1

4

You can access the shipping address from the quote js model in your custom js file.

Use below code to access shipping address in your custom js file:

define(
        [
            'ko',
            'Magento_Checkout/js/model/quote'
        ],
        function (
                ko,
                quote
                ) {
            'use strict';

            return {
                yourFunctionName: function () {

                    var shippingAddress = quote.shippingAddress();
                    var billingAddress = quote.billingAddress();
                }
            };
        }
);

Hope this helps!

1
  • 2
    it returns null.
    – Ali Raza
    Commented Nov 17, 2020 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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