yaroslawww/laravel-quick-checkout

Create simple checkout process using only session.

1.0.0 2021-11-03 16:19 UTC

This package is auto-updated.

Last update: 2024-11-26 16:41:01 UTC


README

Packagist License Packagist Version Total Downloads Build Status Code Coverage Scrutinizer Code Quality

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;

    // ...
}

Credits

  • Think Studio