From 108b7e3f12dc39e13a30b43a425683da97550b9a Mon Sep 17 00:00:00 2001 From: ZaDarkSide <291278+ZaDarkSide@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:00:15 +0200 Subject: [PATCH] Added the minimum amount of changes to allow plugin to work on PrestaShop 8.x tested up to 8.1.3 Tools::jsonDecode was deprecated and removed, using json_decode instead Tools::jsonEncode was deprecated and removed, using json_encode instead Declare TawkTo::getPropertyAndWidget() as static --- .../controllers/admin/AdminTawktoController.php | 12 ++++++------ prestashop8.x/tawkto.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/prestashop8.x/controllers/admin/AdminTawktoController.php b/prestashop8.x/controllers/admin/AdminTawktoController.php index 1c1d46d..6a85975 100644 --- a/prestashop8.x/controllers/admin/AdminTawktoController.php +++ b/prestashop8.x/controllers/admin/AdminTawktoController.php @@ -68,7 +68,7 @@ public function renderView() if (!$displayOpts) { $displayOpts = null; } - $displayOpts = Tools::jsonDecode($displayOpts); + $displayOpts = json_decode($displayOpts); $sameUser = true; // assuming there is only one admin by default $empId = Configuration::get(TawkTo::TAWKTO_WIDGET_USER); @@ -128,13 +128,13 @@ private static function idsAreCorrect($pageId, $widgetId) public function ajaxProcessSetWidget() { if (!Tools::getIsset('pageId') || !Tools::getIsset('widgetId')) { - die(Tools::jsonEncode(array('success' => false))); + die(json_encode(array('success' => false))); } $pageId = Tools::getValue('pageId'); $widgetId = Tools::getValue('widgetId'); if (!self::idsAreCorrect($pageId, $widgetId)) { - die(Tools::jsonEncode(array('success' => false))); + die(json_encode(array('success' => false))); } $currentWidgetKey = TawkTo::TAWKTO_SELECTED_WIDGET; @@ -143,7 +143,7 @@ public function ajaxProcessSetWidget() $userKey = TawkTo::TAWKTO_WIDGET_USER; Configuration::updateValue($userKey, $this->context->employee->id); - die(Tools::jsonEncode(array('success' => true))); + die(json_encode(array('success' => true))); } public function ajaxProcessRemoveWidget() @@ -163,7 +163,7 @@ public function ajaxProcessRemoveWidget() } } - die(Tools::jsonEncode(array('success' => true))); + die(json_encode(array('success' => true))); } @@ -217,6 +217,6 @@ public function ajaxProcessSetVisibility() $key = TawkTo::TAWKTO_WIDGET_OPTS; Configuration::updateValue($key, json_encode($jsonOpts)); - die(Tools::jsonEncode(array('success' => true))); + die(json_encode(array('success' => true))); } } diff --git a/prestashop8.x/tawkto.php b/prestashop8.x/tawkto.php index 830ee8d..d196fc7 100644 --- a/prestashop8.x/tawkto.php +++ b/prestashop8.x/tawkto.php @@ -36,7 +36,7 @@ public function __construct() $this->version = '1.2.3'; $this->author = 'tawk.to'; $this->need_instance = 0; - $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.7'); + $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '8.1.3'); parent::__construct(); @@ -209,7 +209,7 @@ public function getContent() Tools::redirectAdmin($this->context->link->getAdminLink('AdminTawkto')); } - public function getPropertyAndWidget() + public static function getPropertyAndWidget() { $current_widget = Configuration::get(self::TAWKTO_SELECTED_WIDGET); if (empty($current_widget)) {