escolalms/cart
Laravel package for EscolaLMS that provides shopping-cart models, migrations, and REST API endpoints for adding products, updating quantities, removing items, and calculating cart totals. Designed to plug into existing product, user, and checkout flows in an e-commerce application.
Install via Composer (composer require escolalms/cart), then publish and run migrations and config (php artisan vendor:publish --provider="EscolaLMS\Cart\Providers\CartServiceProvider"). Start by inspecting routes/api.php for the cart and checkout endpoints, and src/Services/CartService.php for the domain logic. The quickest first use case is adding a product to the cart via the API (POST /api/cart or the package’s equivalent) and retrieving the current cart for an authenticated user. As of 0.4.81, the product/me response now includes a categories array, so any client consuming that endpoint can display category metadata without an extra request.
Use the package’s service layer or facade rather than manipulating cart tables directly. For API-driven flows, authenticate the user and let the package resolve the active cart from the session or user record. When integrating product listings, call the product/me endpoint and rely on the new categories array for filtering or display. For checkout, listen to the package’s cart/order events to hook in payment, inventory, or notification logic. In admin or reporting contexts, reuse the same cart services to avoid duplicating pricing and tax rules. If you need custom product metadata (beyond categories), extend the product resource or add an accessor rather than modifying vendor migrations.
Cart persistence can differ between guest and authenticated users—confirm whether your configuration uses session-backed carts or database carts before assuming cart contents survive login. The new categories array on product/me may trigger additional queries; eager-load categories in any custom product queries to avoid N+1 issues. Watch for product availability and price recalculation when adding items, since cart totals are often recalculated on each request. For debugging, inspect the package’s service bindings and event listeners in the service provider; most behavior can be overridden via config or by binding your own implementation. If you rely on the product/me endpoint, verify that your API resource version matches 0.4.81+ so the categories key is present and not silently omitted by an older cached response.
How can I help you explore Laravel packages today?