Francis J. Lacoste > Apache-iNcom-0.09 > Apache::iNcom::OrderManager

Download:
Apache-iNcom-0.09.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.5   Source  

NAME ^

Apache::iNcom::OrderManager - Module responsible for order management.

SYNOPSIS ^

    my $order = $Order->checkout( "order", $Cart, %fdat );
    my $report $Order->order_report( $order );

DESCRIPTION ^

This is the part of the Apache::iNcom framework that is responsible for managing the order process. Once the user is ready to check out, the OrderManager rides in. This module enters the user's order in the database according to an order profile. It can also generate order reports and such.

It is in that module that future development will place links with CyberCash (tm) and other online payment systems.

DATABASE ^

The order should be entered in two tables. One table table contains the global order informations : order no, client's information, status, total, taxes, etc., and another table contains the ordered items.

To make order customizable, the OrderManager uses DBIx::SearchProfiles to insert the information. That design is similar to DBIx::UserDB in that only a few fields are required by the framework and the schema can easily be adapted for application specific needs.

The mandatory fields in the main table are the order_no field, which should be a primary key on the table, and the status field. The status field is used to track the order process.

You may also want to add monetary fields for total, subtotal and for the taxes, shipping and discount informations since that will always be available in the order.

The mandatory fields in the items table is order_no which links the items to the order table. What will be inserted in that table are the cart items, so you may want to use the following fields : price, subtotal, quantity and fields for the discount information.

ORDER PROFILES ^

The order profiles is a file which is C{eval}-ed at runtime. (It is also reloaded whenever it changes on disk. It should return an hash reference which contains the name of a profile associated with an hash reference which may contains the following items :

order_template

The record template that will be used to insert the order informations.

order_item_template

The record template that will be used to insert order items.

order_no

The template query that will be used to generate order number.

taxes_fields

The field names that should be given to the order's taxes. This is an array reference which defaults to [taxes0, taxes1, taxes2...] if there is more than one taxes or [ taxes ] if there is only one taxes.

shipping_fields

The field names that should be given to the order's shipping charges. This is an array reference which defaults to [ shipping0, shipping1, shipping2...] if there more than one shipping charges or [ shipping ] if only one is present.

discount_fields

The field names that should be given to the order's discounts. This is an array reference which defaults to [discount0, discount1, discount2...] if there more than one discount or [ discount ] if only one is present.

item_discount_fields

The field names that should be given to the items' discounts. This is an array reference which defaults to [discount0, discount1, discount2...] if there more than one discount or [ discount ] if only one is present.

    Example of an order profile : 

    {
        order =>
        {
            order_template          => "order",
            order_item_template     => "order_items",
            order_no                => "order_no",
            taxes_fields            => [qw( gst gsp ) ],
        },
    }

INITIALIZATION ^

An object is automatically initialized on each request by the Apache::iNcom framework. It is accessible through the $Order global variable in Apache::iNcom pages.

METHODS ^

checkout ( $name, $cart, $order_data )

This method enter the user order in the database. It takes the following parameters :

$name

The name of the order profile to use.

$cart

The cart that contains the user's order.

$order_data

An hash reference which contains other informations that should be stored with the order. (Like customer's name and address for example.)

The cart is emptied if the checkout is successful. NOTE: This is the only method in the framework that will do an explicit commit to make sure that the order is correctly entered in the database.

The method returns an hash references which contains the order informations.

order_report ( $order, $template )

This method will generate an order report for a particular order. The first parameter is the order as returned by checkout, the second is the template file that should be used. This is a standard Apache::iNcom pages. The report will be generated in the namespace of the calling page, so standard Apache::iNcom globals will be accessible. DONT ABUSE IT. Also the order for which the report is generated will be accessible through the %order global hash.

AUTHOR ^

Copyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

SEE ALSO ^

Apache::iNcom(3) Apache::iNcom::Request(3) Apache::iNcom::CartManager(3)

syntax highlighting: