Skip to content

Commit 91a309a

Browse files
committed
test
1 parent f6a676b commit 91a309a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Controller/Cart/Loadquote.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function __construct(
9898
Publisher $publisher,
9999
Contact $mauticContact
100100
) {
101-
101+
102102
$this->pageFactory = $pageFactory;
103103
$this->_quote = $quote;
104104
$this->_customerSession = $customerSession;
@@ -123,8 +123,9 @@ public function execute()
123123
$quote->getResource()->load($quote, $params['id']);
124124
$magentoStoreId = $quote->getStoreId();
125125
$configSecretKey = $this->_helper->getConfig(\Lof\Mautic\Helper\Data::MODULE_ABANDONEDCART_TOKEN);
126+
$tokenNew = $configSecretKey ? md5($configSecretKey.$params['id']) : "";
126127

127-
if (!isset($params['token']) || $params['token'] != $configSecretKey) {
128+
if (!isset($params['token']) || ($tokenNew && $params['token'] != $tokenNew)) {
128129
// @error
129130
$this->_message->addErrorMessage(__("You can't access this cart"));
130131
$url = $this->_urlHelper->getUrl(
@@ -158,7 +159,7 @@ public function execute()
158159
if ($emailAddress = $quote->getCustomerEmail()) {
159160
$this->processUpdateContactTag($emailAddress, $quote->getStoreId());
160161
}
161-
162+
162163
if (!$quote->getCustomerId()) {
163164
$this->_checkoutSession->setQuoteId($quote->getId());
164165
$this->_redirect($url);
@@ -185,7 +186,7 @@ public function execute()
185186

186187
/**
187188
* process update contact tags
188-
*
189+
*
189190
* @param string $email
190191
* @param int|string|null $storeId
191192
* @return bool
@@ -208,4 +209,4 @@ protected function processUpdateContactTag($email, $storeId = null)
208209
}
209210
return true;
210211
}
211-
}
212+
}

Queue/Processor/AbandonedCartProcessor.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ public function process()
7777
$this->_processAbandoned($storeId);
7878
}
7979
}
80-
80+
8181
return;
8282
}
8383

8484
/**
8585
* Process abandoned cart
86-
*
86+
*
8787
* @param int $storeId
8888
* @return void
8989
*/
@@ -99,6 +99,9 @@ protected function _processAbandoned($storeId)
9999
$this->customergroups = [];
100100
}
101101
$diff = $this->helperData->getConfig(Data::MODULE_DIFF_DATE, $storeId);
102+
if (!$diff) { //Disable feature when diff date number is empty
103+
return;
104+
}
102105
$expr = sprintf('DATE_SUB(now(), %s)', $this->_getIntervalUnitSql($diff, 'DAY'));
103106
$from = new \Zend_Db_Expr($expr);
104107

@@ -119,7 +122,7 @@ protected function _processAbandoned($storeId)
119122

120123
try {
121124
foreach ($collection as $quote) {
122-
$tokenNew = $token;//.md5(rand(0, 9999999));
125+
$tokenNew = md5($token.$quote->getEntityId());
123126
$url = $this->_storeManager->getStore($storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK) . 'mautic/cart/loadquote?id=' . $quote->getEntityId() . '&token=' . $tokenNew;
124127

125128
$customData = [
@@ -142,7 +145,7 @@ protected function _processAbandoned($storeId)
142145
} catch (\Exception $e) {
143146
//log exception at here
144147
}
145-
148+
146149
return;
147150
}
148151

0 commit comments

Comments
 (0)