yaroslawww / laravel-quick-checkout
Create simple checkout process using only session.
1.0.0
2021-11-03 16:19 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2
- orchestra/testbench: ^6.21
- phpunit/phpunit: ^9.5
- psalm/plugin-laravel: ^1.5
- vimeo/psalm: ^4.10
This package is auto-updated.
Last update: 2024-10-26 16:30:31 UTC
README
Installation
Install the package via composer:
composer require yaroslawww/laravel-quick-checkout
You can publish the config file with:
php artisan vendor:publish --provider="QuickCheckout\ServiceProvider" --tag="config"
Usage
Example usage:
public function addToCart(Course $course) {
/** @var \QuickCheckout\Cart $cart */
$cart = \QuickCheckout\Checkout::cart()->purge()
->withLineItem($course->toCheckoutProduct(), 2)
->withLineItem(new Product('My other product', 123), 4)
->putToSession();
// ... response or redirect
}
public function showCheckout(Course $course) {
/** @var \QuickCheckout\Cart $cart */
$cart = \QuickCheckout\Checkout::cart()->fromSession();
// ... response or redirect
}
Model configuration:
use Illuminate\Database\Eloquent\Model;
use QuickCheckout\Contracts\UsedAsCheckoutProduct;
use QuickCheckout\Eloquent\AsCheckoutProduct;
class Course extends Model implements UsedAsCheckoutProduct
{
use AsCheckoutProduct;
// ...
}