NAME
Handel::Cart::Item - Module representing an indivudal shopping cart line item
VERSION
$Id: Item.pm 60 2005-01-10 02:18:33Z claco $
SYNOPSIS
use Handel::Cart::Item;
my $item = Handel::Cart::Item->new({
sku => '1234',
price => 1.23,
quantity => 1
});
$cart->add($item);
DESCRIPTION
Handel::Cart::Item
is used in two main ways. First, you can create new line items and add them to an existing cart object:
use Handel::Cart::Item;
my $item = Handel::Cart::Item->new({
sku => '1234',
price => 1.23,
quantity => 1
});
$cart->add($item);
Second, the items
method of any valid Handel::Cart
object returns a collection of Handel::Cart::Item
objects:
my @items = $cart->items;
foreach (@items) {
print $_->sku;
};
CONSTRUCTOR
You can create a new Handel::Cart::Item
object by call the new
method:
my $item = Handel::Cart::Item->new({
sku => '1234',
price => 1.23,
quantity => 1
});
$item->quantity(2);
print $item->total;
This is a lazy operation. No actual item record is created until the item object is passed into the carts add
method.
METHODS
$item->sku
Returns or sets the sku (stock keeping unit/part number) for the cart item.
$item->quantity
Returns or sets the quantity the cart item.
$item->price
Returns or sets the price for the cart item.
$item->total
Returns the total price for the cart item. This is really just quantity*total and is provided for convenience.
$item->description
Returns or sets the description for the cart item.
SEE ALSO
AUTHOR
Christopher H. Laco
CPAN ID: CLACO
cpan@chrislaco.com
http://today.icantfocus.com/blog/