NAME

Nitesi::Cart - Cart class for Nitesi Shop Machine

VERSION

CONSTRUCTOR

new

init

Initializer which receives the constructor arguments, but does nothing. May be overridden in a subclass.

items

Returns items in the cart.

subtotal

Returns subtotal of the cart.

total

Returns total of the cart.

add $item

Add item to the cart. Returns item in case of success.

The item is a hash reference which is subject to the following conditions:

sku

Item identifier is required.

name

Item name is required.

quantity

Item quantity is optional and has to be a natural number greater than zero. Default for quantity is 1.

price

Item price is required and a positive number.

remove $sku

Remove item from the cart. Takes SKU of item to identify the item.

clear

Removes all items from the cart.

apply_cost

Apply cost to cart.

Absolute cost:

$cart->apply_cost(amount => 5, name => 'fee', label => 'Pickup Fee');

Relative cost:

$cart->apply_cost(amount => 0.19, name => 'tax', label => 'Sales Tax',
                  relative => 1);

Inclusive cost:

$cart->apply_cost(amount => 0.19, name => 'tax', label => 'Sales Tax',
                   relative => 1, inclusive => 1);

clear_cost

Clear costs.

cost

Returns particular cost by position or by name.

id

Get or set id of the cart. This can be used for subclasses, e.g. primary key value for carts in the database.

name

Get or set the name of the cart.

error

Returns last error.

seed $item_ref

Seeds items within the cart from $item_ref.

AUTHOR

Stefan Hornburg (Racke), <racke@linuxia.de>

LICENSE AND COPYRIGHT

Copyright 2011 Stefan Hornburg (Racke) <racke@linuxia.de>.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.