Question

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.

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top