Magento2: Guest checkout shipping form blank on checkout page refresh

Created on 15 Jun 2018  路  6Comments  路  Source: magento/magento2

Preconditions

  1. PHP 7.0
  2. Apache 2.4
  3. Magento 2.2.2

Steps to reproduce

  • Admin Settings:
  • Persistent Shopping Cart = Enabled
  • Persist Shopping Cart = Yes or No (I've checked both conditions)

  • Frontend:

  • Homepage: create's cookie - "mage-cache-sessid" = true
  • Add to cart - delete's cookie "mage-cache-sessid"
  • Visit checkout page - delete's cookie "mage-cache-sessid"
  • Fillup shipping address form & selected a shipping method
  • Refresh Checkout page then shipping address blank & shipping method too.

_Investigated results:_

  • /vendor/magento/module-persistent/Observer/CheckExpirePersistentQuoteObserver.php
if ($this->_persistentData->isEnabled() &&
    !$this->_persistentSession->isPersistent() &&
    !$this->_customerSession->isLoggedIn() &&
    $this->_checkoutSession->getQuoteId() &&
    !$observer->getControllerAction() instanceof \Magento\Checkout\Controller\Onepage
    // persistent session does not expire on onepage checkout page to not spoil customer group id
) {
    $this->_eventManager->dispatch('persistent_session_expired');

Note: Please note observer: persistent_session_expired checks whether guest customer then trigger persistent_session_expired event.

  • /vendor/magento/module-persistent/etc/frontend/events.xml
<event name="persistent_session_expired">
    <observer name="refresh_customer_data" instance="Magento\Persistent\Observer\RefreshCustomerData" />
</event>
  • /vendor/magento/module-persistent/Observer/RefreshCustomerData.php
if ($this->cookieManager->getCookie('mage-cache-sessid')) {
    $metadata = $this->cookieMetadataFactory->createCookieMetadata();
    $metadata->setPath('/');
    $this->cookieManager->deleteCookie('mage-cache-sessid', $metadata);
}

Note: above code does not check persistent session is expired or not.

  • /vendor/magento/module-customer/view/frontend/web/js/customer-data.js
/**
     * Invalidate Cache By Close Cookie Session
     */
    invalidateCacheByCloseCookieSession = function () {
        if (!$.cookieStorage.isSet('mage-cache-sessid')) {
            $.cookieStorage.set('mage-cache-sessid', true);
            storage.removeAll();
        }
    };

Above code check cookie & if not found then cookie mage-cache-sessid is created & localStorage is empty.

Expected result

  1. After checkout page refresh, shipping address form must be pre-filled from localStorage - "mage-cache-storage"

Actual result

  1. Currently, after refresh checkout page, shipping address form is blank.
  2. If customer logged in then he/she adds new address in Checkout page then on same or new device that new address never shows up on checkout page.
  3. Same affects on Shopping cart page found.
  4. Because localStorage is device specific then new shipping address is never stored in DB for guest & logged in customer.
FrameworSession Fixed in 2.1.x Fixed in 2.3.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.2.x

Most helpful comment

issue persists in 2.3.2

All 6 comments

@Ananth747, thank you for your report.
We've acknowledged the issue and added to our backlog.

Hi @engcom-backlog-nazar. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [ ] 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

Hi @ananth747 The issue was re-tested and we can confirm that it was fixed on the 2.3 release branch. We closing this issue as fixed due to upcoming 2.3 release that will be available soon.

issue persists in 2.3.2

Was this page helpful?
0 / 5 - 0 ratings