faustbrian/basket

The missing link between your product pages and your payment gateway

2.0.5 2017-05-03 07:30 UTC

README

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