NAME
Mango::Provider::Orders - Provider class for order information
SYNOPSIS
my $provider = Mango::Provider::Orders->new;
my $order = $provider->get_by_id(23);
DESCRIPTION
Mango::Provider::Orders is the provider class responsible for creating, deleting, updating and searching order information.
CONSTRUCTOR
new
Creates a new order provider object. If options are passed to new, those are sent to setup
.
my $provider = Mango::Provider::Orders->new;
See "new" in Mango::Provider for a list of other possible options.
METHODS
create
Creates a new Mango::Order object using the supplied data.
my $order = $provider->create({
user => 23
});
print $order->count;
In addition to using the column names, the following special keys are available:
- user
-
This can be a user id, or a user object for which this order is assigned to.
my $order = $provider->create({ user => $user });
It is recommended that you use this key, rather than setting the foreign key column manually in case it changes later.
delete
Deletes orders from the provider matching the supplied filter.
$provider->delete({
id => 23
});
In addition to using the column names, the following special keys are available:
- user
-
This can be a user id, or a user object for which this order is assigned to.
$provider->delete({ user => $user });
It is recommended that you use this key, rather than setting the foreign key column manually in case it changes later.
get_by_id
Returns a Mango::Order object matching the specified id.
my $order = $provider->get_by_id(23);
Returns undef if no matching order can be found.
search
Returns a list of Mango::Order objects in list context, or a Mango::Iterator in scalar context matching the specified filter.
my @orders = $provider->search({
last_name => 'Alberts'
});
my $iterator = $provider->search({
last_name => 'Alberts'
});
In addition to using the column names, the following special keys are available:
- user
-
This can be a user id, or a user object for which orders are assigned to.
my @carts = $provider->search({ user => $user }); my $carts = $provider->search({ user => $user });
See "search" in Handel::Order for a list of other possible options.
update
Sets the 'updated' column to DateTime->now and saves any changes made to the order back to the underlying store.
my $order = $provider->create(\%data);
$order->number(154325);
$provider->update($order);
SEE ALSO
Mango::Provider, Mango::Order, Handel::Order
AUTHOR
Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/