Page 1 of 1

[HOW TO] Use the total instead of sub-total for coupons

Posted: Thu Jan 09, 2014 2:24 am
by Johnathan
Coupons in OpenCart just use the product sub-total when calculating percentage discounts, not the total at the position of the "Coupon" Order Total in the list. To make it factor in other Order Totals (such as fees or discounts) make this edit:

Code: Select all

IN:
/catalog/model/total/coupon.php

BEFORE:
$total_data[] = array(

ADD:
if ($coupon_info['type'] == 'F') {
    $discount_total = $coupon_info['discount'];
} else {
    $discount_total = $total / 100 * $coupon_info['discount'];
} 
Note that this will only work if the coupon is not applied to specific products (and will also make percentage coupons not work with specific products). Thanks to Dustin from soccerhelp.com for assistance in determining the correct code.