We have the following situation in Magento:

  1. Guest customer is about place order.

  2. The customer filled his billing and shipping addresses on checkout page.

  3. The customer reached one of the following checkout steps (shipping methods, payment methods, order review).

  4. The customer decides to edit his cart and goes back to cart page

  5. The customer reaches the checkout page again then billing information should display

How can store and retrieve the customer information


You can use various local storage mechanisms to store this data in the browser such as Web Storage.

The simplest and most widely supported is WebStorage where you have persistent storage (localStorage) or session based (sessionStorage) which is in memory until you close the browser. Both share the same API.

You can for example (simplified) do something like this when the page is about to reload:

window.onbeforeunload = function() {
    localStorage.setItem(name, $('#inputName').val());
    localStorage.setItem(email, $('#inputEmail').val());
    localStorage.setItem(phone, $('#inputPhone').val());
    localStorage.setItem(subject, $('#inputSubject').val());
    localStorage.setItem(detail, $('#inputDetail').val());
    // ...

Web Storage works synchronously so this can work here. Optionally you can store the data for each blur event on the elements where the data is entered.

At page load you can check:

window.onload = function() {

    var name = localStorage.getItem(name);
    if (name !== null) $('#inputName').val(name);

    // ...

getItem returns null if the data does not exist.

Use sessionStorage instead of localStorage if you want to store only temporary.

For More See here.

| improve this answer | |

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.