Skip to content

Commit a7c3fc6

Browse files
stkorfvital-pantsialeyeu
authored andcommitted
MAGETWO-66666: Adding a product to cart from category page with an expired session does not allow product to be added
- Add reload and error message
1 parent 8c227d5 commit a7c3fc6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ define([
159159
.html(res.product.statusText);
160160
}
161161
self.enableAddToCartButton(form);
162+
},
163+
164+
/** @inheritdoc */
165+
complete: function (res) {
166+
if (res.state() == 'rejected') {
167+
location.reload();
168+
}
162169
}
163170
});
164171
},

app/code/Magento/Checkout/Controller/Cart/Add.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ protected function _initProduct()
8080
public function execute()
8181
{
8282
if (!$this->_formKeyValidator->validate($this->getRequest())) {
83+
$this->messageManager->addErrorMessage(
84+
__('Your session has expired')
85+
);
8386
return $this->resultRedirectFactory->create()->setPath('*/*/');
8487
}
8588

0 commit comments

Comments
 (0)