Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Object of class Gloudemans\Shoppingcart\CartItem could not be converted to string (View: C:\Users\Alasco\Desktop\laravel\e_shop\resources\views\livewire\cart-component.blade.php) #656

Open
LepetitHero opened this issue May 5, 2021 · 0 comments

Comments

@LepetitHero
Copy link

LepetitHero commented May 5, 2021

Hi ! I've a new issue from my code.
When I try to add product to the cart, I get this issue.

this the controller

`use Cart;

public function store($product_id, $product_name, $product_price)
{
Cart::add($product_id, $product_name,1, $product_price)->associate('App\Models\Product');
session()->flash('success_message', 'item add in cart');
return redirect()->route('product.cart');
}`

this this the view code
`

            @if (Session::has('success_message'))

                <strong>Success</strong> {{Session::get('success_message')}}

            @endif

            @if (Cart::count() > 0)



            <h3 class="box-title">Products Name</h3>

            <ul class="products-cart">

                @foreach (Cart::content() as $item )

                <li class="pr-cart-item">

                    <div class="product-image">

                        <figure><img src="{{ asset('assets/images/products') }}/{{$item->model->image}}" alt="{{$item->model->name}}"></figure>

                    </div>

                    <div class="product-name">

                        <a class="link-to-product" href="{{route('product.details',['slug'->$item->model->slug])}}">{{$item->model->name}}</a>

                    </div>

                    <div class="price-field produtc-price"><p class="price">${{$item->model->regular_price}}</p></div>

                    <div class="quantity">

                        <div class="quantity-input">

                            <a class="btn btn-increase" href="#"></a>

                            <input type="text" name="product-quatity" value="{{$item->qty}}" data-max="120" pattern="[0-9]*">

                            <a class="btn btn-reduce" href="#"></a>

                        </div>

                    </div>

                    <div class="price-field sub-total"><p class="price">${{$item->subtotal}}</p></div>

                    <div class="delete">

                        <a href="#" class="btn btn-delete" title="">

                            <span>Delete from your cart</span>

                            <i class="fa fa-times-circle" aria-hidden="true"></i>

                        </a>

                    </div`

Please, I need your help. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant