|
ATTRIBUTEScostsHolds 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. totalReturns the sum of the objects "costs" added to its "subtotal".METHODSclear_costsRemoves 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". clear_totalClears "total".cost_get($index)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.cost_countReturns the number of cost elements for the object.get_costsReturns all of the cost elements for the object as an array (not an arrayref).cost_set($index, $cost)Sets the cost at $index to <$cost>.This method also calls "clear_total". has_totalpredicate on "total".apply_costApply 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: $cart->apply_cost( amount => 0.19, name => 'tax', label => 'VAT', relative => 1 ); Add 10% discount (negative amount): $cart->apply_cost( 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); costReturns particular cost by position or by name.Example: Return tax value by name $cart->cost('tax'); Returns value of the tax (absolute value in your currency, not percentage) Example: Return tax value by position $cart->cost(0); Returns the cost that was first applied to subtotal. By increasing the number you can retrieve other costs applied.
Visit the GSP FreeBSD Man Page Interface. |