How can I save shipping address in cookie/localstorage when user fill it and whenever he/she come back to checkout page it automatically populate the saved data from cookie/localstorage in to corresponding fields – For guest user only.
I have done this in Magento 1 but In magento 2 Most of the checkout page is rendered by knockout js(I have zero knowledge of knockout js), I have no Idea how to proceed.
any help is appreciated
Best Answer
In your JS UI component, you will have to inject
Magento_Customer/js/customer-data
Example:
Be sure to the the customer-data.js get to get the data, alter it, and then set it with the set method. Straight setting the data will give a validation error.
Of course you can use that code wherever you like, I just tried to give a basic example of an entire uiComponent in Magento 2, plus the answer local storage questions.
Hope that helps! Cheers!