Skip to content

Unable to add items to cart #396

@boateng-ampaw

Description

@boateng-ampaw

I import and add item to the cart in my livewire class component like this

use Cart;

$item = Cart::add([
            'id' => $this->product->id, // inique row ID
            'name' => $this->product->name,
            'price' => $validated['price'],
            'quantity' => $validated['quantity'],
            'attributes' => $validated['_attributes'],
            'associatedModel' => Product::class
        ]);

However, getting the content of the cart like this Cart::getContent() returns empty

Darryldecode\Cart\CartCollection {#1572 ▼ // resources\views/products/index.blade.php
  #items: []
  #escapeWhenCastingToString: false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions