Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
resources/data
src
tests
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
USAGE.md
composer.json
phpunit.xml.dist

README.md

Basket

Build Status PHP from Packagist Latest Version License

This package is based on Basket by philipbrown.

Installation

Require this package, with Composer, in the root directory of your project.

$ composer require faustbrian/basket

Coupons

Important: Coupons are applied AFTER Discounts! This means if you have applied a Discount and a Coupon the Coupon will be applied to the discounted price.

Usage

For usage instructions check the USAGE.md.

Create a coupon

$coupon = new Coupon('COUPON_NAME');
$coupon->add(new PercentageDiscount(20));
$coupon->add(new ValueDiscount(new Money(500, new Currency('GBP'))));

Apply a coupon

$basket->products()->first()->coupon($coupon);

Serialize a coupon - Could be used when the coupon needs to be stored.

$coupon->serialize();

Quantity Discount

Grant 20% discount on each Product if more than 5 are purchased

$quantityDiscount = new PercentageDiscount(20);
$coupon->add(new QuantityDiscount(5, $quantityDiscount));

Grant 5£ discount on each Product if more than 5 are purchased

$quantityDiscount = new ValueDiscount(new Money(500, new Currency('GBP')));
$coupon->add(new QuantityDiscount(5, $quantityDiscount));

Testing

$ phpunit

Security

If you discover a security vulnerability within this package, please send an e-mail to hello@brianfaust.me. All security vulnerabilities will be promptly addressed.

Credits

License

MIT © Brian Faust

You can’t perform that action at this time.