Add the method to get cart items as the JSON array.
This commit is contained in:
@@ -56,6 +56,20 @@ class Cart extends Model
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function getItemJSON()
|
||||
{
|
||||
$items = $this->items;
|
||||
$itemJSON = [];
|
||||
|
||||
foreach($items as $item)
|
||||
array_push($itemJSON, [
|
||||
'id' =>$item->uuid,
|
||||
'count'=> $item->count
|
||||
]);
|
||||
|
||||
return $itemJSON;
|
||||
}
|
||||
|
||||
public function getItemIds(): array
|
||||
{
|
||||
return $this->items()->pluck('item_id')->toArray();
|
||||
|
||||
Reference in New Issue
Block a user