NAME
Mango::Provider::Carts - Provider class for cart information
SYNOPSIS
my $provider = Mango::Provider::Carts->new;
my $cart = $provider->get_by_id(23);
DESCRIPTION
Mango::Provider::Carts is the provider class responsible for creating, deleting, updating and searching cart information.
CONSTRUCTOR
new
Creates a new cart provider object. If options are passed to new, those are sent to setup
.
my $provider = Mango::Provider::Carts->new;
See "new" in Mango::Provider for a list of other possible options.
METHODS
create
Creates a new Mango::Cart object using the supplied data.
my $cart = $provider->create({
user => 23
});
print $cart->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 cart is assigned to.
my $cart = $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 carts 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 cart 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::Cart object matching the specified id.
my $cart = $provider->get_by_id(23);
Returns undef if no matching cart can be found.
search
Returns a list of Mango::Cart objects in list context, or a Mango::Iterator in scalar context matching the specified filter.
my @carts = $provider->search({
name => 'A%'
});
my $iterator = $provider->search({
name => 'A%'
});
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 carts are assigned to.
my @carts = $provider->search({ user => $user }); my $carts = $provider->search({ user => $user });
See "search" in Handel::Cart for a list of other possible options.
update
Sets the 'updated' column to DateTime->now and saves any changes made to the cart back to the underlying store.
my $cart = $provider->create(\%data);
$cart->name('Favorites');
$provider->update($cart);
SEE ALSO
Mango::Provider, Mango::Cart, Handel::Cart
AUTHOR
Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/