Waverider Systems

Perlshop 4 Order Collator DBI Package Version 1.3

Contents


Overview

This plugin requires Perlshop 4.2.06 or later, and the Perlshop Database Interface.

This plugin is intended for use by customers that already have the PSDBI package installed. The psdbi.cfg file is used by this plugin to connect to the default database.

Database tables used by this plugin:

Customer data will be stored in a table named ps_customers. This table is expected to have the following form:
create table ps_customers
(
	order_id          varchar(40),
	ip_address        varchar(40),
	date              varchar(40),
	sale_time         varchar(40),

	title             varchar(40),
	first_name        varchar(40),
	last_name         varchar(40),
	company           varchar(40),
	street1           varchar(40),
	street2           varchar(40),
	city              varchar(40),
	state             varchar(40),
	zip               varchar(40),
	country           varchar(40),

	ship_title        varchar(40),
	ship_first_name   varchar(40),
	ship_last_name    varchar(40),
	ship_company      varchar(40),
	ship_street1      varchar(40),
	ship_street2      varchar(40),
	ship_city         varchar(40),
	ship_state        varchar(40),
	ship_zip          varchar(40),
	ship_country      varchar(40),

	email             varchar(40),
	dphone            varchar(40),
	nphone            varchar(40),
	fax               varchar(40),
	ship_type         varchar(40),
	payby             varchar(40),

	card_type         varchar(40),
	card_no           varchar(40),
	card_exp          varchar(40),

	subtotal          float,
	tax               float,
	shipping          float,
	grand_total       float,
	discount          float,
	cod               float,
	handling          float,
	rebate            float
)
Order data will be stored in a table named ps_orders. This table is expected to have the following form:
create table ps_orders
(
	order_id    varchar(40),
	item_id     varchar(40),
	name        varchar(40),
	price       float,
	quantity    float,
	weight      float,
	shiptype    varchar(40),
	taxtype     varchar(40),
	option1     varchar(40),
	option2     varchar(40),
	option3     varchar(40)
)


Installing the Collator DBI Software

Installing the Collator DBI Plugin

  1. Place the PS_Collator_DBI.pm file into the same web server directory as your perlshop.cgi file.
  2. Give the PS_Collator_DBI.pm file the same file permissions as your perlshop.cgi file.
  3. Add the Order Collator DBI plugin to the plugin registration table in your ps.cfg file.

Example plugin registration table before adding the Collator plugin:

%plugins =
(
    # Calendar example plugin
    'calendar'  => 
    {
        'program'    => 'ps_plugin_gencal.pl'
    }
);

Example plugin registration table after adding the Collator plugin:

%plugins =
(
    # Calendar example plugin
    'calendar' => 
    {
        'program' =>     'ps_plugin_gencal.pl'
    },

    'collator_dbi' =>
    {
        'module'          =>    'PS_Collator_DBI.pm',
        'event'           =>    'after_place_order',
        'display'         =>    'no',

	'customers_table' =>    'ps_customers',
	'orders_table'    =>    'ps_orders',

	'init'            =>    'no'
    }
);

Installing the Collator DBI Plugin Web Server Utility Program:

  1. Place the ps_collator_dbi_util.pl file into your account main directory.
    This is not a CGI program, and is intended for web server command line use only.

  2. Give the ps_collator_dbi_util.pl file the permission settings required to prevent any other user from accessing it.

Creating the Database Tables

There are two ways to create the database tables used by this plugin.

Creating the database tables through Plugin Self-Initialization

The plugin database tables can be created using the Perlshop Plugin Initialization action:
http://www.yoururl.com/yourcgipath/perlshop.cgi?action=init_plugin&plugin=collator_dbi
Note: This action will only be allowed if the init setting in the plugin information to 'yes'. Once the database tables have been created, you should set the init setting in the plugin information to 'no'.


Creating the database tables using the web server command line utility:

The database tables can be created from the web server command line using this command:
ps_collator_dbi_util.pl CREATEDB



Using the Order Collator DBI Plugin

Once added to the ps.cfg file, this plugin will automatically be used by Perlshop 4. As each new order is closed, the information from the customer and order files will be copied into two tables in your PSDBI database.

Optional features:

  1. By default, all customer information is stored in table ps_customers. If you want to change this, then you can alter the value of the customers_table setting in the plugin information.

  2. By default, all customer information is stored in table ps_orders. If you want to change this, then you can alter the value of the orders_table setting in the plugin information.

Using the Order Collator DBI Web Server Utility Program

The collator utility program is intended for use via the command line. It is not a CGI program, and is not intended for use over the web.

This program is run from the command line using the command "ps_collator_dbi_util.pl". If this command is entered with no command line arguments, the following usage instructions will be displayed:

Usage: ps_collator_dbi_util.pl command [file] {file}
    where command is:
        CREATEDB    - Creates ps_customers and ps_orders tables.
        CLEARDB     - Delete all content from both tables.
        CUSTOMERS   - Populates customer table with the data from the given customer file(s).
        ORDERS      - Populates order table with the data from the given order file(s).
        report      - Generates a status report


The CREATEDB command will create the new database tables required to support this plugin. This command is run by entering the following command:

ps_collator_dbi_util.pl CREATEDB


The CLEARDB command will delete all records from the database tables required to support this plugin. This command is run by entering the following command:

ps_collator_dbi_util.pl CLEARDB


Existing customer data files can be transcribed into the database using the following command:

ps_collator_dbi_util.pl CUSTOMERS 


This is an example of loading a single customer file:

ps_collator_dbi_util.pl CUSTOMERS /home/myaccount/cgi-bin/customers/548723560


This is an example of loading all customer files:

ps_collator_dbi_util.pl CUSTOMERS /home/myaccount/cgi-bin/customers/*


Existing order data files can be transcribed into the database using the following command:

ps_collator_dbi_util.pl ORDERS 


This is an example of loading a single order file:

ps_collator_dbi_util.pl ORDERS /home/myaccount/cgi-bin/customers/548723560


This is an example of loading all order files:

ps_collator_dbi_util.pl ORDERS /home/myaccount/cgi-bin/customers/*


A simple database table dump can be achieved using the following command:

ps_collator_dbi_util.pl report