1. Create an additional field where shoppers can enter the coupon code.

Go to eShop -> Advanced Settings -> Payment methods -> Rules for the order pages

Here you should see **$RULE_ORDERPAGE_2**

2. Now you have to enter a rule to give the discount.

add_field(array("fieldname" =&gt; 'discount_code',

"fieldname_text" =&gt; "Discount Code:",

"typ" =&gt; "textfield(size=18):Text (any)"

));

Go to eShop -> Advanced Settings -> Payment methods -> Settings for all payment methods.

Here you should see

A shopper is asked to enter any discount/coupon codes in the T&C page.

if (get_orderinfo_additional_field('discount_code') == '12345')

{

$additional_costs = -($total_sum * 0.05);

$text_order_additional_costs = "5% Discount coupon code";

}

If the code is correct (in this case 12345), the the discount is applied.

**Note: **The discount is given to the amount including the tax. So for example

the tax amount was $10.00 and the total order was 500, then the discount will be

applied on £510.00

Similarly, you can give various discounts based on the coupon code entered. In the following example:

discount for '12345' is 5%

discount for '123456' is 15%

discount for '1234567' is 20%

All you have to do is include more statements:

if (get_orderinfo_additional_field('discount_code') == '12345')

{

$additional_costs = -($total_sum * 0.05);

}

elseif (get_orderinfo_additional_field('discount_code') == '123456')

{

$additional_costs = -($total_sum * 0.15);

}

elseif (get_orderinfo_additional_field('discount_code') == '1234567')

{

$additional_costs = -($total_sum * 0.20);

}

$text_order_additional_costs = "5% Discount coupon code";