From 4a1ffe122e654d1a5799e298b6ea0dfb50c403cd Mon Sep 17 00:00:00 2001 From: kevin-DL Date: Sat, 23 Apr 2022 18:36:50 +0100 Subject: [PATCH] Update Cart.php JSON encode to fix issue with data not being saved properly in the content column --- src/Cart.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cart.php b/src/Cart.php index fc33359..95e1a06 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -646,7 +646,7 @@ class Cart $this->getConnection()->table($this->getTableName())->insert([ 'identifier' => $identifier, 'instance' => $instance, - 'content' => serialize($content), + 'content' => json_encode(serialize($content)), 'created_at' => $this->createdAt ?: Carbon::now(), 'updated_at' => Carbon::now(), ]); @@ -676,7 +676,7 @@ class Cart $stored = $this->getConnection()->table($this->getTableName()) ->where(['identifier'=> $identifier, 'instance' => $currentInstance])->first(); - $storedContent = unserialize(data_get($stored, 'content')); + $storedContent = unserialize(json_decode(data_get($stored, 'content'))); $this->instance(data_get($stored, 'instance')); @@ -741,7 +741,7 @@ class Cart $stored = $this->getConnection()->table($this->getTableName()) ->where(['identifier'=> $identifier, 'instance'=> $instance])->first(); - $storedContent = unserialize($stored->content); + $storedContent = unserialize(json_decode($stored->content)); foreach ($storedContent as $cartItem) { $this->addCartItem($cartItem, $keepDiscount, $keepTax, $dispatchAdd);