While not exactly trying to do the same, it is similar enough to what I want to be able to do, which is to calculate and adjust the freeoptions shipping module to base the free shipping on Cart Total AFTER the discounts are applied, not before.
To do that, I had to figure out a way to get the amount (of the total discount) per discount module (ot_coupon.php) and for the added mod plugin I installed, newsletter discount (ot_newsletter_discount.php) found in the includes/modules/order_total directory.
Any other discount mods you may have installed should be located here as well. You will need to figure out what is the best method to determine if the discount is active or not. That is why I have the IF - ELSE statements.
No explanation is necessary if you understand the code below. It works. You just need to figure out where to put it and use it for your purposes. I'm on a tight schedule and when I have more time, I may expand on it further. Or not, lol.
Code:
// added this for calculating Adjusted Total AFTER Discounts to base free shipping on,
// instead of free shipping based on total BEFORE discounts!
if (isset($_SESSION['cc_id'])) {
$coupon_total = $ot_coupon->calculate_deductions($_SESSION['cart']->show_total());
} else { $coupon_total['total'] = 0; }
if ($ot_newsletter_discount->is_subscriber()) {
$nwsltr_total = $ot_newsletter_discount->calculate_deductions();
} else { $nwsltr_total['total'] = 0; }
$total_discounts = $coupon_total['total'] + $nwsltr_total['total'];
$adjusted_total = $_SESSION['cart']->show_total() - $total_discounts;
// echo 'Total Discounts = ' . $currencies->format($total_discounts) . '<br>';
// echo 'Adjusted Total = ' . $currencies->format($adjusted_total);
Bookmarks