mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
Update Cart.php
JSON encode to fix issue with data not being saved properly in the content column
This commit is contained in:
@@ -646,7 +646,7 @@ class Cart
|
|||||||
$this->getConnection()->table($this->getTableName())->insert([
|
$this->getConnection()->table($this->getTableName())->insert([
|
||||||
'identifier' => $identifier,
|
'identifier' => $identifier,
|
||||||
'instance' => $instance,
|
'instance' => $instance,
|
||||||
'content' => serialize($content),
|
'content' => json_encode(serialize($content)),
|
||||||
'created_at' => $this->createdAt ?: Carbon::now(),
|
'created_at' => $this->createdAt ?: Carbon::now(),
|
||||||
'updated_at' => Carbon::now(),
|
'updated_at' => Carbon::now(),
|
||||||
]);
|
]);
|
||||||
@@ -676,7 +676,7 @@ class Cart
|
|||||||
$stored = $this->getConnection()->table($this->getTableName())
|
$stored = $this->getConnection()->table($this->getTableName())
|
||||||
->where(['identifier'=> $identifier, 'instance' => $currentInstance])->first();
|
->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'));
|
$this->instance(data_get($stored, 'instance'));
|
||||||
|
|
||||||
@@ -741,7 +741,7 @@ class Cart
|
|||||||
$stored = $this->getConnection()->table($this->getTableName())
|
$stored = $this->getConnection()->table($this->getTableName())
|
||||||
->where(['identifier'=> $identifier, 'instance'=> $instance])->first();
|
->where(['identifier'=> $identifier, 'instance'=> $instance])->first();
|
||||||
|
|
||||||
$storedContent = unserialize($stored->content);
|
$storedContent = unserialize(json_decode($stored->content));
|
||||||
|
|
||||||
foreach ($storedContent as $cartItem) {
|
foreach ($storedContent as $cartItem) {
|
||||||
$this->addCartItem($cartItem, $keepDiscount, $keepTax, $dispatchAdd);
|
$this->addCartItem($cartItem, $keepDiscount, $keepTax, $dispatchAdd);
|
||||||
|
|||||||
Reference in New Issue
Block a user