Skip to content

Commit a87bbe1

Browse files
authored
Merge pull request #59 from Guisardo/patch-1
Avoid array to string error on homepage with cart
2 parents ef7cd10 + 95eac65 commit a87bbe1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

classes/Hook/HookDisplayFooter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use PrestaShop\Module\Ps_Googleanalytics\Handler\GanalyticsJsHandler;
2828
use PrestaShop\Module\Ps_Googleanalytics\Wrapper\ProductWrapper;
2929
use Ps_Googleanalytics;
30+
use RecursiveArrayIterator;
31+
use RecursiveIteratorIterator;
3032
use Tools;
3133

3234
class HookDisplayFooter implements HookInterface
@@ -70,6 +72,11 @@ public function run()
7072
$gacart['quantity'] = abs($gacart['quantity']);
7173
$gaScripts .= 'MBG.removeFromCart(' . json_encode($gacart) . ');';
7274
}
75+
} elseif (is_array($gacart)) {
76+
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($gacart));
77+
foreach ($it as $v) {
78+
$gaScripts .= $v;
79+
}
7380
} else {
7481
$gaScripts .= $gacart;
7582
}

0 commit comments

Comments
 (0)