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

when add product to card return last item added only #371

Open
TarekRamadan91 opened this issue Dec 21, 2023 · 0 comments
Open

when add product to card return last item added only #371

TarekRamadan91 opened this issue Dec 21, 2023 · 0 comments

Comments

@TarekRamadan91
Copy link

when try to add product to card using this method


    public function addProduct(Request $request)
    {

        $product = Product::findOrFail($request->product_id);

        $data = [
            'id' => $product->id,
            'name' => $product->name,
            'price' => $product->price,
            'quantity' => $request->quantity,
            'attributes' => [
                'image' => $product->image,
            ],
        ];

        Cart::add($data); // Add the new item to the cart

        $cartContent = Cart::getContent(); // Retrieve the updated cart content
        dd($cartContent->toArray()); // Display the updated cart

and try to add another product and make

   $cartContent = Cart::getContent(); // Retrieve the updated cart content
        dd($cartContent->toArray()); // Display the updated cart

its return last item added only not all product in cart !

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