Originally Posted by
swguy
In my experience these things are never that simple; there are tax implications
and sort order implications and bla bla bla. You are welcome to PM me if you
need help.
Scott
Thanks for trying to help, but I managed to figure it out and it did turn out to be simple
If anyone else needs this in the future, what I did was ad the following line in the includes\modules\order_total\ot_group_pricing.php file
Code:
$check_QD_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_LEVEL_1'");
if ($_SESSION['cart']->count_contents() < $check_QD_query->fields['configuration_value']){
Which disables the group pricing option when the quantity total is above the defined number.
In the file it will look like this:
Code:
function calculate_deductions($order_total) {
global $db, $order;
$od_amount = array();
$tax_address = zen_get_tax_locations();
$group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
/// - Check if Quantity Discount is enabled /////
$check_QD_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_LEVEL_1'");
if ($_SESSION['cart']->count_contents() < $check_QD_query->fields['configuration_value']){
///
if ($group_query->fields['customers_group_pricing'] != '0') {
$group_discount = $db->Execute("select group_name, group_percentage from " . TABLE_GROUP_PRICING . " where
group_id = '" . (int)$group_query->fields['customers_group_pricing'] . "'");
$gift_vouchers = $_SESSION['cart']->gv_only();
$discount = ($order_total - $gift_vouchers) * $group_discount->fields['group_percentage'] / 100;
$od_amount['total'] = round($discount, 2);
/**
* when calculating the ratio add some insignificant values to stop divide by zero errors
*/
$ratio = ($od_amount['total'] + .000001)/($order_total - $gift_vouchers + .000001);
switch ($this->calculate_tax) {
case 'Standard':
reset($order->info['tax_groups']);
while (list($key, $value) = each($order->info['tax_groups'])) {
$tax_rate = zen_get_tax_rate_from_desc($key);
if ($tax_rate > 0) {
$od_amount[$key] = $tod_amount = round(($order->info['tax_groups'][$key]) * $ratio, 2) ;
$od_amount['tax'] += $tod_amount;
}
}
break;
case 'Credit Note':
reset($order->info['tax_groups']);
while (list($key, $value) = each($order->info['tax_groups'])) {
$tax_rate = zen_get_tax_rate_from_desc($order->info['tax_groups']);
if ($tax_rate > 0) {
$od_amount[$key] = $tod_amount = round(($order->info['tax_groups'][$key]) * $ratio, 2) ;
$od_amount['tax'] += $tod_amount;
}
}
break;
}
}
} // - end Check if Quantity Discount is enabled ///
return $od_amount;
}
Hope someone will find this usefully.
Amit
Bookmarks