Docs / Laravel Cart / Livewire / Inertia

Livewire / Inertia

HasCart trait (Livewire)

Add HasCart to any Livewire component to get reactive cart state and proxy methods.

use Wearepixel\Cart\Concerns\HasCart; class CartComponent extends Component { use HasCart; // $cartItems, $cartCount, $cartSubTotal, $cartTotal are auto-populated public function addToCart(int $id, string $name, float $price): void { $this->cartAdd($id, $name, $price, 1); // $cartCount, $cartSubTotal etc. update automatically } }

ShareCartWithInertia (Inertia)

Share cart state on every Inertia response from your HandleInertiaRequests middleware:

use Wearepixel\Cart\Concerns\ShareCartWithInertia; public function share(Request $request): array { return array_merge(parent::share($request), [ 'cart' => fn() => ShareCartWithInertia::data(), ]); }

This shares cart.items, cart.subtotal, cart.total, and cart.count with every page.

Discovery Call

One call.
We'll both know.

An hour to walk through your project, ask the hard questions, and work out honestly if we're the right team for it.

  • One call per day - it gets our full attention
  • Australia's only Laravel Premier Partner
  • Senior engineers only - no juniors on your project
  • Brisbane-based, onshore team

Press Esc to close  ·  B to reopen