Check https://github.com/Artisanry/Basket to see how the underlying Basket works.
Require this package, with Composer, in the root directory of your project.
$ composer require artisanry/basket
This function should be used when you want to built your "Product"-Objects on your own.
use Artisanry\LaravelBasket\Basket;
get('/', function (Basket $basket) {
// Setup the Basket for UK
$basket = $basket->setup('uuid_for_example', new UnitedKingdom());
// Build a new Product
$product = new Product(1, 'Four Steps to the Epiphany', new Money(1000, new Currency('GBP')), new UnitedKingdomValueAddedTax());
$product->action(function ($product) {
$product->quantity(1);
$product->freebie(false);
$product->taxable(false);
$product->delivery(new Money(500, new Currency('GBP')));
$product->coupon($coupon);
$product->tags(new Collection(['four steps', 'movie', 'cinema']));
$product->discount(new PercentageDiscount(20));
$product->category(new PhysicalBook());
});
// Add a new Product
$basket->add($product);
});
This method should be used if you want to have your "Product"-Objects build by LaravelBasket. It will create the "Product"-Object and build all objects that are required like "Money"-Objects for delivery costs.
use Artisanry\LaravelBasket\Basket;
get('/', function (Basket $basket) {
// Setup the Basket for UK
$basket = $basket->setup('uuid_for_example', new UnitedKingdom());
// Add a new Product
$basket->addQuick(1, 'Four Steps to the Epiphany', 1000, [
'quantity' => 1,
'freebie' => false,
'taxable' => false,
'delivery' => 500,
'coupon' => $coupon,
'tags' => ['four steps', 'movie', 'cinema'];
'discount' => new PercentageDiscount(20),
'category' => new PhysicalBook(),
]);
});
$basket->boot(Jurisdiction $jurisdiction);
$basket->load($identifier);
$basket->products();
$basket->count();
$basket->pick($sku);
$basket->add(Product $product);
$basket->update($sku, Closure $action)
$basket->addQuick($sku, $name, $price, $actions = []);
$basket->updateQuick($sku, $actions = []);
$basket->remove($sku);
$basket->discount(Discount $discount);
$basket->getRate();
$basket->getCurrency();
$basket->getDelivery();
$basket->getDiscount();
$basket->getProductsCount();
$basket->getSubtotal();
$basket->getTaxable();
$basket->getTax();
$basket->getTotal();
$basket->getValue();
$basket->getProducts();
$basket->reconcile();
$ phpunit
If you discover a security vulnerability within this package, please send an e-mail to hello@basecode.sh. All security vulnerabilities will be promptly addressed.
This project exists thanks to all the people who contribute.
Mozilla Public License Version 2.0 (MPL-2.0).