NAME

AxKit::XSP::Handel::Cart - XSP Cart Taglib

SYNOPSIS

Add this taglib to AxKit in your http.conf or .htaccess:

    AxAddXSPTaglib AxKit::XSP::Handel::Cart

Add the namespace to your XSP file and use the tags:

    <xsp:page
         language="Perl"
         xmlns:xsp="http://apache.org/xsp/core/v1"
         xmlns:cart="http://today.icantfocus.com/CPAN/AxKit/XSP/Handel/Cart"
    >

    <cart:load type="1">
        <cart:filter name="id"><request:idparam/></cart:filter>

        <cart:cart>
            <cart>
                <id><cart:id/></id>
                <name><cart:name/></name>
                <description><cart:description/></description>
                <subtotal><cart:subtotal/></subtotal>

                <cart:items>
                    <item>
                        <sku><cart:sku/></sku>
                        <description><cart:description/></description>
                        <quantity><cart:quantity/></quantity>
                        <price><cart:price/></price>
                        <total><cart:total/></total>
                    </item>
                </cart:items>
            </cart>
        </cart:cart>
    </cart:load>

DESCRIPTION

This tag library provides an interface to use Handel::Cart inside of your AxKit XSP pages.

TAG HIERARCHY

    <cart:load>
        <cart:filter>
        <cart:cart>
            <cart:add>
                <cart:description></cart:description>
                <cart:id></cart:id>
                <cart:sku></cart:sku>
                <cart:quantity></cart:quantity>
                <cart:price></cart:price>
            </cart:add>
            <cart:clear/>
            <cart:count/>
            <cart:description/>
            <cart:id/>
            <cart:item>
                <cart:filter>
                <cart:description/>
                <cart:id/>
                <cart:sku/>
                <cart:quantity/>
                <cart:update>
                    <cart:description></cart:description>
                    <cart:sku></cart:sku>
                    <cart:quantity></cart:quantity>
                    <cart:price></cart:price>
                </cart:update>
                <cart:price/>
                <cart:total/>
            </cart:item>
            <cart:items>
                <cart:description/>
                <cart:id/>
                <cart:sku/>
                <cart:quantity/>
                <cart:price/>
                <cart:total/>
            </cart:items>
            <cart:name/>
            <cart:save/>
            <cart:subtotal/>
            <cart:type/>
            <cart:update>
                <cart:description></cart:description>
                <cart:name></cart:name>
                <cart:shopper></cart:shopper>
                <cart:type></cart:type>
            </cart:update>
        </cart:cart>
        <cart:carts>
            <cart:count/>
            <cart:description/>
            <cart:id/>
            <cart:items>
                <cart:description/>
                <cart:id/>
                <cart:sku/>
                <cart:quantity/>
                <cart:price/>
                <cart:total/>
            </cart:items>
            <cart:name/>
            <cart:subtotal/>
            <cart:type/>
        </cart:carts>
    </cart:load>
    <cart:new>
        <cart:description></cart:description>
        <cart:id></cart:id>
        <cart:name></cart:name>
        <cart:shopper></cart:shopper>
        <cart:type></cart:type>
    </cart:new>

TAG REFERENCE

<cart:add>

Adds an a item to the current cart. You can specify the item properties as attributes in the tag itself:

    <cart:add
        description="My New Part"
        id="11111111-1111-1111-1111-111111111111"
        sku="1234"
        quantity="1"
        price="1.23"
    />

or you can add them as child elements:

    <cart:add>
        <cart:description>My New Part</cart:description>
        <cart:id>11111111-1111-1111-1111-111111111111</cart:id>
        <cart:sku>1234</cart:sku>
        <cart:quantity>1</cart:quantity>
        <cart:price>1.23</cart:price>
    </cart:add>

or any combination of the two:

    <cart:add quantity="1">
        <cart:description>My New Part</cart:description>
        <cart:id>11111111-1111-1111-1111-111111111111</cart:id>
        <cart:sku>1234</cart:sku>
        <cart:price>1.23</cart:price>
    </cart:add>

This tag is only valid within the <cart:cart> block. See Handel::Cart for more information about adding parts to the shopping cart.

<cart:cart>

