customer-addresses.js 793 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. /**
  6. * @api
  7. */
  8. define([
  9. 'jquery',
  10. 'ko',
  11. './customer/address'
  12. ], function ($, ko, Address) {
  13. 'use strict';
  14. var isLoggedIn = ko.observable(window.isCustomerLoggedIn);
  15. return {
  16. /**
  17. * @return {Array}
  18. */
  19. getAddressItems: function () {
  20. var items = [],
  21. customerData = window.customerData;
  22. if (isLoggedIn()) {
  23. if (Object.keys(customerData).length) {
  24. $.each(customerData.addresses, function (key, item) {
  25. items.push(new Address(item));
  26. });
  27. }
  28. }
  29. return items;
  30. }
  31. };
  32. });