please format your question correctly
Error : "strlen(): Argument #1 ($string) must be of type string, array given" with anayarojo/shoppingcart
Dear Sir, I am new in programing and started a Laravel Inertia Ecommerce project. I am trying to add a shopping cart from anayarojo/shoppingcart. But it showing the following error : strlen(): Argument #1 ($string) must be of type string, array given
My controller is as bellow:
public function index(CartService $cartService) { return Inertia::render('Cart/Index', [ 'cartItems' => $cartService->setCartValues()->get('cartItems'), 'cartTaxRate' => $cartService->setCartValues()->get('cartTaxRate'), 'cartSubtotal' => $cartService->setCartValues()->get('cartSubtotal'), 'code' => $cartService->setCartValues()->get('code'), 'discount' => $cartService->setCartValues()->get('discount'), 'newTax' => $cartService->setCartValues()->get('newTax'), 'newSubtotal' => $cartService->setCartValues()->get('newSubtotal'), 'newTotal' => $cartService->setCartValues()->get('newTotal'), 'laterItems' => $cartService->setCartValues()->get('laterItems'), 'laterCount' => $cartService->setCartValues()->get('laterCount'), ]); }
public function store(Request $request)
{
Cart::instance('default')->add(
$request->id,
$request->name,
$request->quantity,
$request->price,
[
'totalQty' => $request->totalQty,
'product_code' => $request->product_code,
'image' => $request->image,
'slug' => $request->slug,
'details' => $request->details
]
)->associate('App\Models\Product');
return redirect()->route('cart.index');
}
And my vue template is as follows : {{ $page.props.cartCount }} item(s) in cart
How can I solve the problem?
Please or to participate in this conversation.