Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2007
    Location
    Nijmegen, Netherlands
    Posts
    44
    Plugin Contributions
    0

    Default Different Quantity Discounts for customers from Group Pricing?

    How can I accomplish different Quantity Discounts for Group Pricing customers?

    I have Zen Cart 1.3.7 and for some products I use Quantity Discount (Admin > Catalog > Products Price Manager)
    and I assigned some customers to Group Pricing (Admin > Customers > Group Pricing).

    A product is listed for all customers as:
    Qty Discounts Off Price
    1-5: €20.00 (normal price)
    6-10: €15.00
    11-20: €10.00

    Customers who are assigned to Group Pricing receive 10% discount.
    I am looking for a way that customers who are logged in and assigned to the 10% discount Group Pricing will get a different Quantity Discount, e.g.:
    1-5: €20.00 (normal price)
    6-10: €17.50
    11-20: €15.00
    (and 10% off the total price, which is accomplished by using Group Pricing)

    The Quantity discounts above are just an example.
    In the shop they will differ for every product.

    Is it possible or do I need a modification?
    Kind Regards,
    Peter Martin, Joomla specialist
    www.db8.nl

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,622
    Plugin Contributions
    123

    Default Re: Different Quantity Discounts for customers from Group Pricing?

    Quote Originally Posted by pe7er View Post
    ...
    Is it possible or do I need a modification?
    You need a modification.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Apr 2007
    Location
    Nijmegen, Netherlands
    Posts
    44
    Plugin Contributions
    0

    Default Re: Different Quantity Discounts for customers from Group Pricing?

    Thanks for your fast answer!

    In what file is the "Discount Value" specified?
    I looked in \admin\products_price_manager.php and found the table name
    TABLE_PRODUCTS_DISCOUNT_QUANTITY

    Should I make a modification in:
    \admin\includes\functions\general.php
    or in
    \admin\includes\functions\functions_prices.php
    in 1.3.7, line 1186:
    $discounted_price = $check_amount - ($check_amount * ($products_discounts_query->fields['discount_price']/100));

    I use Discount Prices of discount type "percentage",
    and the customers from the Group Price should get half of the quantity discount.
    Can I use the following:
    Code:
     //check if current customer is part of a certain (customers_group_pricing) group pricing (zen_group_pricing -> 1) category
    $gpcheck = $db->Execute("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_id = '".$order->customer['customers_id']."' AND customers_group_pricing = '1'; ");
    if ($gpcheck->fields['count'] >0){ 
    //customer is part of Group Price ID "1"
    //some statement where the Discount Value is multiplied by 50%
    $discounted_price = $check_amount - ($check_amount * (($products_discounts_query->fields['discount_price']/100)/2));
    }else{
    $discounted_price = $check_amount - ($check_amount * ($products_discounts_query->fields['discount_price']/100));
    }
    //end modification
    Kind Regards,
    Peter Martin, Joomla specialist
    www.db8.nl

  4. #4
    Join Date
    Apr 2007
    Location
    Nijmegen, Netherlands
    Posts
    44
    Plugin Contributions
    0

    Default Re: Different Quantity Discounts for customers from Group Pricing?

    To give customers who are in a certain customer group pricing group (customers_group_pricing = 1)
    only half (0.5) the regular quantity discount, I modified to following files:

    \includes\modules\products_quantity_discounts.php
    This file will display the quantity discount at the product information page.
    Just above the code
    Code:
    $display_price = zen_get_products_base_price($products_id_current);
    $display_specials_price = zen_get_products_special_price($products_id_current, true);
    $disc_cnt = 1;
    $quantityDiscounts = array();
    $columnCount = 0;
    I included:

    Code:
        //modification by pe7er
        //check if current customer is part of a certain (customers_group_pricing) group pricing (zen_group_pricing -> 1) category
        $gpcheck = $db->Execute("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_id = '".$_SESSION['customer_id']."' AND customers_group_pricing = '1'; ");
        if ($gpcheck->fields['count'] >0){
          $distri_discount = 0.5; // the customers in this price group get 50% of the quantity discount
        }else{
          $distri_discount = 1; // other customers will receive the full quantity discount
        }// end modification.
    and I changed (about 6 lines)
    Code:
    = $display_price - (($products_discounts_query->fields['discount_price'] *$distri_discount)/100);
    into
    Code:
    = $display_price - ($display_price * (($products_discounts_query->fields['discount_price'] *$distri_discount)/100));
    \shop\includes\functions\functions_prices.php
    This file calculates the quantity prices.

    Just AFTER:
    Code:
    $display_specials_price = zen_get_products_special_price($product_id, true);
    I added:
    Code:
        //modification by pe7er
        //check if current customer is part of a certain (customers_group_pricing) group pricing (zen_group_pricing -> 1) category
        $gpcheck = $db->Execute("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_id = '".$_SESSION['customer_id']."' AND customers_group_pricing = '1'; ");
        if ($gpcheck->fields['count'] >0){
          $distri_discount = 0.5;
        }else{
          $distri_discount = 1;
        }       // end modification.
    and I changed (about 6 lines):
    Code:
    ($products_discounts_query->fields['discount_price'])/100);
    into:
    Code:
    (($distri_discount * $products_discounts_query->fields['discount_price'])/100));
    Kind Regards,
    Peter Martin, Joomla specialist
    www.db8.nl

  5. #5
    Join Date
    Aug 2008
    Posts
    41
    Plugin Contributions
    0

    Default Re: Different Quantity Discounts for customers from Group Pricing?

    Thanks for your post, I had a similar (but not exactly the same) issue.

    Our store has price groups for every product. These price groups are actually determined by a multiplier of the product's cost to the seller. Furthermore, some products have quantity pricing as well!

    I have not yet dared to change both the admin and the store to calculate the displayed price based on a base price * multiplier; however I was able to adapt the store (which has the price groups mod) to display quantity pricing based on the price group.

    I took Pe7er's code above, tweaked it a bit to suit my store. However I noticed that the shopping cart does not display the correct quantity pricing nor does it show the correct subtotal. I am adding this post to help others correct that.

    There are two places where you need to change or add code:
    • store/includes/modules/pages/shopping_cart/header_php.php
    • store/includes/classes/shopping_cart.php


    store/includes/modules/pages/shopping_cart/header_php.php

    If you have an un-modded header_php.php, on line 141 is:
    PHP Code:
    $productsPrice $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : ''); 
    just before this line, add the following:

    PHP Code:
      // MOD ADJUST 'productsPriceEach' IF THERE IS QUANTITY PRICING FOR THIS PRODUCT

      
    $prodQ $products[$i]['quantity'];
      
    $prodPE $products[$i]['final_price'];
      
    $prodID $products[$i]['id'];
      if (
    $prodQ 1) {  // don't bother if quantity == 1
        
    $sql "select discount_qty as dq from " TABLE_PRODUCTS_DISCOUNT_QUANTITY " where products_id = '" $prodID "' order by discount_qty asc";
        
    $dqCheck $db->Execute($sql);
        
    $count $dqCheck->RecordCount();
        
    $key 0;
        
    $dqCheckArray = array();
        while (!
    $dqCheck->EOF) {
          
    $dqCheckArray[$key] = $dqCheck->fields['dq'];
          
    $dqCheck->MoveNext();
          
    $key++;
          }
        if (
    $count && $prodQ >= $dqCheckArray[0]) { // if there are quantity discounts AND if the product quantity is at least as large as the lowest qty discount level
          
    for($x=0;$x<$count;$x++) { // first let's get the base price which applies to this quantity
            
    if ($x < ($count 1) && $prodPE >= $dqCheckArray[$x] && $prodPE $dqCheckArray[($x+1)]) { // if the quantity is >= this qty discount level but < the next higher qty discount level
                
    $key $x;
                }
            elseif (
    $x == ($count-1)) { // if the quantity is >= the highest qty discount level, use that one
              
    $key $x;
              }
            }
          
    $dqVal $dqCheckArray[$key]; // select the value for the correct qty disc level in the table
          
    $sql "select discount_price as dp from " TABLE_PRODUCTS_DISCOUNT_QUANTITY " where products_id = '" $prodID "' and discount_qty = '" $dqVal "'";
          
    $dp $db->Execute($sql);
          
    $discPrice $dp->fields['dp']; // yay, now we have the base price to work with
          
    $sql "select customers_group_pricing as cgp from " TABLE_CUSTOMERS " where customers_id = '" $_SESSION['customer_id'] . "'";
          
    $cgpid $db->Execute($sql);
          
    $custGP $cgpid->fields['cgp'];
          
    $sql "select group_percentage as gp from "TABLE_GROUP_PRICING " where group_id = '" $custGP "'";
          
    $cgppct $db->Execute($sql);
          
    $gpPct $cgppct->fields['gp']; // yay, now we have the percentage by which to multiply the base price
          
          
    $products[$i]['final_price'] = $gpPct $discPrice// now, was that so hard? ;-)
          
    }
        }

    // END MOD 
    store/includes/classes/shopping_cart.php

    Now we want to change the 'calculate' function of the class 'shopping cart'. Strangely, the subtotal for the shopping cart is calculated not by adding up the product price * quantity for each item in your basket, at least not using the figures you see individually listed in your shopping cart! Instead it is calculated completely separately! So you need to change the shopping cart class with code which is similar to that above, but not exactly the same.

    If you have an group pricing modded shopping_cart.php like me, find line 639:
    PHP Code:
    if($customers_group
    and on my line 649 is the closing bracket for a series of if... elseif... statements which look like this (again, this is in my file, YMMV):

    PHP Code:
    if($customers_group == GROUP_PRICE_PER_ITEM1 && $product->fields['products_group_a_price'] != 0) {
                
    $products_price $product->fields['products_group_a_price'];
              } elseif(
    $customers_group == GROUP_PRICE_PER_ITEM2 && $product->fields['products_group_b_price'] != 0) {
                
    $products_price $product->fields['products_group_b_price'];
              } elseif(
    $customers_group == GROUP_PRICE_PER_ITEM3 && $product->fields['products_group_c_price'] != 0) {
                
    $products_price $product->fields['products_group_c_price'];
              } elseif(
    $customers_group == GROUP_PRICE_PER_ITEM4 && $product->fields['products_group_d_price'] != 0) {
                
    $products_price $product->fields['products_group_d_price'];
              } 
    replace that entire block of code - including the opening 'if' statement and the closing bracket - with this:

    PHP Code:
    if($customers_group) {
              if (
    $product->fields['products_discount_type'] != '0') {
                if (
    $qty 1) {  // don't bother if quantity == 1
                  
    $sql "select discount_qty as dq from " TABLE_PRODUCTS_DISCOUNT_QUANTITY " where products_id = '" $prid "' order by discount_qty asc";
                  
    $dqCheck $db->Execute($sql);
                  
    $count $dqCheck->RecordCount();
                  
    $key 0;
                  
    $dqCheckArray = array();
                  while (!
    $dqCheck->EOF) {
                    
    $dqCheckArray[$key] = $dqCheck->fields['dq'];
                    
    $dqCheck->MoveNext();
                    
    $key++;
                    }
                  if (
    $count && $qty >= $dqCheckArray[0]) { // if there are quantity discounts AND if the product quantity is at least as large as the lowest qty discount level
                    
    for($x=0;$x<$count;$x++) { // first let's get the base price which applies to this quantity
                      
    if ($x < ($count 1) && $prodPE >= $dqCheckArray[$x] && $prodPE $dqCheckArray[($x+1)]) { // if the quantity is >= this qty discount level but < the next higher qty discount level
                        
    $key $x;
                        }
                      elseif (
    $x == ($count-1)) { // if the quantity is >= the highest qty discount level, use that one
                        
    $key $x;
                        }
                      }
                    
    $dqVal $dqCheckArray[$key]; // select the value for the correct qty disc level in the table
                    
    $sql "select discount_price as dp from " TABLE_PRODUCTS_DISCOUNT_QUANTITY " where products_id = '" $prid "' and discount_qty = '" $dqVal "'";
                    
    $dp $db->Execute($sql);
                    
    $discPrice $dp->fields['dp']; // yay, now we have the base price to work with
                    
    $sql "select group_percentage as gp from "TABLE_GROUP_PRICING " where group_id = '" $product->fields['products_discount_type'] . "'";
                    
    $cgppct $db->Execute($sql);
                    
    $gpPct $cgppct->fields['gp']; // yay, now we have the percentage by which to multiply the base price
          
                    
    $products_price $gpPct $discPrice// now, was that so hard? ;-)
                    
    }
                  }
                }
              else {
                if(
    $customers_group == GROUP_PRICE_PER_ITEM1 && $product->fields['products_group_a_price'] != 0) {
                  
    $products_price $product->fields['products_group_a_price'];
                  }
                elseif(
    $customers_group == GROUP_PRICE_PER_ITEM2 && $product->fields['products_group_b_price'] != 0) {
                  
    $products_price $product->fields['products_group_b_price'];
                  }
                elseif(
    $customers_group == GROUP_PRICE_PER_ITEM3 && $product->fields['products_group_c_price'] != 0) {
                  
    $products_price $product->fields['products_group_c_price'];
                  }
                elseif(
    $customers_group == GROUP_PRICE_PER_ITEM4 && $product->fields['products_group_d_price'] != 0) {
                  
    $products_price $product->fields['products_group_d_price'];
                  }
                }
              } 
    if you did it right, the line after the last closing curly bracket above should read "// adjusted count for free shipping"

    if anyone else finds this useful I would love to know about it. I put in several hours on getting this to work!!!

    in bocca al lupo...

  6. #6
    Join Date
    Aug 2008
    Posts
    41
    Plugin Contributions
    0

    Default Re: Different Quantity Discounts for customers from Group Pricing?

    ... also be sure to read this thread if you have installed the group product pricing mod, or your shopping cart totals will not be correct.

  7. #7
    Join Date
    Jun 2009
    Posts
    66
    Plugin Contributions
    0

    Default Re: Different Quantity Discounts for customers from Group Pricing?

    Quote Originally Posted by pe7er View Post
    To give customers who are in a certain customer group pricing group (customers_group_pricing = 1)
    only half (0.5) the regular quantity discount, I modified to following files:

    \includes\modules\products_quantity_discounts.php
    This file will display the quantity discount at the product information page.
    Just above the code
    Code:
    $display_price = zen_get_products_base_price($products_id_current);
    $display_specials_price = zen_get_products_special_price($products_id_current, true);
    $disc_cnt = 1;
    $quantityDiscounts = array();
    $columnCount = 0;
    I included:

    Code:
        //modification by pe7er
        //check if current customer is part of a certain (customers_group_pricing) group pricing (zen_group_pricing -> 1) category
        $gpcheck = $db->Execute("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_id = '".$_SESSION['customer_id']."' AND customers_group_pricing = '1'; ");
        if ($gpcheck->fields['count'] >0){
          $distri_discount = 0.5; // the customers in this price group get 50% of the quantity discount
        }else{
          $distri_discount = 1; // other customers will receive the full quantity discount
        }// end modification.
    and I changed (about 6 lines)
    Code:
    = $display_price - (($products_discounts_query->fields['discount_price'] *$distri_discount)/100);
    into
    Code:
    = $display_price - ($display_price * (($products_discounts_query->fields['discount_price'] *$distri_discount)/100));
    \shop\includes\functions\functions_prices.php
    This file calculates the quantity prices.

    Just AFTER:
    Code:
    $display_specials_price = zen_get_products_special_price($product_id, true);
    I added:
    Code:
        //modification by pe7er
        //check if current customer is part of a certain (customers_group_pricing) group pricing (zen_group_pricing -> 1) category
        $gpcheck = $db->Execute("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_id = '".$_SESSION['customer_id']."' AND customers_group_pricing = '1'; ");
        if ($gpcheck->fields['count'] >0){
          $distri_discount = 0.5;
        }else{
          $distri_discount = 1;
        }       // end modification.
    and I changed (about 6 lines):
    Code:
    ($products_discounts_query->fields['discount_price'])/100);
    into:
    Code:
    (($distri_discount * $products_discounts_query->fields['discount_price'])/100));
    Hi..perhaps you can help me.
    I have only one price group (1) that has 5% discount
    how can I do to apply 5% if total order is max 200 Dollars, +50% (7.5%) if total order is max 600 Dollars and +100% (10%) if total orders is more than 600 dollars (only to group price 1)?

    thank you very much

 

 

Similar Threads

  1. v150 Quantity Discounts /group pricing
    By Serg in forum Customization from the Admin
    Replies: 2
    Last Post: 22 Aug 2012, 09:45 PM
  2. Group Pricing and Quantity Discounts
    By therummagehole in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 9 Jun 2012, 10:44 AM
  3. Need to have wholesale pricing with quantity discounts for wholesale customers only..
    By littleturtlemama in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 4
    Last Post: 16 Dec 2010, 04:47 AM
  4. Need to have wholesale pricing with quantity discounts for wholesale customers only..
    By littleturtlemama in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 29 Sep 2007, 10:01 PM
  5. Group Pricing/Quantity Discounts
    By kinget in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 22 Jun 2007, 07:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR