This is an old revision of the document!
Coupons using description
1. New Coupon is created automatically on sendmail.php page, only if customer previously completed his order. Customer data (name and e-mail address) on sendmail.php page are taken from DB table, from header record of just completed order. These customer data are stored in hidden fields of “Tell a friend” form. When customer fill out “Tell a friend” form fields with one or more e-mail addresses (up to 10 addresses) and click “Send skjema” button, the number of non-empty e-mail addresses is calculated. // If name and e-mail address of customer are undefined, customer will be redirected on index page on “Tell a friend” form submit. //
// Initial number of fields in “Tell a friend” form is defined by SENDMAIL_INIT_TF_FIELDS_AMT constant in includes/settings.inc.php file. Maximal total number of fields in this for is defined by SENDMAIL_MAX_TF_FIELDS_AMT constant in the same file. //
Then coupon record with unique coupon code (which is random string) is created and value of discount is selected depending on the number of e-mail addresses, entered by the customer.
// Discount value selected from “[instance prefix]_coupons_discounts” table, “discount_value” field. “Discount_threshold” field contains minimal number of entered e-mail addresses for each discount value. At this moment, we have the following discount selection schema: //
| discount_threshold | discount_value | description |
|---|---|---|
| 1 | 10 | from 1 to 4 addresses - discount 10% |
| 5 | 20 | from 5 to 9 addresses - discount 20% |
| 10 | 30 | from 10 addresses - discount 30% |
For instance, customer has entered 3 e-mail addresses. Coupon discount value will be set to 10%. If customer has entered 7 e-mail addresses, coupon discount value will be set 20%.
// You could change current threshold and discount values or add new records for more discount thresholds. Coupons records stored in “[instance prefix]_coupons” table. //
As a result we have coupon record in “[instance prefix]_coupons” table, for example:
| coupon_code | coupon_discount |
|---|---|
| AV5DbjRZ | 20 |
After “Tell a friend” form submitted, e-mail notification messages created and sent on each entered e-mail address. // These messages created on the basis of template “tell_friend_email.tpl” from templtes folder. // Also notification message with auto generated coupon code will be created and sent to customer. // This message created on the basis of “tell_customer_email.tpl” template from templates folder. //
2. When customer received notification e-mail with discount coupon code, he could use it on index.php page in order to get discount for the next his order. Coupon code should be entered in “Kupongkode” field. When this field loses focus, coupon code verified against DB table. If coupon code is valid, discount value is appeared, prices and totals are recalculated.
