diff --git a/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js b/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js index 6784ca111674c..49911ddbee9d4 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js @@ -15,39 +15,40 @@ define([ 'use strict'; var cacheKey = 'checkout-data', + checkoutData, /** - * @param {Object} data + * @return {*} */ - saveData = function (data) { - storage.set(cacheKey, data); + getData = function () { + return storage.get(cacheKey)(); }, /** - * @return {*} + * @param {Object} data */ - getData = function () { - var data = storage.get(cacheKey)(); - - if ($.isEmptyObject(data)) { - data = { - 'selectedShippingAddress': null, - 'shippingAddressFromData': null, - 'newCustomerShippingAddress': null, - 'selectedShippingRate': null, - 'selectedPaymentMethod': null, - 'selectedBillingAddress': null, - 'billingAddressFormData': null, - 'newCustomerBillingAddress': null - }; - saveData(data); - } - - return data; + saveData = function (data) { + storage.set(cacheKey, data); + }; + + if ($.isEmptyObject(getData())) { + checkoutData = { + 'selectedShippingAddress': null, //Selected shipping address pulled from persistence storage. + 'shippingAddressFromData': null, //Shipping address pulled from persistence storage. + 'newCustomerShippingAddress': null, //Shipping address pulled from persistence storage for new customer. + 'selectedShippingRate': null, //Shipping rate pulled from persistence storage. + 'selectedPaymentMethod': null, //Payment method pulled from persistence storage. + 'selectedBillingAddress': null, //Selected billing address pulled from persistence storage. + 'billingAddressFromData': null, //Billing address pulled from persistence storage. + 'newCustomerBillingAddress': null //Billing address pulled from persistence storage for new customer. }; + saveData(checkoutData); + } return { /** + * Setting the selected shipping address pulled from persistence storage. + * * @param {Object} data */ setSelectedShippingAddress: function (data) { @@ -58,6 +59,8 @@ define([ }, /** + * Pulling the selected shipping address from persistence storage. + * * @return {*} */ getSelectedShippingAddress: function () { @@ -65,6 +68,8 @@ define([ }, /** + * Setting the shipping address pulled from persistence storage. + * * @param {Object} data */ setShippingAddressFromData: function (data) { @@ -75,6 +80,8 @@ define([ }, /** + * Pulling the shipping address from persistence storage. + * * @return {*} */ getShippingAddressFromData: function () { @@ -82,6 +89,8 @@ define([ }, /** + * Setting the shipping address pulled from persistence storage for new customer. + * * @param {Object} data */ setNewCustomerShippingAddress: function (data) { @@ -92,6 +101,8 @@ define([ }, /** + * Pulling the shipping address from persistence storage for new customer. + * * @return {*} */ getNewCustomerShippingAddress: function () { @@ -99,6 +110,8 @@ define([ }, /** + * Setting the selected shipping rate pulled from persistence storage. + * * @param {Object} data */ setSelectedShippingRate: function (data) { @@ -109,6 +122,8 @@ define([ }, /** + * Pulling the selected shipping rate from local storge + * * @return {*} */ getSelectedShippingRate: function () { @@ -116,6 +131,8 @@ define([ }, /** + * Setting the selected payment method pulled from persistence storage. + * * @param {Object} data */ setSelectedPaymentMethod: function (data) { @@ -126,6 +143,8 @@ define([ }, /** + * Pulling the payment method from persistence storage. + * * @return {*} */ getSelectedPaymentMethod: function () { @@ -133,6 +152,8 @@ define([ }, /** + * Setting the selected billing address pulled from persistence storage. + * * @param {Object} data */ setSelectedBillingAddress: function (data) { @@ -143,6 +164,8 @@ define([ }, /** + * Pulling the selected billing address from persistence storage. + * * @return {*} */ getSelectedBillingAddress: function () { @@ -150,6 +173,8 @@ define([ }, /** + * Setting the billing address pulled from persistence storage. + * * @param {Object} data */ setBillingAddressFromData: function (data) { @@ -160,6 +185,7 @@ define([ }, /** + * Pulling the billing address from persistence storage. * @return {*} */ getBillingAddressFromData: function () { @@ -167,6 +193,8 @@ define([ }, /** + * Setting the billing address pulled from persistence storage for new customer. + * * @param {Object} data */ setNewCustomerBillingAddress: function (data) { @@ -177,6 +205,8 @@ define([ }, /** + * Pulling the billing address from persistence storage for new customer. + * * @return {*} */ getNewCustomerBillingAddress: function () { @@ -184,6 +214,8 @@ define([ }, /** + * Pulling the email address from persistence storage. + * * @return {*} */ getValidatedEmailValue: function () { @@ -193,6 +225,8 @@ define([ }, /** + * Setting the email address pulled from persistence storage. + * * @param {String} email */ setValidatedEmailValue: function (email) { @@ -203,6 +237,8 @@ define([ }, /** + * Pulling the email input field value from persistence storage. + * * @return {*} */ getInputFieldEmailValue: function () { @@ -212,6 +248,8 @@ define([ }, /** + * Setting the email input field value pulled from persistence storage. + * * @param {String} email */ setInputFieldEmailValue: function (email) {