Exclude items from the Group Pricing Discount
Hi everyone, this is my first post.
I am currently setting up my first zencart site.
Im making pretty good progress, but I have a problem.
I have set up the group pricing to allow a % discount on items, however, I want to know if there is any module/php alteration to exclude items marked as "OEM" in the manufacturer option, or only allow items marked "Compatible" in the manufacturer option.
I have got the Online Group Pricing module by Toni installed (To show the discount on each item instead of the cart), so please take this into account if I have to replace core files.
Many thanks
Ray
v1.3.9h
Re: Exclude items from the Group Pricing Discount
Surely somebody knows how to do this ? :huh:
I sort of know what I want it to do, but dont know how about doing it.
I think this may work....
Create an extra field somewhere in the database called "excludefromsales", and assign it to a checkbox next to either, the manufacturer or the item.
Then in the functions_prices.php or html_output.php, or both files, a function that does something like....
"if excludefromsales = 0 {do this with discount applied}
else
{do this without discount applied}"
I know it is probably simple for some of you guys, but without a lot of trial and error, its not something simple for me :frusty:
Thanks in advance for any help.
Re: Exclude items from the Group Pricing Discount
very interested in this as well... i've tried many codes and nothing seems to work :no::no:
Re: Exclude items from the Group Pricing Discount
I think the perfect guy to help on this would be Toni, the creator of the online group mod.
I have got this far, I have added a session variable named "$customer_manufacturer_group" and done the "if" statement similar to my first post.
This does remove the discount, but on all products, and not just those in my category number 6.
Can anybody help ?
My additions are in green below.
} else {
session_start();
$_SESSION['customer_group_id'] = array();
$_SESSION['customer_group_id']['customer_id'] = $customer_id;
$_SESSION['customer_group_id']['group_id'] = $customer_group_id;
$_SESSION['customer_group_id']['discount'] = $customer_group_percentage;
$_SESSION['customer_group_id']['method'] = $customer_group_method;
$_SESSION['manufacturers']['manufacturers_id'] = $customer_manufacturer_group;
}
}
switch($customer_group_method) {
case 1:
if ($customer_manufacturer_group =6) {
$display_normal_price = round($display_normal_price,4) * $qty;
return $display_normal_price;}
else
{$display_normal_price = round($display_normal_price * (1 - ($customer_group_percentage/100)),4) * $qty;
return $display_normal_price;}
break;
case 2:
$display_normal_price = round($display_normal_price / (1 + ($customer_group_percentage/100)),4) * $qty;
return $display_normal_price;
break;
default:
// regular price
$display_normal_price = round($display_normal_price,4) * $qty;
return $display_normal_price;
break;
}
Re: Exclude items from the Group Pricing Discount
What file are you editing??
Everywhere I looked mentions to edit ot_group_pricing.php and edit the deductions portion. I've tried but I'm not able to make it work :no:
PHP Code:
function calculate_deductions($order_total) {
global $db, $order;
$od_amount = array();
$orderTotal = $this->get_order_total();
$orderTotalTax = $orderTotal['tax'];
$group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
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);
$ratio = $od_amount['total']/$order_total;
/**
* when calculating the ratio add some insignificant values to stop divide by zero errors
*/
switch ($this->calculate_tax) {
case 'None':
if ($this->include_tax) {
reset($order->info['tax_groups']);
foreach ($order->info['tax_groups'] as $key=>$value) {
$od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio;
}
}
Re: Exclude items from the Group Pricing Discount
Ill have a look in that file later on today.
Ive been editing the includes/functions/functions_prices.php file.
Im having trouble setting the variable "$customer_manufacturer_group"
Ive added this green text below the existing black text
$_SESSION['customer_group_id']['method'] = $customer_group_method;
$_SESSION['manufacturers']['manufacturers_id'] = $product_manufacturer_group;
}
and trying to echo the result to the screen, but i can seem to get this to work :frusty:
Re: Exclude items from the Group Pricing Discount
Did anyone ever figure this out?
Re: Exclude items from the Group Pricing Discount
Seems to me that there is a fundamental error in the logic in the question.
The Group discount works on the order total, so there are three possiblities:
1. The order has no "excluded" items, so the group discount should be applied
2. The order is entirely made up of "excluded" items, so no groupd discount is available
3. The order has some "excluded" and some not "excluded". What happens then?
Or have I missed something?
Re: Exclude items from the Group Pricing Discount
EXACTLY this, in example 3, discount needs to be on a per product basis not order total.
Quote:
Originally Posted by
hairydog
Seems to me that there is a fundamental error in the logic in the question.
The Group discount works on the order total, so there are three possiblities:
1. The order has no "excluded" items, so the group discount should be applied
2. The order is entirely made up of "excluded" items, so no groupd discount is available
3. The order has some "excluded" and some not "excluded". What happens then?
Or have I missed something?
Re: Exclude items from the Group Pricing Discount
Quote:
Originally Posted by
DigitalShadow
EXACTLY this, in example 3, discount needs to be on a per product basis not order total.
That means calculating the price on a per-item basis, and it is no longer an order total discount.