From 8f64be0b5e6171ac27f4ce773afc6a8eb1c469a1 Mon Sep 17 00:00:00 2001 From: Alcino Van Rooyen Date: Thu, 16 Nov 2023 11:55:18 +0000 Subject: [PATCH] fixed json html encoded issue --- 8/pitchprint/pitchprint.php | 16 ++++++++++++---- .../front/ppCartData.tpl => js/cartData.js} | 8 +++----- CHANGELOG.txt | 3 +-- 3 files changed, 16 insertions(+), 11 deletions(-) rename 8/pitchprint/views/{templates/front/ppCartData.tpl => js/cartData.js} (91%) diff --git a/8/pitchprint/pitchprint.php b/8/pitchprint/pitchprint.php index 871e468..ad6030c 100755 --- a/8/pitchprint/pitchprint.php +++ b/8/pitchprint/pitchprint.php @@ -147,7 +147,7 @@ private function updateProducts($params) if ($row['pitchprint_customization']) { if (gettype($row['pitchprint_customization']) === 'object') { - $row['pitchprint_cusotmization'] = json_decode(json_encode($row['pitchprint_customization']), true); + $row['pitchprint_customization'] = json_decode(json_encode($row['pitchprint_customization']), true); } $row['pitchprint_customization']['links'] = []; if (strpos($row['pitchprint_customization']['distiller'], 'io') !== false) { @@ -649,9 +649,17 @@ public function hookDisplayHeader($params) 'afterValidation' => ($this->context->controller->php_self === 'my-account' ? '_fetchProjects' : '_sortCart'), ]; - $this->context->smarty->assign(['ppData' => $ppData]); - - return $this->display(__DIR__, '/views/templates/front/ppCartData.tpl'); + Media::addJsDef( + [ + 'pitchprintCartData' => $ppData, + ] + ); + + $this->context->controller->registerJavascript( + 'module-pitchprint-cart-data', + 'modules/' . $this->name . '/views/js/cartData.js', + ['position' => 'bottom', 'priority' => 199] + ); } } diff --git a/8/pitchprint/views/templates/front/ppCartData.tpl b/8/pitchprint/views/js/cartData.js similarity index 91% rename from 8/pitchprint/views/templates/front/ppCartData.tpl rename to 8/pitchprint/views/js/cartData.js index 0295fdd..832276e 100644 --- a/8/pitchprint/views/templates/front/ppCartData.tpl +++ b/8/pitchprint/views/js/cartData.js @@ -1,4 +1,4 @@ -{* +/** * 2023 PitchPrint * * NOTICE OF LICENSE @@ -21,7 +21,5 @@ * @copyright 2023 PitchPrint Inc * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PitchPrint Inc. -*} - \ No newline at end of file +*/ +var pp_data = pitchprintCartData; \ No newline at end of file diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 442136d..bdfe5f4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,2 +1 @@ -Added get order and design the old way if new way returns nothing. -Also store old designs the new way. \ No newline at end of file +Fixed a bug in the cart, where JSON was html encoded and could not parse properly. \ No newline at end of file