public function getCartItems(Request $request)
 {
     $items = [];
     $total = 0;
     foreach (\Cart::content() as $rowid => $item) {
         $product = \App\Product::find($item['id']);
         $items[] = ['id' => $item['id'], 'name' => $item['name'], 'options' => $item['options'], 'price' => $product->formatPrice($item['price']), 'qty' => $item['qty'], 'rowid' => $item['rowid'], 'subtotal' => $product->formatPrice($item['subtotal']), 'image' => $product->img()->first()];
         $total += $item['subtotal'];
     }
     //dd($items);
     return response()->json(['items' => $items, 'total' => kalFormatPrice($total)]);
 }
Exemple #2
0
function cartItems()
{
    $items = [];
    $total = 0;
    foreach (\Cart::content() as $rowid => $item) {
        $product = \App\Product::find($item['id']);
        $items[] = ['id' => $item['id'], 'name' => $item['name'], 'options' => $item['options'], 'price' => $product->formatPrice($item['price']), 'qty' => $item['qty'], 'path' => $product->fullPath(), 'rowid' => $item['rowid'], 'subtotal' => $product->formatPrice($item['subtotal']), 'image' => $product->img()->first()];
        $total += $item['subtotal'];
    }
    return json_encode(['items' => $items, 'total' => kalFormatPrice($total)]);
}