We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c0a6ad commit 30c1903Copy full SHA for 30c1903
src/CartService.php
@@ -144,7 +144,15 @@ public function moveSessionToDatabase()
144
if ($this->hasSession() && $this->storage instanceof Model) {
145
$session = \Session::get($this->instanceName);
146
\Session::forget($this->instanceName);
147
- $this->cart = $this->cart->merge($session->toArray());
+ $session->each(function ($item) {
148
+ $cart=$this->cart->where("cartable_id", $item["cartable_id"])->where("cartable_type", $item["cartable_type"])->first();
149
+ if (!is_null($cart)) {
150
+ $item["id"]=$cart["id"];
151
+ $item["quantity"]+=$cart["quantity"];
152
+ $item["price"]=$cart["price"];
153
+ }
154
+ $this->cart->put($item["id"], $item);
155
+ });
156
$this->save();
157
}
158
0 commit comments