Skip to content

Commit

Permalink
Merge pull request #114 from YotpoLtd/COR-2220-pass-origin-request-pa…
Browse files Browse the repository at this point in the history
…rams-in-abandoned-cart-redirection

COR-2220 pass origin request params in abandoned cart redirection
  • Loading branch information
LiorGingi authored Jul 24, 2022
2 parents 535bbca + 15d2b59 commit c5965f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions Controller/AbandonedCart/LoadCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,27 @@ public function __construct(
*/
public function execute()
{
$resultPage = $this->resultRedirectFactory->create();
$originRequestParams = $this->request->getParams();
$redirectionRequestParamsArray = ['_query' => $originRequestParams];

$yotpoQuoteToken = $this->request->getParam('yotpoQuoteToken', null);
if ($yotpoQuoteToken === null) {
$this->messageManager->addErrorMessage(self::NO_ACTIVE_QUOTE);
return $this->resultRedirectFactory->create()->setPath('/');
return $resultPage->setPath('/', $redirectionRequestParamsArray);
}

$abandonedCartQuoteId = (int)$this->abandonedCartData->getQuoteId($yotpoQuoteToken);
if (!$abandonedCartQuoteId) {
$this->messageManager->addErrorMessage(self::NO_ACTIVE_QUOTE);
return $this->resultRedirectFactory->create()->setPath('/');
return $resultPage->setPath('/', $redirectionRequestParamsArray);
}

$abandonedQuote = $this->quoteRepository->get($abandonedCartQuoteId);
/** @phpstan-ignore-next-line */
if (!$abandonedQuote || !$abandonedQuote->getId() || !$abandonedQuote->getIsActive()) {
$this->messageManager->addErrorMessage(self::NO_ACTIVE_QUOTE);
return $this->resultRedirectFactory->create()->setPath('/');
return $resultPage->setPath('/', $redirectionRequestParamsArray);
}

$customerSessionCustomer = $this->customerSession->getCustomer();
Expand All @@ -165,17 +169,17 @@ public function execute()
$this->yotpoSmsBumpSession->start();
$this->yotpoSmsBumpSession->setData('yotpoQuoteToken', $abandonedCartQuoteId);
if ($isLoggedInCustomerDifferent) {
return $this->resultRedirectFactory->create()->setPath('customer/account/login');
return $resultPage->setPath('customer/account/login', $redirectionRequestParamsArray);
}
}

$isValidQuote = $this->abandonedCartData->setQuoteData($abandonedCartQuoteId);
if (!$isValidQuote) {
return $this->resultRedirectFactory->create()->setPath('/');
return $resultPage->setPath('/', $redirectionRequestParamsArray);
}

$this->checkoutSession->setQuoteId($abandonedCartQuoteId);
$resultPage = $this->resultRedirectFactory->create()->setPath('checkout/cart');
$resultPage->setPath('checkout/cart', $redirectionRequestParamsArray);
$resultPage->setHeader('Yotpo-Abandoned-Cart', 'true');
return $resultPage;
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "yotpo/module-yotpo-messaging",
"description": "Yotpo Sms extension for Magento2",
"version": "4.0.28",
"version": "4.0.29",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"php": "~5.6.0|^7.0|^8.0",
"magento/framework": ">=102.0.0",
"yotpo/module-yotpo-core": "4.0.28"
"yotpo/module-yotpo-core": "4.0.29"
},
"type": "magento2-module",
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Yotpo_SmsBump" setup_version="4.0.28">
<module name="Yotpo_SmsBump" setup_version="4.0.29">
<sequence>
<Yotpo_Core/>
</sequence>
Expand Down

0 comments on commit c5965f1

Please sign in to comment.