NAME
Handel::Cart::Item - Module representing an indivudal shopping cart line item
VERSION
$Id: Item.pm 282 2005-03-04 02:26:59Z 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.
Starting in version 0.12
, price now returns a stringified Handel::Currency object. This can be used to format the price, and hopefully to convert it's currency to another locale in the future.
$item->total
Returns the total price for the cart item. This is really just quantity*total and is provided for convenience.
Starting in version 0.12
, subtotal now returns a stringified Handel::Currency object. This can be used to format the price, and hopefully to convert it's currency to another locale in the future.
$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/