Coupon Redemption
Copyright © 2000, William Weiland
Overview
Manage coupon addition and redemption functions within a Miva Merchant 2.2x or 3.x storefront with this plugin module.
Initial Setup
Use the Merchant admin upload feature to upload the modules couponrd.mv and cim_coup.mv. As each are uploaded, click the Add button to add them to the mall/domain.

In admin, under your store, click on the link for the System Extension Configuration screen. Assign the CIM Coupon Extension module and Update it to install it in your store.

In admin, under your store, click on the link for the Fulfillment Configuration screen. Assign the Coupon Redemption module and Update it to install it in your store.

Click the link for Coupon Redemption to enter the configuration settings and add coupons.


Configuration Settings
An unlimited number of coupons can be assigned to the store and each identified with a coupon code. Once you have added the module to the store, you can add coupons in the Order Fulfillment section of the admin interface. When you select the Add icon, you will have several input fields to fill in.

Coupon ID
You must enter a unique code for your coupon. This is the code that you will give to customers so they can shop and redeem the coupon. It can be any combination of letters and/or numbers.

Expiration Date
An optional expiration date can be included which will prevent its use if the date has passed. Enter it in the year, month, day format, eg. 20000724 would be July 24, 2000. If you leave this field blank the coupon will never expire. However, you can still delete it manually through the admin interface.

Redemption Value
A flat value OR percentage off the order total is assigned to each coupon. The default is flat value, eg $5.00 off the order total. If you put the % sign in the next input field AFTER the value field, it will calculate the coupon value based on the assigned percent of the order total. Note: only include numbers or decimal in the value field. The %, if used, is entered in the separate field to the right for that purpose. If left blank, the calculation will be based on the raw value of the coupon. See the note below about restricting calculations to specific products.

Minimum Order
Optionally, a coupon can be allowed only when an order total reaches a specific amount. In all cases where a raw value is used, you must make this value equal to or greater than the value of the coupon. If you use the percent calculation, this value can be any value, including zero.

Reduce Tax
Based on your state's tax requirements, the coupon can be designated to reduce the sales tax or not reduce it. For example, in some states, a store coupon reduces the value of products purchased before the sales tax is applied, hence you would want it to reduce tax. The exception to doing this is if your products are likely to be non-taxable, making a coupon reduce tax could result in a negative tax calculation. Another type coupon might be the manufacturer coupon. In some states, manufacturer coupons do not decrease the tax liability. You should determine your state's tax requirements before adding coupons to your store.

Coupon Usage
- multiple times - The coupon can be used at every visit by any customer who shops at your store. This is usually used as a promo to customers, user lists, clubs, etc. They often have a short expiration date to limit their use. A typical usage might be a special holiday sale, eg 10% off everything in the store if used by a specified date. This would eliminate the need for special price groups if the intent is that everybody who has the coupon code can use it.
- only one time for each customer - The coupon can only be used for one visit per customer. When the same customer shops at your store a second time, if he/she uses the same coupon code, it will be rejected. This is probably the most common coupon and is usually used in print ads or as a promo, eg. "$5.00 off on your next visit".
- only one time for a unique coupon code - The coupon can only be used once. Once any customer has used this code, it becomes unavailable for any other purchase. This is often used as a customer relations tool, eg "sorry for the inconvenience, please accept this coupon.....".

Product Code Specificity
You can restrict usage of a coupon in your store so that it can be used only if a specific product is ordered. You can list several product codes, any of which in the basket would make the coupon valid if the other requirements are met. Caution: do not put the same product code in the list more than one time. Leaving the product code blank means that customers do not have to order a specific product as long as they meet the other requirements the store owner has specified. If you check the box to the left of the product code list, and are using the percentage discount, only those products in the code list will be used in the calculation. If you do not check the box, the percentage will be applied against the order total.

Deleting Expired Coupons
Expired coupons can be removed from the database (to cut down on disk usage) one at a time or in mass. In admin, you can either put a check in the remove column and select update or select purge expired coupons, then select update.


Editing Requirements (skip if using the OpenUI)
If you are using the Miva Merchant User Interface (mmui) you will need to make some very simple edits to the core files. Be sure to do that with a text editor (NO WYSIWYG editors) such as Programmer's File Editor (PFE) so as not to damage the mv files. ALWAYS BACKUP your unmodified mv files in case you make a mistake.

1) In the mmui.mv file MMUI_Order_ShippingPaymentSelection function add the following code just above the last table tag in the function. That last table contains the Continue submit button.
<MvDO FILE = "{g.Module_Root$'modules/fulfill/couponrd.mv'}" NAME = "l.couponask" VALUE = "{Coupon_Prompt()}">

2) In the mmui.mv file MMUI_Order_Payment function add the following just above the last table tag (same as you did in the previous instruction).
<MvDO FILE = "{g.Module_Root$'modules/fulfill/couponrd.mv'}" NAME = "l.couponpass" VALUE = "{Coupon_Pass()}">


Merchant Version 2.22-2.24 Special Note
This module can be used in both Merchant version 3.x and 2.2x. However, there is a serious, fatal error bug in one of the Miva Corp supplied core files in versions 2.22, 2.23, and 2.24. Hence, in order to use this module in those versions of Merchant, you will need to edit the db.mv file. Be sure you make a backup of this file in case you make an error. In the db.mv file, locate the function BasketCharge_DeleteAll_Module. The MvWHILE loop needs to be closed with </MvWHILE> instead of </MvIF>. If you don't fix this, you will get an error upon checkout. Again, this bug has been fixed in Merchant 2.25 and 3.x so you only need to make the file correction in Merchant 2.22, 2.23, and 2.24.
Customer Interface
Coupon codes are entered at the checkout screen which also displays the shipping and payment selections. Appropriate error messages are displayed when coupons do not meet the usage criteria established by the store owner. When the shopper enters a coupon code at checkout that is not valid based on the criteria you establish, he/she will see an error message just below the coupon code input when the checkout form is re-displayed after the validation step. Customers are allowed to redeem one coupon per order.

Additionally, if customers go back to the basket and remove items which previously qualified them for a coupon, then go to checkout, they will not be able to get past the coupon validation step with a coupon not meeting the pre-established criteria.


Historical Review
A historical database, which can be imported and analyzed in database or spreadsheet software, is maintained on all coupons used. The couponuz.dbf can be FTPd to your PC for further analysis in MS Access, MS Excel, or other data management software. This could be useful in determining which coupons bring you the most activity.