Waverider Systems

Perlshop 4 Gift Certificate Package Version 1.3

Contents


Overview

This plugin requires Perlshop 4.2.07 or later.

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.

This software package comes with three software components:

  1. The Gift Certificate command line utility program (ps_giftcert_util.pl).
  2. The Gift Certificate library module (PS_GiftCert.pm).
  3. The Gift Certificate plugin program (ps_plugins_giftcert.pl).

This package includes three HTML files:

  1. A basic "Buy a Gift Certificate" catalog page.
  2. A basic "Redeem a Gift Certificate" catalog page.
  3. A basic PSDBI catalog page used to preview a new gift certificate prior to placing it in a shopping cart.

This package includes three Email Template files:

  1. An HTML version of the email sent to the gift certificate recipient.
  2. A plain-text version of the email sent to the gift certificate recipient.
  3. The plain-text email sent to the gift certificate buyer.

This package includes three sample background images to use with gift certificate email:

  1. cert1.jpg - Grey scrollwork
  2. cert2.jpg - Blue scrollwork
  3. cert3.jpg - Green scrollwork

Installing the Gift Certificate Software

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

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

  3. Place the ps_plugin_giftcert.pl file into the same web server directory as your perlshop.cgi file.

  4. Give the ps_plugin_giftcert.pl file the same file permissions as your perlshop.cgi file.

  5. Place the PS_GiftCert.pm file into the same web server directory as your perlshop.cgi file.

  6. Give the PS_GiftCert.pm file the same file permissions as your perlshop.cgi file.

  7. Place the giftcertbuy.html and giftcertredeem.html files into your normal catalog directory. Give these files the same permissions as your other catalog files. Customize these files to match the needs of your store.

  8. Place the giftcertpreview.html file into your catalog/psdbi directory. Give this file the same permissions as your other catalog/psdbi files. Customize this file to match the needs of your store.

  9. Create a new directory called 'plugins' under your main CGI directory (your main CGI is the directory that already contains your 'customers' and 'orders' directories). Give the 'plugins' directory the same file permissions as the 'customers' directory. This directory will be used to hold data files used by the various plugins you are using.

  10. Create a new directory called 'giftcert' under the 'plugins' directory. Give this new directory the same permissions as the 'plugins' directory. This directory will be used to hold data files specific to the Gift Certificate plugin.

  11. Place the giftcertemail.html file into the 'plugins/giftcert' directory. Give this file the same permissions as your ps.cfg file. This file contains the text of the email that will be sent to the gift certificate recipient when you have HTML email enabled. Customize this file to match the needs of your store.

  12. Place the giftcertemail.txt file into the 'plugins/giftcert' directory. Give this file the same permissions as your ps.cfg file. This file contains the text of the email that will be sent to the gift certificate recipient when you are sending email as normal plain text. Customize this file to match the needs of your store.

  13. Place the giftcertissued.txt file into the 'plugins/giftcert' directory. Give this file the same permissions as your ps.cfg file. This file contains the text of the email that will be sent to the gift certificate buyer. Customize this file to match the needs of your store.

  14. Examine the three sample gift certificate background images. Place the one you wish to use in your web server images directory. The selected image file is referenced in the 'giftcertemail.html' file.

  15. Add the Gift Certificate plugin to the plugin registration table in your ps.cfg file.

Adding this Plugin to the Plugin Registration Table:

Example plugin registration table before adding the Gift Certificate plugin:

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

Example plugin registration table after adding the Gift Certificate plugin:

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

    'giftcert' =>
    {
        'program'       =>    'ps_plugin_giftcert.pl',
        'module'        =>    'PS_GiftCert.pm',
        'event'         =>    '.*',
        'display'       =>    'yes',

        'cert_dir'      =>    'plugins/giftcert',
        'cert_html'     =>    'giftcertemail.html',
        'cert_issued'   =>    'giftcertissued.txt',
        'cert_plain'    =>    'giftcertemail.txt',

        'redeem_action' =>    'thispage',
        'redeem_page'   =>    'giftcertredeem.html',

        'cc_webmaster'  =>    'no',

        'init'          =>    'no'
    }
);

Optional ps.cfg Gift Certificate Plugin Configuration Settings:

'cert_dir'
This is the directory used to contain the various email template files used by this plugin. The default setting of 'plugins/giftcert' should work correctly for all platforms.

'cert_html'
This setting contains the name of the HTML email template file that is used to generate the email that is sent to the gift certificate recipient. This template will only be used if Perlshop has been configured to send email in HTML format. This file is expected to be in the directory indicated by the 'cert_dir' setting. This file contains Perlshop DBI commands. On-line documentation is available from the Waverider Systems web site.

