0

Is there any way I can get a customer default billing address in custom js ?

var defaultBillingAddresses = addressList().filter(function (address) {
                console.log(address.getType());
                return  address.getType() == 'customer-address' && address.isDefaultBilling();
            });

Above is mine code with inject

'Magento_Customer/js/model/address-list'

but it's not retrieving any thing.

  • have you tried using customerData with customer.js ? – Dimple Panchal Mar 30 at 16:29
  • yes, but can you clarify more your point – Yogesh Mar 30 at 16:36
0

not sure, I haven't tried this code.

var customerData = {};
if (isLoggedIn()) {
    customerData = window.customerData;
} else {
    customerData = {};
}

cust_addresses = this.customerData.addresses;
// user for each for addresses
if(cust_addresses[addressId]['default_billing'] == 1)
{
//write your code here.
}

hope this will help.

| improve this answer | |
  • not working....! – Yogesh Mar 30 at 17:52

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.