NAME

Handel::Order - Module to manipulate order records

SYNOPSIS

my $order = Handel::Order->new({
    id => '12345678-9098-7654-322-345678909876'
});

my $iterator = $order->items;
while (my $item = $iterator->next) {
    print $item->sku;
    print $item->price;
    print $item->total;
};

DESCRIPTION

Handel::Order is a component for maintaining simple order records.

While Handel::Order subclasses Class::DBI, it is strongly recommended that you not use its methods unless it's absolutely necessary. Stick to the documented methods here and you'll be safe should I decide to implement some other data access mechanism. :-)

CONSTRUCTOR

There are three ways to create a new order object. You can either pass a hashref into new containing all the required values needed to create a new order record or pass a hashref into load containing the search criteria to use to load an existing order or set of orders.

You may also pass an already existing Handel::Cart object into new instead of a hash of search critera.

Handel::Order->new(\%data) =item Handel::Order->new(Handel::Cart)
my $order = Handel::Order->new({
    shopper => '10020400-E260-11CF-AE68-00AA004A34D5',
    id => '111111111-2222-3333-4444-555566667777'
});
Handel::Order->load([\%filter, $wantiterator])
my $order = Handel::Order->load({
    id => 'D597DEED-5B9F-11D1-8DD2-00AA004ABD5E'
});

You can also omit \%filter to load all available orders.

my @orders = Handel::Order->load();

In scalar context load returns a Handel::Order object if there is a single result, or a Handel::Iterator object if there are multiple results. You can force load to always return an iterator even if only one cart exists by setting the $wantiterator parameter to RETURNAS_ITERATOR.

my $iterator = Handel::Order->load(undef, RETURNAS_ITERATOR);
while (my $item = $iterator->next) {
    print $item->sku;
};

See Handel::Contstants for the available RETURNAS options.

A Handel::Exception::Argument exception is thrown if the first parameter is not a hashref.

AUTHOR

Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/