-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Datatrics/1.3.2
1.3.2
- Loading branch information
Showing
25 changed files
with
282 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Datatrics\Connect\Controller\Cart; | ||
|
||
use Magento\Checkout\Model\SessionFactory as Session; | ||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; | ||
use Magento\Framework\App\ResponseInterface; | ||
use Magento\Framework\Controller\Result\Json; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Controller\ResultInterface; | ||
use Datatrics\Connect\ViewModel\PreProcessor; | ||
|
||
/** | ||
* Class Get | ||
* Ajax controller to get queued events | ||
*/ | ||
class Get extends Action implements HttpPostActionInterface | ||
{ | ||
|
||
/** | ||
* @var JsonFactory | ||
*/ | ||
private $resultJsonFactory; | ||
|
||
/** | ||
* @var Session | ||
*/ | ||
private $checkoutSession; | ||
|
||
/** | ||
* @var PreProcessor | ||
*/ | ||
private $preProcessor; | ||
|
||
/** | ||
* Get constructor. | ||
* | ||
* @param Context $context | ||
* @param JsonFactory $resultJsonFactory | ||
* @param Session $checkoutSession | ||
* @param PreProcessor $preProcessor | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
JsonFactory $resultJsonFactory, | ||
Session $checkoutSession, | ||
PreProcessor $preProcessor | ||
) { | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->checkoutSession = $checkoutSession; | ||
$this->preProcessor = $preProcessor; | ||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* @return ResponseInterface|Json|ResultInterface | ||
*/ | ||
public function execute() | ||
{ | ||
$result = $this->resultJsonFactory->create(); | ||
$html = ''; | ||
if ($this->checkoutSession->create()->getCartTrigger()) { | ||
$html = $this->preProcessor->getTrack( | ||
'Datatrics_Connect::cart.phtml', | ||
'cart' | ||
); | ||
} | ||
$this->checkoutSession->create()->setCartTrigger(false); | ||
$result->setData($html); | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Datatrics\Connect\Plugin; | ||
|
||
use Magento\Catalog\Model\Product; | ||
use Magento\Checkout\Model\SessionFactory as Session; | ||
use Magento\Quote\Model\Quote as QuoteModel; | ||
use Magento\Quote\Model\Quote\Item; | ||
|
||
/** | ||
* Class Quote | ||
* Plugin for quote model | ||
*/ | ||
class Quote | ||
{ | ||
const CART_TRIGGER = 'TriggerCart'; | ||
|
||
/** | ||
* @var Session | ||
*/ | ||
private $checkoutSession; | ||
|
||
/** | ||
* Quote constructor. | ||
* | ||
* @param Session $checkoutSession | ||
*/ | ||
public function __construct( | ||
Session $checkoutSession | ||
) { | ||
$this->checkoutSession = $checkoutSession; | ||
} | ||
|
||
/** | ||
* Fire event after item was removed from cart | ||
* | ||
* @param QuoteModel $subject | ||
* @param QuoteModel $result | ||
* @param int $itemId | ||
* | ||
* @return QuoteModel | ||
*/ | ||
public function afterRemoveItem( | ||
QuoteModel $subject, | ||
QuoteModel $result, | ||
int $itemId | ||
) { | ||
$this->checkoutSession->create()->setCartTrigger(true); | ||
return $result; | ||
} | ||
|
||
/** | ||
* Fire event after item was added to the cart (only after post request) | ||
* | ||
* @param QuoteModel $subject | ||
* @param Item $result | ||
* @param Product $product | ||
* | ||
* @return Item | ||
*/ | ||
public function afterAddProduct( | ||
QuoteModel $subject, | ||
Item $result, | ||
Product $product | ||
) { | ||
$this->checkoutSession->create()->setCartTrigger(true); | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright © Magmodules.eu. All rights reserved. | ||
~ See COPYING.txt for license details. | ||
--> | ||
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd"> | ||
<policies> | ||
<policy id="script-src"> | ||
<values> | ||
<value id="datatrics" type="host">*.datatrics.com</value> | ||
</values> | ||
</policy> | ||
<policy id="connect-src"> | ||
<values> | ||
<value id="datatrics_connect" type="host">*.datatrics.com</value> | ||
</values> | ||
</policy> | ||
<policy id="img-src"> | ||
<values> | ||
<value id="www-magmodules" type="host">www.magmodules.eu</value> | ||
<value id="datatrics_image" type="host">*.datatrics.com</value> | ||
</values> | ||
</policy> | ||
</policies> | ||
</csp_whitelist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,4 +82,4 @@ | |
"DATATRICS_PROFILE_STORE_ID_STORE_STORE_ID": true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> | ||
<router id="standard"> | ||
<route id="datatrics" frontName="datatrics"> | ||
<module name="Datatrics_Connect"/> | ||
</route> | ||
</router> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.