'cert_plain'
This setting contains the name of the plain-text email template file that is used to generate the email that is sent to the gift certificate recipient. This template will be used as the alternate plain-text email body when HTML email is enabled, and will also be used when Perlshop is configured for plain-text email. This file is expected to be in the directory indicated by the 'cert_dir' setting. This file contains Perlshop DBI commands. On-line documentation is available from the Waverider Systems web site.

'cert_issued'
This setting contains the name of the plain-text email template file that is used to genreate the email that is sent to the gift certificate buyer. This file is expected to be in the directory indicated by the 'cert_dir' setting. This file contains Perlshop DBI commands. On-line documentation is available from the Waverider Systems web site.

'redeem_action'
Set this value to 'thispage' to enable the display of the gift certificate redemption link on shopping cart display screen. Leave this value out if you want to disable this feature. No other values are supported for this setting.

'redeem_page'
This is the name of the catalog page that will be loaded when the redemption offer link is clicked on.

'cc_webmaster'
The allowed values for this setting are 'yes' and 'no'. If set to yes, a copy of the gift certificate email will be sent to the webmaster address specified in the ps.cfg file.


Creating the Database Tables

This plugin requires two database tables in order to operate. The first of these tables, called ps_gift_cert, records information about each gift certificate issued. The second table, called ps_gift_cert_log, keeps a historical record of events associated with each gift certificate.

The ps_gift_cert table is expected to have the following form:

create table ps_gift_cert
(
	cert_id          varchar(40),
	timestamp        timestamp,
	status           varchar(10),
	amount           float,
	purchase_order   varchar(40),
	purchase_name    varchar(40),
	purchase_email   varchar(40),
	recipient_name   varchar(40),
	recipient_email  varchar(40),
	recipient_order  varchar(40),
	note             varchar(250),
	activator        varchar(40)
)
The table fields are defined as follows:

'cert_id'
This is a unique identifier used to identify a gift certificate. This identifier will be of the form "orderid-number", where "orderid" is the order ID number used to purchase the gift certificate, and "number" is a randomly generated six digit value.

'timestamp'
This is the date and time that the certificate was generated.

'status'
This is the current status of the gift certificate. This will be one of the following values:
'created' - This means the certificate has been created, but not yet purchased.
'issued' - This means the certificate has been purchased and issued to the recipient.
'used' - This means the certificate has been assigned to a shopping cart, but that the certificate has not yet been fully used.
'closed' - This certificate has been all used up.

'amount'
This is the current monetary value of the certificate. This is assigned by the buyer, and will be reduced each time the certificate is used.

'purchase_order'
This is the Perlshop order number under which the certificate was purchased.

'purchase_name'
This is the name of the certificate buyer, as taken from their Perlshop customer data.

'purchase_email'
This is the email address of the certificate buyer, as taken from their Perlshop customer data.

'recipient_name'
This is the name of the certificate recipient, as given by the certificate buyer.

'recipient_email'
This is the email address of the certificate recipient, as given by the certificate buyer.

'recipient_order'
This is the Perlshop order number that this certificate was last applied to by the recipient.

'note'
This is the gift certificate note provided by the buyer.

'activator'
This is the unique gift certificate activiation string generated by the plugin when the certificate was created.


The ps_gift_cert_log table is expected to have the following form:

create table ps_gift_cert_log
(
	cert_id     varchar(40),
	timestamp   timestamp,
	description varchar(120)
)
The table fields are defined as follows:

'cert_id'
This is a unique identifier used to identify a gift certificate. This identifier will be of the form "orderid-number", where "orderid" is the order ID number used to purchase the gift certificate, and "number" is a randomly generated six digit value.

'timestamp'
This is the date and time of the log entry.

'description'
This is the text of the log entry. A log entry will be made for each gift certificate when any of the following events takes place:
- Gift certificate creation
- Gift certificate purchase
- Gift certificate activated and assigned to a shopping cart
- Gift certificate used, some value remains for use on a later purchase
- Gift certificate all used up
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=giftcert
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_giftcert_util.pl CREATEDB

Once created, the database tables can be cleared from the web server command line using this command:

ps_giftcert_util.pl CLEARDB


A Note for Stores that use a CSV Database:

Due to limitations inherant to the Perl DBD::CSV library, all table column values will be stored as varchar(40) values.


Using the Order Gift Certificate Plugin

Once added to the ps.cfg file, this plugin will automatically be used by Perlshop 4. This plugin is complex, and integrates itself into Perlshop at many levels.

Using the Gift Certificate Utility Program

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

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

Usage: ps_giftcert_util.pl command [file] {file}
    where command is:
        CREATEDB    - Creates ps_gift_cert and ps_gift_cert_log tables.
        CLEARDB     - Delete all content from both tables.
        report      - Generates a status report


The database tables can be created from the web server command line using this command:

ps_giftcert_util.pl CREATEDB


Once created, the database tables can be cleared from the web server command line using this command:

ps_giftcert_util.pl CLEARDB


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

ps_giftcert_util.pl report

