Package: vouchers
Generated from api/packages/vouchers
Source: api/packages/vouchers · imported version 0.1.22. The sections after the README are extracted from the code on every docs build.
README
Section titled “README”Purpose
Section titled “Purpose”This package lets you define Coupons that can be applied to User Cart before placing an Order, calculating a discount depending on multiple different, configurable rules.
Installation
Section titled “Installation”composer require ulams/vouchersphp artisan migratephp artisan db:seed --class="Ulams\Vouchers\Database\Seeders\VoucherPermissionsSeeder"
Dependencies
Section titled “Dependencies”This package depends (and extends) on Ulams/Cart package and can not be used separately.
Coupon rules
Section titled “Coupon rules”Every coupon defines set of rules that are checked when User tries to add Coupon to Cart. Only if all conditions are met, coupon (discount) can be applied to given Cart content. Some of the conditions work differently depending on type of coupon.
- Min/max amount - cart value must be at least “min” amount, and if cart value is above “max” amount, discount is only calculated as if value was at the “max” level
- Usage limits - coupons can not be used after their global or per user limits are reached
- Exclude promotions - coupon can not be used if products with already discounted price are in the Cart
Types of coupon
Section titled “Types of coupon”This package defines four type of discounts, that represent four separate strategies for calculating discount. There are two types that relate to whole Cart and two types that relate to specified Products.
Fixed Cart amount coupon
Section titled “Fixed Cart amount coupon”Coupon of type Ulams\Vouchers\Enums::CART_FIXED substracts constant amount from total price of Cart. See Ulams\Vouchers\Strategies\CartFixedDiscountStrategy.
- At least one of “included products” must be in Cart
- None of “excluded products” must be in Cart
- At least one of “included categories” must be in Cart
- None of “exclude categories” must be in Cart
Percent Cart amount coupon
Section titled “Percent Cart amount coupon”Coupon of type Ulams\Vouchers\Enums::CART_PERCENT substracts percentage based amount from total price of Cart, but only for Products not in “excluded products” or “excluded categories” list. See Ulams\Vouchers\Strategies\CartPercentDiscountStrategy.
- At least one of “included products” must be in Cart
- At least one of “included categories” must be in Cart
Fixed Product coupon
Section titled “Fixed Product coupon”Coupon of type Ulams\Vouchers\Enums::PRODUCT_FIXED substracts constant amount from Product price, but only once per unique Product. Product must be specified in “included products”. See Ulams\Vouchers\Strategies\ProductFixedDiscountStrategy.
Percent Product coupon
Section titled “Percent Product coupon”Coupon of type Ulams\Vouchers\Enums::PRODUCT_FIXED substracts percentage based amount from Product price. Product must be specified in “included products”. See Ulams\Vouchers\Strategies\ProductPercentDiscountStrategy.
How to use Coupon
Section titled “How to use Coupon”Coupon can be added to Cart using POST /api/cart/voucher/ endpoint.
Endpoints
Section titled “Endpoints”All the endpoints are defined in .
Run ./vendor/bin/phpunit to run tests. See tests directory.
Events
Section titled “Events”There are no events emitted by this package.
Listeners
Section titled “Listeners”There are no listeners specified in this package.
How to use this on frontend
Section titled “How to use this on frontend”Admin panel
Section titled “Admin panel”
List of Coupons
Section titled “List of Coupons”
Creating/editing Coupon
Section titled “Creating/editing Coupon”
Permissions
Section titled “Permissions”Permissions are defined in Enum and seeded in Seeder.
Roadmap. Todo. Troubleshooting
Section titled “Roadmap. Todo. Troubleshooting”- endpoint for removing Coupon from Cart
More documentation in the package
Section titled “More documentation in the package”- api/packages/vouchers/ADMIN.md
- api/packages/vouchers/docs/edit.png
- api/packages/vouchers/docs/list.png
- api/packages/vouchers/docs/menu.png
API endpoints
Section titled “API endpoints”| Method | Path | Auth | Action |
|---|---|---|---|
GET |
/api/admin/vouchers |
yes | VouchersAdminApiController@index |
POST |
/api/admin/vouchers |
yes | VouchersAdminApiController@create |
GET |
/api/admin/vouchers/{id} |
yes | VouchersAdminApiController@read |
PUT |
/api/admin/vouchers/{id} |
yes | VouchersAdminApiController@update |
PATCH |
/api/admin/vouchers/{id} |
yes | VouchersAdminApiController@update |
DELETE |
/api/admin/vouchers/{id} |
yes | VouchersAdminApiController@delete |
POST |
/api/cart/voucher |
VouchersApiController@apply |
|
DELETE |
/api/cart/voucher |
VouchersApiController@unapply |
Permissions
Section titled “Permissions”| Permission | Seeded for roles | Constant |
|---|---|---|
coupon_list |
admin | VoucherPermissionsEnum::COUPON_LIST |
coupon_create |
admin | VoucherPermissionsEnum::COUPON_CREATE |
coupon_read |
admin | VoucherPermissionsEnum::COUPON_READ |
coupon_update |
admin | VoucherPermissionsEnum::COUPON_UPDATE |
coupon_delete |
admin | VoucherPermissionsEnum::COUPON_DELETE |
coupon_use |
admin, student, tutor | VoucherPermissionsEnum::COUPON_USE |
Settings
Section titled “Settings”Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).
None.
Events
Section titled “Events”None.
Artisan commands
Section titled “Artisan commands”None.
Scheduled jobs
Section titled “Scheduled jobs”None.
Environment variables read
Section titled “Environment variables read”None.