Container tag for the current cart inside of the <cart:load> tag. If load or it's filters load more than one cart, cart will contain only the first cart. If you're looking for loop through multiple carts, try <cart:carts> instead.

    <cart>
        <cart:cart>
            <id><cart:id/></id>
            <name><<cart:name/></name>
            <description><cart:description/></description>
            <subtotal><cart:subtotal/></subtotal>
            <items>
                <cart:items>
                    ...
                </cart:items>
            </items>
        </cart:cart>
    </cart>

<cart:carts>

Loops through all loaded carts inside of the <cart:load> tag.

    <carts>
        <cart:carts>
            <cart>
                <id><cart:id/></id>
                <name><<cart:name/></name>
                <description><cart:description/></description>
                <subtotal><cart:subtotal/></subtotal>
                <items>
                    <cart:items>
                        ...
                    </cart:items>
                </items>
            </cart>
        </cart:carts>
    </carts>

<cart:clear>

Deletes all items in the current shopping cart. This tag is only valid inside of <cart:cart>, not inside of <cart:carts>.

    <cart:carts>
        <cart:clear/>
    </cart:carts>

<cart:count>

Returns the number of items in the current shopping cart. This is valid in both <cart:cart> and <cart:carts>.

    <cart:carts>
        <cart>
            <id><cart:id/></id>
            <name><<cart:name/></name>
            <description><cart:description/></description>
            <subtotal><cart:subtotal/></subtotal>
            <count>cart:count/></count>
        </cart>
    </cart:carts>

<cart:description>

Context aware tag to get or set the description of various other tags. Within <cart:cart> and <cart:carts> it returns the current carts description:

    <cart:cart>
        <description><cart:description/></description>
    </cart:cart>

Within <cart:add> or <cart:update> it sets the current cart or cart items description:

    <cart:cart>
        <cart:update>
            <cart:description>My Updated Cart Description</cart:description>
        </cart:update>

        <cart:add>
            <cart:description>My New SKU Description</cart:description>
        </cart:add>

        <cart:item sku="1234">
            <cart:update>
                <cart:description>My Updated SKU Description</cart:description>
            <cart:update>
        <cart:item>
    </cart:cart>

<cart:filter>

Adds a new name/value pair to the filter used in <cart:load>, <cart:delete>, and <cart:item>. Pass the name of the pair in the name atttribute and the value between the start and end filter tags:

    <cart:load type="0">
        <cart:filter name="shopper">12345678-9098-7654-3212-345678909876</cart:filter>

        <cart:delete>
            <cart:filter name="sku">sku1234</cart:filter>
        <cart:delete>
    </cart:load>

If the same attribute is specified in a filter, the filter takes precedence.

    <cart:load type="0">
        <!-- type == 0 -->
        <cart:filter name="type">1</cart:filter>
        <!-- type == 1 -->
    </cart:load>

You can supply as many filters as needed.

    <cart:load>
        <cart:filter name="type">0</cart:filter>
        <cart:filter name="shopper">12345678-9098-7654-3212-345678909876</cart:filter>
    </cart:load>

<cart:id>

Context aware tag to get or set the record id within various other tags. In <cart:cart>, <cart:carts>, <cart:item>, and <cart:items> it returns the record id for the object:

    <cart:cart>
        <id><cart:id/></id>
        <cart:items>
            <item>
                <id><cart:id/></id>
            </item>
        </cart:items>
    </cart:cart>

Within <cart:delete>, and <cart:new> it sets the id value used in the operation specified:

    <cart:cart>
        <cart:delete>
            <cart:id>11111111-1111-1111-1111-111111111111</cart:id>
        </cart:delete>
    </cart:cart>
    ...
    <cart:new>
        <cart:id>11112222-3333-4444-5555-6666777788889999</cart:id>
        <cart:name>New Cart</cart:name>
    </cart:new>

It cannot be used within <cart:update> and will die if you try updating the record ids.

<cart:items>

Loops through all items in the current cart:

    <cart:cart>
        <items>
            <cart:items>
                <item>
                    <sku><cart:sku/></sku>
                    <description><cart:description/></cart:description>
                    <sku><cart:sku/></sku>
                    <quantity><cart:quantity/></quantity>
                    <price><cart:price/></price>
                    <total><cart:total/></total>
                </item>
            </cart:items>
        </items>
    </cart:cart>

<cart:load>

Load a specified shopping cart. You can pass filter name/value pairs as attributes or you can use <cart:filter<gt> to add them within load:

    <cart:load type="1">
        <cart:filter name="shopper">12345678-9098-7654-3212-345678909876</cart:filter>
    </cart:load>

