spatie / checkout by spatie

A simple e-commerce checkout helper for Laravel 5
698
40
4
Package Data
Maintainer Username: spatie
Maintainer Contact: freek@spatie.be (Freek Van der Herten)
Package Create Date: 2014-08-23
Package Last Update: 2022-07-02
Home Page: https://spatie.be/opensource/laravel
Language: PHP
License: MIT
Last Refreshed: 2024-03-23 03:06:40
Package Statistics
Total Downloads: 698
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 40
Total Watchers: 4
Total Forks: 4
Total Open Issues: 0

Remember the order id in the checkout process of a webshop

Build Status Latest Stable Version StyleCI License

When building a checkout process for a webshop, you likely discovery a need to store the id of a newly created order in a session. This Laravel package provides a clean way to work the order id in the session.

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

The best postcards will get published on the open source page on our website.

Installation

This package can be installed through Composer.

composer require spatie/checkout

There is a service provider you can make use of.


// app/config/app.php

'providers' => [
    '...',
    'Spatie\Checkout\CheckoutServiceProvider'
];

This package also comes with a facade, which provides an easy way to use this class.


// app/config/app.php

'aliases' => array(
	...
	'Checkout' => 'Spatie\Checkout\CheckoutFacade',
)

Usage

You can store the order id using this method:

    Checkout::setCurrentOrderId($yourOrderId);

Your order id will be stored in Laravel's session store.

You can retrieve the value with:

    Checkout::getCurrentOrderId();

These methods are also provided:

  • Checkout::clearCurrentOrderId(): Forget the previously stored value.
  • Checkout::isCurrentOrderId($orderId): Convenient method to determine if the given orderId is equal to the value stored with the previous call to setCurrentOrderId.