larasoft / checkout
此包已被废弃,不再维护。没有建议的替代包。
最新版本(dev-master)的此包没有可用的许可证信息。
dev-master
2017-03-03 15:22 UTC
Requires
- illuminate/routing: 5.*
- illuminate/session: 5.*
- illuminate/support: 5.*
This package is not auto-updated.
Last update: 2017-08-01 19:27:12 UTC
README
定义一系列相互连接的屏幕,作为持续过程的一部分。
设置
1) Add the `Larasoft\Ecommerce\Checkout\CheckoutServiceProvider` service provider in app/config/app.php
2) Add the `Checkout` facade (`Larasoft\Ecommerce\Checkout\Facades\Checkout`) to the aliases array in `in app/config/app.php
用法
1) Register a new checkout process using the Checkout facade
2) On the returned object, call `add` to add screens. The add method takes 4 parameters:
a) The URL the screen will respond to
b) The Screen class to use (resolved out the IoC container)
c) An optional additional label to identify the screen
d) Route parameters (uses, as, before, etc.)
例如
$checkout = Checkout::register(['prefix' => 'checkout'], function($checkout)
{
$checkout->add('/', 'LoginOrRegister', 'Start');
$checkout->add('customer', 'CustomerDetails', 'Personal Info');
$checkout->add('address', 'AddressSelection', 'Addresses');
$checkout->add('billing', 'IframeBilling', 'Payment');
$checkout->add('complete', 'OrderCompleted');
});
上述示例将注册以下URL
GET /checkout
POST /checkout
GET /checkout/customer
POST /checkout/customer
GET /checkout/address
POST /checkout/address
GET /checkout/billing
POST /checkout/billing
GET /checkout/complete
POST /checkout/complete
屏幕
屏幕必须扩展 Larasoft\Ecommerce\Checkout\Screen
并必须定义一个 view() 方法。
此外,支持 canSkip
方法,该方法必须返回一个布尔值。如果此方法返回 true
,则屏幕将在过程中被跳过。
处理屏幕
要定义屏幕上的处理操作(当屏幕URL被POST到时触发),屏幕类必须实现 Larasoft\Ecommerce\Checkout\Processable
。此接口要求定义一个 process() 方法。
提供此方法不抛出 Larasoft\Ecommerce\Checkout\ValidationException
实例时,结账过程将在完成时继续到下一个屏幕。