load must be a top level tag within it's declared namespace. It will die otherwise.

<cart:name>

Context aware tag to get or set the name within various other tags. In <cart:cart>, or <cart:carts> it returns the name for the object:

    <cart:cart>
        <name><cart:name/></name>
        ...
    </cart:cart>

Within <cart:update> and <cart:new> it sets the name value used in the operation specified:

    <cart:cart>
        <cart:update>
            <cart:name>My Updated Cart Name</cart:name>
        </cart:update>
    </cart:cart>
    ...
    <cart:new>
        <cart:name>New Cart</cart:name>
    </cart:new>

<cart:new>

Creates a new shopping cart using the supplied attributes and child tags:

    <cart:new type="1">
        <cart:id>22222222-2222-2222-2222-222222222222</cart:id>
        <cart:shopper><request:shopper/></cart:shopper>
        <cart:name>New Cart</cart:name>
    </cart:new>

The child tags take precedence over the attributes of the same name. load must be a top level tag within it's declared namespace. It will die otherwise.

<cart:price>

Context aware tag to get or set the price of a cart item. In <cart:add> and <cart:update> it sets the price:

    <cart:cart>
        <cart:add>
            <cart:price>1.24</cart:price>
        </cart:add>
    </cart:cart>

In <cart:item> and <cart:items> it returns the price for the cart item:

    <cart:cart>
        <cart>
            <items>
                <cart:items>
                    <item>
                        <price><cart:price/></price>
                    </item>
                </cart:items>
            </items>
        </cart>
    </cart:cart>

<cart:quantity>

Context aware tag to get or set the quantity of a cart item. In <cart:add> and <cart:update> it sets the quantity:

    <cart:cart>
        <cart:add>
            <cart:quantity>1.24</cart:quantity>
        </cart:add>
    </cart:cart>

In <cart:item> and <cart:items> it returns the quantity for the cart item:

    <cart:cart>
        <cart>
            <items>
                <cart:items>
                    <item>
                        <quantity><cart:quantity/></quantity>
                    </item>
                </cart:items>
            </items>
        </cart>
    </cart:cart>

<cart:update>

Updates the current cart values:

    <cart:cart>
        <cart:update>
            <cart:name>My Updated Cart Name</cart:update>
        <cart:update>
    </cart:cart>

update is only valid within <cart:cart> and <cart:item>. <cart:id> is not valid withing an update statement.

<cart:save>

Saves the current cart by setting its type to CART_TYPE_SAVED:

    <cart:cart>
        <cart:save/>
    </cart:cart>

save is only valid in <cart:cart>.

<cart:sku>

Context aware tag to get or set the sku of a cart item. In <cart:add> and <cart:update> it sets the su:

    <cart:cart>
        <cart:add>
            <cart:sku>sku1234</cart:sku>
        </cart:add>
    </cart:cart>

In <cart:item> and <cart:items> it returns the sku for the cart item:

    <cart:cart>
        <cart>
            <items>
                <cart:items>
                    <item>
                        <sku><cart:sku/></sku>
                    </item>
                </cart:items>
            </items>
        </cart>
    </cart:cart>

<cart:subtotal>

Returns the subtotal of the items in the current cart:

    <cart:cart>
        <subtotal><cart:subtotal/></subtotal>
    </cart:cart>

<cart:total>

Returns the total of the current cart item:

    <cart:cart>
        <cart>
            <items>
                <cart:items>
                    <item>
                        <total><cart:total/></total>
                    </item>
                </cart:items>
            </items>
        </cart>
    </cart:cart>

<cart:type>

Context aware tag to get or set the type within various other tags. In <cart:cart>, or <cart:carts> it returns the type for the object:

    <cart:cart>
        <type><cart:type/></type>
        ...
    </cart:cart>

Within <cart:update> and <cart:new> it sets the type value used in the operation specified:

    <cart:cart>
        <cart:update>
            <cart:type>1</cart:type>
        </cart:update>
    </cart:cart>
    ...
    <cart:new>
        <cart:type>1</cart:type>
    </cart:new>

TAG RECIPES

AUTHOR

    Christopher H. Laco
    CPAN ID: CLACO
    cpan@chrislaco.com
    http://today.icantfocus.com/blog/