NAME
Template::Plugin::Handel::Checkout - Template Toolkit plugin for checkout processing
SYNOPSIS
[% USE Handel.Checkout %]
[% IF (checkout = Handel.Checkout.create(order => 'A2CCD312-73B5-4EE4-B77E-3D027349A055')) %]
[% checkout.process %]
[% FOREACH message IN checkout.messages %]
[% message.text %]
[% END %]
[% END %]
DESCRIPTION
Template::Plugin::Handel::Checkout
is a TT2 (Template Toolkit 2) plugin for Handel::Checkout
. It's API is exactly the same as Handel::Checkout
with a few minor exceptions noted below.
Since new
is used by TT2 to load plugins, Handel::Checkouts new
can be accesed using create
.
Starting in version 0.08
, Handel::Constants
are now imported into this module automatically. This removes the need to use Template::Plugin::Handel::Constants
seperately when working with carts.
[% USE hc = Handel.Constants %]
[% cart = hc.create(...) %]
[% cart.type(hc.CHECKOUT_PHASE_INITIALIZE) %]
CAVEATS
Template Toolkit
handles method params in a smart fashion that allows you to pass named parameters into methoda and it will convert them into HASH references.
For example:
[% checkout.method(name1=val1, name2=val2, otherarg);
is turned into:
checkout->method(otherarg, {name1=>val1, name2=>val2});
Unfortunatly, it looks like TT2 reverses the @ARGS order during translation. This causes problems with Handel::Order::load
and items
as they expect ($hashref, $wantiterator)
instead.
Do to this, it is recommended that you always use the same explicit form as you would use when calling Handel::Checkout
when calling create
and items
:
[% checkout.method({name1=>val1, name2=>val2}, $wantiterator) %]
CONSTRUCTOR
Unlike using Handel::Checkout
to create a new checkout object using new
, Template::Plugin::Handel::Checkout
takes a slightly different approach to checkout objects. Because USE
ing in TT2 calls new
, we first USE
or create a new Template::Plugin::Handel::Checkout
object then create
to return a new checkout object.
new
This returns a new Handel.Checkout object. This is used internally when loading TT2 plugins and should not be used directly.
METHODS
create(\%options)
[% USE Handel.Checkout %]
[% IF (checkout = Handel.Checkout.create({
order => '12345678-9876-5432-1234-567890987654'})) %]
[% order.process %]
...
[% END %]
SEE ALSO
Template::Plugin::Handel::Constants, Handel::Constants, Handel::Checkout, Template::Plugin
AUTHOR
Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/