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.
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) )
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'
}
);
http://www.yoururl.com/yourcgipath/perlshop.cgi?action=init_plugin&plugin=collator_dbiNote: 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'.
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