laravel-cart icon indicating copy to clipboard operation
laravel-cart copied to clipboard

Updating and inserting more than one item

Open lstables opened this issue 11 years ago • 1 comments

I have the following which adds to the cart:

      {{ Form::open(['route' => 'cart']) }}
                <input type="hidden" name="path" value="{{ Request::path() }}">
                <input type="hidden" name="image" value="{{ $item->image }}">
                <input type="hidden" name="product" value="{{ $item->name }}">
                <input type="hidden" name="description" value="{{ $item->seo_description }}">
                <input type="hidden" name="qty" value="1">
                <input type="hidden" name="size" value="{{ Session::get('size') }}">
                <input type="hidden" name="colour" value="{{ Session::get('colour') }}">
                <input type="hidden" name="price" value="{{ $item->price }}">
            @if ($item->stock > 0) <button class="btn btn-success">Add to Bag</button>  @else <a href="" class="btn btn-primary">Email us</a> @endif
            {{ Form::close() }}

Then I have this which shows the items of the carts.

  @foreach($items as $item)
                    <tr>
                        <td class="col-sm-8 col-md-6">
                        <div class="media">
                            <span class="thumbnail pull-left"> <img class="media-object" src="/uploads/product-images/{{$item->image}}" style="width: 72px; height: 72px;"> </span>
                            <div class="media-body">
                                <h4 class="media-heading"><a href="{{ $item->path }}">{{ $item->name }}</a></h4>
                                <span>Status: </span><span class="text-success"><strong>In Stock</strong></span>
                            </div>
                        </div></td>
                        <td class="col-sm-1 col-md-1" style="text-align: center">
                        <input type="email" class="form-control" id="exampleInputEmail1" value="1">
                        </td>
                        <td class="col-sm-1 col-md-1 text-center"><strong>&pound;{{ $item->price }}</strong></td>
                        <td class="col-sm-1 col-md-1">
                        </td>
                    </tr>
                    @endforeach
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td>   </td>
                        <td><h5>Subtotal</h5></td>
                        <td class="text-right"><h5><strong>&pound;{{ $item->price }}</strong></h5></td>
                    </tr>
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td>   </td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td>   </td>
                        <td><h3>Total</h3></td>
                        <td class="text-right"><h3><strong>&pound;{{ Cart::total(false) }}</strong></h3></td>
                    </tr>
                    <tr>
                        <td>   </td>
                        <td>   </td>
                        <td><a href="/remove/{{ $item->identifier }}" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Remove</a>
Continue Shopping Checkout

But like I said it only shows one item, but yet the amount in £ is correct. Show what should I be doing? Or what am I doing wrong?

Also a suggestion would be to update the docs a little more with more info like this to show people like me more examples.

lstables avatar Oct 28 '14 18:10 lstables

I think you need to reduce this question to the core problem. There is a lot of cruft in what you have pasted that is not a part of the issue (e,g, table tags) and are just getting in the way of anyone trying to understand your problem.

Being quite old, is this even still an issue? @chrisnharvey - this is from 2014 - does this mean nobody on your team is even looking at this package, let alone maintaining it?

judgej avatar Jul 02 '16 11:07 judgej