Zen Cart Logo
Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / Group Pricing + Quantity Discount

Group Pricing + Quantity Discount

Locked

Views: 4,297

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
18 Dec 2006, 9:15 AM
#1
zilwiz avatar

zilwiz

New Zenner

Join Date:
Dec 2006
Posts:
9
Plugin Contributions:
0

Group Pricing + Quantity Discount

Hello,
I have both the Group Pricing and the Quantity Discounts installed and am trying to accomplish the following with no luck:
I have setup a few price groups such as:
50% group
55% group

I have also setup in the Quantity Discount section a discount level rule which says that if there are 25 items or more there is a 55% discount.

My question is, how can I make them work together that when someone places an order of 25 items or more, the cart will ignore the group pricing and only use the discount from the Quantity Discount rule
(in other words, I want all clients that purchase 25 items or more to get a fixed discount that will over ride any Group Pricing discounts).

Any help appreciated - thanks in advance!

Amit

18 Dec 2006, 10:16 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Group Pricing + Quantity Discount

You would have to make GP and QD aware of each other; something they're not right now. Each of these modules stands alone.

Scott

18 Dec 2006, 5:33 PM
#3
zilwiz avatar

zilwiz

New Zenner

Join Date:
Dec 2006
Posts:
9
Plugin Contributions:
0

Re: Group Pricing + Quantity Discount

Thanks Scott,
Do you think it is possible with a simple IF sentence? If yes, would you have any direction to where that would be?

Thank you,

Amit

18 Dec 2006, 6:40 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Group Pricing + Quantity Discount

zilwiz:

Thanks Scott,
Do you think it is possible with a simple IF sentence?

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

20 Dec 2006, 8:06 AM
#5
zilwiz avatar

zilwiz

New Zenner

Join Date:
Dec 2006
Posts:
9
Plugin Contributions:
0

Re: Group Pricing + Quantity Discount

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 :smile:
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

$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:

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

20 Dec 2006, 12:48 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Group Pricing + Quantity Discount

Bear in mind that this is not a general solution; it will only work when discount basis is total items in cart, and is not compatible with user exits which generate discounts.

Scott