Holds an array reference of Interchange::Cart::Cost items.
When called without arguments returns an array reference of all costs associated with the object. Costs are ordered according to the order they were applied.
Returns the sum of the objects "costs" added to its subtotal.
Removes all the costs previously applied (using apply_cost). Used typically if you have free shipping or something similar, you can clear the costs.
This method also calls "clear_total".
Returns an element of the array of costs for the object by its index. You can also use negative index numbers, just as with Perl's core array handling.
Returns the number of cost elements for the object.
Returns all of the cost elements for the object as an array (not an arrayref).
Sets the cost at $index to <$cost>.
predicate on "total".
Apply cost to object. "apply_cost" is a generic method typicaly used for taxes, discounts, coupons, gift certificates, etc.
NOTE: This method also calls "clear_total".
Example: Absolute cost
Uses absolute value for amount. Amount 5 is 5 units of currency used (i.e. $5).
$cart->apply_cost(amount => 5, name => 'shipping', label => 'Shipping');
Example: Relative cost
Uses percentage instead of value for amount. Relative is a boolean value (0/1).
Add 19% German VAT:
amount => 0.19, name => 'tax', label => 'VAT', relative => 1
Add 10% discount (negative amount):
amount => -0.1, name => 'discount', label => 'Discount', relative => 1
Example: Inclusive cost
Same as relative cost, but it assumes that tax was included in the subtotal already, and only displays it (19% of subtotal value in example). Inclusive is a boolean value (0/1).
$cart->apply_cost(amount => 0.19, name => 'tax', label => 'Sales Tax', relative => 1, inclusive => 1);
Returns particular cost by position or by name.
Example: Return tax value by name
Returns value of the tax (absolute value in your currency, not percentage)
Example: Return tax value by position
Returns the cost that was first applied to subtotal. By increasing the number you can retrieve other costs applied.
To install Interchange6, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.