escolalms / cart
Escola Headless LMS Cart
Installs: 14 156
Dependents: 13
Suggesters: 1
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=7.4
- escolalms/auth: ^0 >=0.1.86
- escolalms/categories: ^0 >=0.1.21
- escolalms/core: ^1.2
- escolalms/files: ^0
- escolalms/payments: ^0 >=0.2.0
- escolalms/tags: ^0 >=0.1.14
- escolalms/templates: ^0 >=0.2.5
- laravel/framework: >=8.0
- maatwebsite/excel: ^3.1
- treestoneit/shopping-cart: ^1.4
Requires (Dev)
- barryvdh/laravel-ide-helper: ^2.10
- escolalms/courses: ^0
- nunomaduro/collision: >=5.5
- nunomaduro/larastan: >=0.7.6
- orchestra/testbench: >=7.0
- phpunit/phpunit: ^9.0
- dev-main / 0.x-dev
- 0.4.78
- 0.4.77
- 0.4.76
- 0.4.75
- 0.4.74
- 0.4.73
- 0.4.72
- 0.4.71
- 0.4.70
- 0.4.69
- 0.4.68
- 0.4.67
- 0.4.66
- 0.4.65
- 0.4.64
- 0.4.63
- 0.4.62
- 0.4.61
- 0.4.60
- 0.4.59
- 0.4.58
- 0.4.57
- 0.4.56
- 0.4.55
- 0.4.54
- 0.4.53
- 0.4.52
- 0.4.51
- 0.4.50
- 0.4.49
- 0.4.48
- 0.4.47
- 0.4.46
- 0.4.45
- 0.4.44
- 0.4.43
- 0.4.42
- 0.4.41
- 0.4.40
- 0.4.39
- 0.4.38
- 0.4.37
- 0.4.36
- 0.4.35
- 0.4.34
- 0.4.33
- 0.4.32
- 0.4.31
- 0.4.30
- 0.4.29
- 0.4.28
- 0.4.27
- 0.4.26
- 0.4.25
- 0.4.24
- 0.4.23
- 0.4.22
- 0.4.21
- 0.4.20
- 0.4.19
- 0.4.18
- 0.4.17
- 0.4.16
- 0.4.15
- 0.4.14
- 0.4.13
- 0.4.12
- 0.4.11
- 0.4.10
- 0.4.9
- 0.4.8
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.20
- 0.3.19
- 0.3.18
- 0.3.17
- 0.3.16
- 0.3.15
- 0.3.14
- 0.3.13
- 0.3.12
- 0.3.11
- 0.3.10
- 0.3.9
- 0.3.8
- 0.3.7
- 0.3.6
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.19
- 0.1.18
- 0.1.17
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-feature/attach-productable
- dev-qunabu-patch-1
- dev-feature/WELLMS-389
This package is auto-updated.
Last update: 2024-10-24 08:00:49 UTC
README
Purpose
This package lets you manage user Shopping Cart, and defines what is a buyable Product (and what are Productables, that is sellable things), that can be then added to the Cart. This package also lets your users create Orders and buy content of their Carts.
Installation
composer require escolalms/cart
php artisan migrate
php artisan db:seed --class="EscolaLms\Cart\Database\Seeders\CartPermissionSeeder"
Dependencies
This package depends on EscolaLms/Payments package for creating and processing Payments for Orders.
Usage
Product
EscolaLms\Cart\Models\Product
is a Model that represents abstract buyable thing that can be added to Cart and bought. Product by itself has no additional functionality than being bought and assigned to Users.
Products consist of one (Single type products) or more (Bundle type products) Productables - that is, Models representing concrete things that are sold in your (LMS) application, for example Courses. Productables must implement Productable interface.
Productable
EscolaLms\Cart\Contracts\Productable
interface defines how Model representing sellable things behave and which methods and relations they must contain.
Defining Productables
To create (and sell) Products, you need to define Productables. A Productable is a Model implementing EscolaLms\Cart\Models\Contracts
interface (and possibly using EscolaLms\Cart\Contracts\ProductableTrait
). After adding this interface to your Model, you need to call EscolaLms\Cart\Facades\Shop::registerProductableClass(Productable::class)
in one of your Service Providers boot method. This will enable using this Productable Model as a (part of) Product which can then be sold.
Shop Facade
Shop Facade wraps EscolaLms\Cart\Services\ProductService
giving access to methods related to registering Productables and managing Products.
Cart Model
EscolaLms\Cart\Models\Cart
is a model representing User Cart. Every User can have one active (existing) Cart at given time.
To create Cart (or retrieve current active Cart) for a given user, you need to call EscolaLms\Cart\Services\ShopService::cartForUser($user)
method.
Cart Manager
Cart and its content is managed using EscolaLms\Cart\Services\CartManager
class instance attached to that Cart, instead of manipulating Cart object directly.
CartManager
is used by EscolaLms\Cart\Services\ShopService
(and you probably don't need to use it directly, as methods in ShopService represent all sensible use cases).
Shop Service
Shop Service contains functionality related to managing Cart content (adding/removing Products), and purchasing Cart (storing Cart data as an Order and processing payment flow).
Endpoints
All the endpoints are defined in .
Tests
Run ./vendor/bin/phpunit
to run tests. See tests directory as it's a quite good starting point for understanding how this package works.
Especially pay attention to tests/Mocks directory, as it represents core concepts of Productable and use of Productable Trait & Interface.
Events
EscolaLms\Cart\Events\AbandonedCartEvent
- emited when scheduled job finds a non-empty Cart older than 24 hoursEscolaLms\Cart\Events\OrderCancelled
- emited after payment processing is cancelled, which marks Order as cancelledEscolaLms\Cart\Events\OrderCreated
- emited when new Order is createdEscolaLms\Cart\Events\OrderPaid
- emited after order was paidEscolaLms\Cart\Events\ProductableAttached
- emited after Productable is attached to an User (for example after Product containing that Productable is attached to User, or admin endpoints for managing Productable attachments is used)EscolaLms\Cart\Events\ProductableDetached
- analogous to ProductableAttachedEscolaLms\Cart\Events\ProductAddedToCart
- emitted when Product is added to CartEscolaLms\Cart\Events\ProductAttached
- emitted when Product is attached to User (after buying it or adding it using admin endpoint)EscolaLms\Cart\Events\ProductBought
- emited after Product is bought by UserEscolaLms\Cart\Events\ProductDetached
- analogous to ProductAttachedEscolaLms\Cart\Events\ProductRemovedFromCart
- analogous to ProductAdded
Listeners
EscolaLms\Cart\Listeners\PaymentSuccessListener
- this listener handles marking Orders as Paid after a Payment created for given Order is marked as Paid (listens toEscolaLms\Payments\Events\PaymentSuccess
event)
How to use this on frontend
Admin panel
Left menu
List of Products
Creating/editing Product
List of Orders
Details of Order
Permissions
Permissions are defined in Enum and seeded in Seeder.
Roadmap. Todo. Troubleshooting
- ???