Skip to content

Commit

Permalink
Added the minimum amount of changes to allow plugin to work on Presta…
Browse files Browse the repository at this point in the history
…Shop 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
  • Loading branch information
ZaDarkSide committed Jan 16, 2024
1 parent 594210d commit 108b7e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions prestashop8.x/controllers/admin/AdminTawktoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -163,7 +163,7 @@ public function ajaxProcessRemoveWidget()
}
}

die(Tools::jsonEncode(array('success' => true)));
die(json_encode(array('success' => true)));
}


Expand Down Expand Up @@ -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)));
}
}
4 changes: 2 additions & 2 deletions prestashop8.x/tawkto.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 108b7e3

Please sign in to comment.