Certainly.
This was an add on for the reward points mod. However, you can use it in any order_total module. Since I don't want to discount gift certificates sold, I figured it was best if they were removed from the sub-total before calculation of the discount. The built in programming of the reward points mod prevents negative discounts (basic algebra on this one, a negative of a negative turns into a positive or in this case, creates a charge).
If you are going to use this for that same mod, edit ot_reward_points_discount.php found in the includes/modules/order_total directory.
Find (near line 61):
PHP Code:
$order_total=$this->get_order_total();
Add after:
PHP Code:
for($i=0; $i<sizeof($order->products); $i++) {
if (preg_match("/GIFT/", $order->products[$i]['model'])) {
$order_total -= ($order->products[$i]['qty'] * $order->products[$i]['price']);
}
}
Essentially you would need to cycle through $order->products and test each one for a match on the preg_match. If it's true, add code in to do something with it or vice versa. In my case in the line of code above, I'm instructing ot_reward_points_discount.php to remove the total of the gift certificate from the total.