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. 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 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. 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..30bf0b8 100644 --- a/src/Hook/Event/Browser/PurchaseHook.php +++ b/src/Hook/Event/Browser/PurchaseHook.php @@ -14,20 +14,62 @@ class PurchaseHook extends AbstractHook Hooks::DISPLAY_ORDER_CONFIRMATION => [ 'addDataElementInOrderConfirmationPage', ], + Hooks::DISPLAY_AFTER_BODY_OPENING_TAG => [ + 'p24Compatibility', + ], ]; public function addDataElementInOrderConfirmationPage(array $data): string { + if (true === $this->isP24ConfirmationPage()) { + return ''; + } + /** @var PrestaShopOrder $orderObject */ $orderObject = $data['order']; - $order = Order::fromOrderObject($orderObject); + return $this->handlePurchaseEvent($orderObject); + } + + public function p24Compatibility(array $data): string + { + if (false === $this->isP24ConfirmationPage()) { + 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 + { + $orderModel = Order::fromOrderObject($order); - $this->getContext()->smarty->assign('tc_order', $order->toArray()); + $this->getContext()->smarty->assign('tc_order', $orderModel->toArray()); 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); + } } 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'; 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) {