Skip to content

Commit bef3bad

Browse files
committed
added cart url for abandoned cart
1 parent 738c000 commit bef3bad

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

Controller/Cart/Loadquote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function execute()
122122
$quote = $this->_quote->create();
123123
$quote->getResource()->load($quote, $params['id']);
124124
$magentoStoreId = $quote->getStoreId();
125-
$configSecretKey = $this->_helper->getConfig("general/webhook_secret");
125+
$configSecretKey = $this->_helper->getConfig(\Lof\Mautic\Helper\Data::MODULE_ABANDONEDCART_TOKEN);
126126

127127
if (!isset($params['token']) || $params['token'] != $configSecretKey) {
128128
// @error

Helper/Data.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ class Data extends AbstractHelper
5050
*/
5151
const MODULE_ABANDONEDCART_PAGE = 'abandoned/page';
5252

53+
/**
54+
* Path of abandoned token
55+
*/
56+
const MODULE_ABANDONEDCART_TOKEN = 'abandoned/loadquote_token';
57+
5358
/**
5459
* Path of base module settings
5560
*/

Queue/Processor/AbandonedCartProcessor.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AbandonedCartProcessor extends AbstractQueueProcessor
4242
*/
4343
protected $_storeManager;
4444

45+
4546
/**
4647
* CategoryImport constructor.
4748
*
@@ -90,6 +91,8 @@ protected function _processAbandoned($storeId)
9091
{
9192
$this->firstdate = $this->helperData->getConfig(Data::MODULE_FIRST_DATE, $storeId);
9293
$this->customergroups = $this->helperData->getConfig(Data::MODULE_ABANDONED_CUSTOMER_GROUP, $storeId);
94+
$token = $this->helperData->getConfig(Data::MODULE_ABANDONEDCART_TOKEN, $storeId);
95+
9396
if ($this->customergroups) {
9497
$this->customergroups = explode(",", $this->customergroups);
9598
} else {
@@ -115,14 +118,18 @@ protected function _processAbandoned($storeId)
115118
}
116119

117120
try {
118-
foreach ($collection as $cart) {
121+
foreach ($collection as $quote) {
122+
$tokenNew = $token;//.md5(rand(0, 9999999));
123+
$url = $this->_storeManager->getStore($storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK) . 'mautic/cart/loadquote?id=' . $quote->getEntityId() . '&token=' . $tokenNew;
124+
119125
$customData = [
120-
"email" => $cart->getCustomerEmail(),
121-
"firstname" => $cart->getFirstname(),
122-
"lastname" => $cart->getLastname(),
123-
"tags" => Data::ABANDONED_CART_TAGS
126+
"email" => $quote->getCustomerEmail(),
127+
"firstname" => $quote->getFirstname(),
128+
"lastname" => $quote->getLastname(),
129+
"tags" => Data::ABANDONED_CART_TAGS,
130+
"cart_url" => $url
124131
];
125-
$customer = $this->helperData->getCustomerById($cart->getCustomerId());
132+
$customer = $this->helperData->getCustomerById($quote->getCustomerId());
126133
if (!$this->helperData->isAyncApi()) {
127134
$this->mauticContact->exportCustomer($customer, $customData);
128135
} else {
@@ -131,7 +138,6 @@ protected function _processAbandoned($storeId)
131138
$this->helperData->encodeData($data)
132139
);
133140
}
134-
135141
}
136142
} catch (\Exception $e) {
137143
//log exception at here

etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
<field id="*/general/enabled">1</field>
168168
</depends>
169169
</field>
170-
<field id="loadquote_token" type="text" sortOrder="45" showInWebsite="1" showInStore="1" showInDefault="1" translate="label comment">
170+
<field id="loadquote_token" type="text" sortOrder="20" showInWebsite="1" showInStore="1" showInDefault="1" translate="label comment">
171171
<label>Load Quote Token</label>
172172
<comment><![CDATA[<span>Please enter some random characters in "Quote Token" field, save config, and use this URL in looad adbandoned cart. The load quote url as this: http://your_domain/mautic/cart/loadquote?id=[QUOTE_ID]&token=[QUOTE_TOKEN] .]]></comment>
173173
</field>

0 commit comments

Comments
 (0)