this is my session array of cart application in laravel 6
[cartS] => Array (
[0] => Array (
[pid] => 3
[pname] => Watch
[price] => 500
[qnty] => 5
[pimg] => 3.jpg
)
[1] => Array (
[pid] => 1
[pname] => Mobile case
[price] => 200
[qnty] => 3
[pimg] => 1.jpg
)
)
i have a table in checkout page
i am doing foreach loop so i can access $key => $value of session array
product quantity total_price
------- -------- ------------
item1 2 100 ( here 100 is multipication of price and qunatity)
item2 4 200
item3 2 200
------------------- ------------
total amount 500
-----------i want to display 500 as a total amount----------
here is foreach loop in my checkout.blade.php file
<?php $items = Session::has('cartS') ? Session::get('cartS') : null; ?>
@foreach($items as $key=>$value)
<tr>
<th class="w-50 font-size-14">
{{ucfirst($value['pname'])}}
</th>
<td class="text-right font-size-14">
{{$value['qnty']}}
</td>
<th class="text-right font-size-14">
{{ $value['qnty'] * $value['price'] }}
</th>
</tr>
@endforeach
<h1>your total amount -----------</h1>
Am i doing somthing wrong or i have to display total amount in foreach loop?