Using the Plugin Self-Test

This plugin can execute a basic internal self-test. The results of this self-test are reported as a part of the Perlshop self-test action:
http://www.yoururl.com/yourcgipath/perlshop.cgi?action=selftest

Sample Files

Sample Catalog HTML Files

There are three sample catalog HTML files included with this software package:

'giftcertbuy.html'
This is a standard Perlshop catalog page file. It contains an example of using the Gift Certificate plugin to purchase a gift certificate. You should customize the cosmetic appearance of this page to suit the needs of your store. The names of the form fields used to call the plugin should not be changed. Each of the plugin form fields are detailed in a later section of this document.

'giftcertredeem.html'
This is a standard Perlshop catalog page file. It contains an example of using the Gift Certificate plugin to redeem a gift certificate. You should customize the cosmetic appearance of this page to suit the needs of your store. The names of the form fields used to call the plugin should not be changed. Each of the plugin form fields are detailed in a later section of this document.

'giftcertpreview.html'
This is a PSDBI catalog page file. It is used to present a preview of a gift certificate prior to adding it to a shopping cart. You should customize the cosmetic appearance of this page to suit the needs of your store. The PSDBI SQL statements and template variables used in this page should not be changed.

Sample Email Template Files:

There are three sample email template files included with this software package:

'giftcertemail.html'
This is the HTML email template file that is used to generate the email that is sent to the gift certificate recipient. This template will only be used if Perlshop has been configured to send email in HTML format. This file is expected to be in the directory indicated by the 'cert_dir' setting. This file contains Perlshop DBI commands. On-line documentation is available from the Waverider Systems web site.

'giftcertemail.txt'
This is the plain-text email template file that is used to generate the email that is sent to the gift certificate recipient. This template will be used as the alternate plain-text email body when HTML email is enabled, and will also be used when Perlshop is configured for plain-text email. This file is expected to be in the directory indicated by the 'cert_dir' setting. This file contains Perlshop DBI commands. On-line documentation is available from the Waverider Systems web site.

'giftcertissued.txt'
This is the plain-text email template file that is used to genreate the email that is sent to the gift certificate buyer. This file is expected to be in the directory indicated by the 'cert_dir' setting. This file contains Perlshop DBI commands. On-line documentation is available from the Waverider Systems web site.


The Gift Certificate External Plugin API

This section details the use of the Gift Certificate plugin when it is used as an external plugin. To make this type of plugin call, the Perlshop "action" parameter must be set to "plugin", and the "plugin" parameter must be set to "giftcert".

Plugin parameter 1:
This value determines which mode of operation is being requested of the plugin. Legal values are "create" and "use".

Plugin parameter 2:
This is the current Order ID number.

Plugin parameter 3:
This is the value to use for the Perlshop "thispage" parameter on subsequent pages.


When plugin parameter 1 is set to "create", the other plugin parameters are used as follows:

Plugin parameter 4:
This is the full name of the intended gift certificate recipient.

Plugin parameter 5:
This is the email address of the intended gift certificate recipient.

Plugin parameter 6:
This is the amount of the gift certificate.

Plugin parameter 7:
This is the text of the gift certificate note.


When plugin parameter 1 is set to "use", the other plugin parameters are used as follows:

Plugin parameter 4:
This is the email address of the intended gift certificate recipient.

Plugin parameter 5:
This is the email address used to buy the gift certificate.

Plugin parameter 6:
This is the gift certificate number.

Plugin parameter 7:
This is the gift certificate activation code.


Installing the Perlshop Office Gift Certificate Tools

  1. Place the PSO_GiftCert.pm file into the same web server directory as your psoffice.cgi file.
  2. Give this file the same permissions as your perlshop.cgi file.
  3. Add the Perlshop Office Gift Certificate plugin to the plugin registration table in your pso.cfg file.

%office_tool_plugins =
(
	# Gift Certificate Log report
	'gift_cert_log'	=>
	{
		'label'		=>	'Gift Certificate Log Report',
		'module'	=>	'PSO_GiftCert.pm'
	},

	# Gift Certificate report
	'gift_cert_report'	=>
	{
		'label'		=>	'Gift Certificate Use Report',
		'module'	=>	'PSO_GiftCert.pm'
	}
);

Using the Perlshop Office Gift Certificate DBI Tools

Once installed, these tools will be displayed in the Tools menu of Perlshop Office.

Gift Certificate Log

This report lists all Gift Certificate activity for your web site. Data can be sorted by Certificate ID, Log Time, or Activity Type. Each Gift Certificate can be tracked back to the order that purchased them, and to the order(s) that used them.

Gift Certificate Report

This report lists all Gift Certificates purchased on your web site. Data can be sorted by Purchase Time, Certificate ID, Certificate Status, Amount Remaining, Purchase Invoice ID, Recipient Name, or Activation Code.