Christopher H. Laco > Mango-0.01000_13 > Mango::Provider::Carts

Download:
Mango-0.01000_13.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

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

Arguments: \%options

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

Arguments: \%data

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

Arguments: \%filter

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

Arguments: $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

Arguments: \%filter, \%options

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

Arguments: $cart

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/
syntax highlighting: