From c2c1331231e772aa4ce58127f1a2fe1525c4e701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Wed, 19 Apr 2023 22:06:25 +0200 Subject: [PATCH 1/6] Update README.md --- README.md | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5f4b849..1075025 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,44 @@ # Tag Concierge PrestaShop Module Free This extension pushes standard eCommerce information – **GA4 Commerce and UA Enhanced eCommerce compatible** – to GTM Data Layer. Once this information is available in your GTM workspace you can plug in and use any tool available, even if you are unsure which tool you need or would like to use. -![image](https://user-images.githubusercontent.com/18583662/232718044-5496a26e-553c-4231-bba8-ddbec06e0c55.png) +

+ +

GTM setup can be cumbersome and time-consuming – this extension comes with packaged presets for 4 main tools in the market that allow you to set up and run the integration in few simple steps without creating every single GTM Variable and Trigger yourself. -![gif](https://user-images.githubusercontent.com/18583662/232718426-4fec6b72-7bba-4b48-be29-00a438385847.gif) +

+ +

Tag Concierge integrates your PrestaShop shop with a GTM container. It can work with existing GTM installation and allows injecting the GTM snippets in the settings. -![image](https://user-images.githubusercontent.com/18583662/232718949-ea27f1d3-06d0-45e6-9d2e-b10e6df2c78d.png) +

+ +

The extension starts to work without any additional installation. Once it is activated and GTM is embedded in the website, it starts to emit eCommerce events to the GTM dataLayer. Those events are compatible with the newest GA4 format but can be adapted to different tools, including UA and Facebook Pixel. -![image](https://user-images.githubusercontent.com/18583662/232719076-bb557af4-abae-4e30-a3e2-220a48f96c8e.png) +

+ +

-![image](https://user-images.githubusercontent.com/18583662/232719118-9a17b117-3de5-49a3-8834-f5bad1fe2d3d.png) +

+ +

From there, virtually any integration can be achieved through GTM and the same data from your shop can be sent out to any analytical or optimization tool. But to make it easier, the extension comes with **packaged GTM presets** that can be imported into GTM workspace to enable dataflow to specific tool in few simple steps without creating every single GTM Tag, Variable, and Trigger manually. -![image](https://user-images.githubusercontent.com/18583662/232719541-3ca2bb80-dbd9-4773-a215-81a046c48a7d.png) +

+ +

That’s it. With the help of the extension and packaged presets, you can start analyzing and optimizing your PrestaShop shop in almost no time. -![image](https://user-images.githubusercontent.com/18583662/232719590-bd041a18-cfcc-44a3-88a1-0911314f7911.png) +

+ +

See [**our documentation**](https://tagconcierge.com/tag-concierge-for-prestashop) for the list of all supported events. From 0cfb3f1d50bb66e9c05636bb84fa083914e8804c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Wed, 19 Apr 2023 22:27:11 +0200 Subject: [PATCH 2/6] Update LICENSE.md --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 26b7187..baa55ef 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -2023 Handcraft Byte +2023 Tag Concierge NOTICE OF LICENSE From 81a552639b52f0cb3a11fcaf5812823cc8af15b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Fri, 2 Jun 2023 14:33:48 +0200 Subject: [PATCH 3/6] p24 module compat --- src/Controller/AjaxController.php | 2 +- src/Hook/Event/Browser/PurchaseHook.php | 45 ++++++++++++++++++- .../display_before_body_closing_tag.tpl | 2 +- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/Controller/AjaxController.php b/src/Controller/AjaxController.php index 6a36a2d..43f1c8e 100644 --- a/src/Controller/AjaxController.php +++ b/src/Controller/AjaxController.php @@ -21,7 +21,7 @@ public function postProcess() ob_end_clean(); header('Content-Type: application/json'); - $this->ajaxDie(json_encode($response, JSON_THROW_ON_ERROR, 512)); + $this->ajaxDie(json_encode($response)); } private function getCart(): array diff --git a/src/Hook/Event/Browser/PurchaseHook.php b/src/Hook/Event/Browser/PurchaseHook.php index dab90f8..cec571b 100644 --- a/src/Hook/Event/Browser/PurchaseHook.php +++ b/src/Hook/Event/Browser/PurchaseHook.php @@ -9,11 +9,16 @@ class PurchaseHook extends AbstractHook { + private $eventFired = false; + /** @var array */ public const HOOKS = [ Hooks::DISPLAY_ORDER_CONFIRMATION => [ 'addDataElementInOrderConfirmationPage', ], + Hooks::DISPLAY_BEFORE_BODY_CLOSING_TAG => [ + 'p24Compatibility', + ], ]; public function addDataElementInOrderConfirmationPage(array $data): string @@ -21,9 +26,45 @@ public function addDataElementInOrderConfirmationPage(array $data): string /** @var PrestaShopOrder $orderObject */ $orderObject = $data['order']; - $order = Order::fromOrderObject($orderObject); + return $this->handlePurchaseEvent($orderObject); + } + + public function p24Compatibility(array $data): string + { + $controller = $this->getContext()->controller; + + if (null === $controller) { + return ''; + } + + $controllerClass = get_class($controller); + + if ('Przelewy24paymentConfirmationModuleFrontController' !== $controllerClass) { + return ''; + } + + $orderId = PrestaShopOrder::getIdByCartId($this->getContext()->cart->id); + + if (false === $orderId) { + return ''; + } + + $order = new PrestaShopOrder($orderId); + + return $this->handlePurchaseEvent($order); + } + + private function handlePurchaseEvent(PrestaShopOrder $order): string + { + if (true === $this->eventFired) { + return ''; + } + + $orderModel = Order::fromOrderObject($order); + + $this->getContext()->smarty->assign('tc_order', $orderModel->toArray()); - $this->getContext()->smarty->assign('tc_order', $order->toArray()); + $this->eventFired = true; return $this->module->display( \TagConciergeFree::MODULE_FILE, diff --git a/views/templates/hooks/add_to_cart/display_before_body_closing_tag.tpl b/views/templates/hooks/add_to_cart/display_before_body_closing_tag.tpl index 6db2568..6af8d3b 100644 --- a/views/templates/hooks/add_to_cart/display_before_body_closing_tag.tpl +++ b/views/templates/hooks/add_to_cart/display_before_body_closing_tag.tpl @@ -9,7 +9,7 @@ if (null === tagConcierge.lastPrestashopCartFromResponse) { jQuery.ajax({ type: 'POST', - url: '/index.php?fc=module&module=tag_concierge&controller=ajax&ajax=true', + url: '/index.php?fc=module&module=tagconciergefree&controller=ajax&ajax=true', data: 'action=getCart', async: false, success: function (d) { From dfa1aad0ed1c7f71a9cc0831d5b652f2e6b437ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Fri, 2 Jun 2023 14:34:11 +0200 Subject: [PATCH 4/6] version --- tagconciergefree.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tagconciergefree.php b/tagconciergefree.php index e90380f..92888ae 100644 --- a/tagconciergefree.php +++ b/tagconciergefree.php @@ -41,7 +41,7 @@ public function __construct() { $this->name = 'tagconciergefree'; $this->author = 'Tag Concierge'; - $this->version = '1.0.1'; + $this->version = '1.0.2'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->bootstrap = true; $this->tab = 'advertising_marketing'; From 001fe2b11d0b4ebcb28767a232a3664af67a96ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Fri, 2 Jun 2023 15:10:22 +0200 Subject: [PATCH 5/6] fixes 'empty' hook calling by p24 --- src/Hook/Event/Browser/PurchaseHook.php | 37 +++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Hook/Event/Browser/PurchaseHook.php b/src/Hook/Event/Browser/PurchaseHook.php index cec571b..30bf0b8 100644 --- a/src/Hook/Event/Browser/PurchaseHook.php +++ b/src/Hook/Event/Browser/PurchaseHook.php @@ -9,20 +9,22 @@ class PurchaseHook extends AbstractHook { - private $eventFired = false; - /** @var array */ public const HOOKS = [ Hooks::DISPLAY_ORDER_CONFIRMATION => [ 'addDataElementInOrderConfirmationPage', ], - Hooks::DISPLAY_BEFORE_BODY_CLOSING_TAG => [ + Hooks::DISPLAY_AFTER_BODY_OPENING_TAG => [ 'p24Compatibility', ], ]; public function addDataElementInOrderConfirmationPage(array $data): string { + if (true === $this->isP24ConfirmationPage()) { + return ''; + } + /** @var PrestaShopOrder $orderObject */ $orderObject = $data['order']; @@ -31,15 +33,7 @@ public function addDataElementInOrderConfirmationPage(array $data): string public function p24Compatibility(array $data): string { - $controller = $this->getContext()->controller; - - if (null === $controller) { - return ''; - } - - $controllerClass = get_class($controller); - - if ('Przelewy24paymentConfirmationModuleFrontController' !== $controllerClass) { + if (false === $this->isP24ConfirmationPage()) { return ''; } @@ -56,19 +50,26 @@ public function p24Compatibility(array $data): string private function handlePurchaseEvent(PrestaShopOrder $order): string { - if (true === $this->eventFired) { - return ''; - } - $orderModel = Order::fromOrderObject($order); $this->getContext()->smarty->assign('tc_order', $orderModel->toArray()); - $this->eventFired = true; - return $this->module->display( \TagConciergeFree::MODULE_FILE, 'views/templates/hooks/purchase/display_order_confirmation.tpl' ); } + + private function isP24ConfirmationPage(): bool + { + $controller = $this->getContext()->controller; + + if (null === $controller) { + return false; + } + + $controllerClass = get_class($controller); + + return 'przelewy24paymentconfirmationmodulefrontcontroller' === strtolower($controllerClass); + } } From 94417b50b8e11195d651da24ca3577ce3a4f8150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Frankiewicz?= Date: Fri, 2 Jun 2023 19:12:41 +0200 Subject: [PATCH 6/6] changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d706f43..5d6ab78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Change Log All notable changes to this project will be documented in this file. +## [1.0.2] - 2023-06-02 + +### Added +- support for Przelewy24 payment module + +### Changed + +### Fixed + ## [1.0.1] - 2023-04-19 GTM body snippet should be provided again in module configuration after upgrade.