GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Interchange6::Role::Costs(3) User Contributed Perl Documentation Interchange6::Role::Costs(3)

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".

Clears "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>.

This method also calls "clear_total".

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:

    $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);

Returns 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.

2016-03-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.