Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with "quantity discount" and "customer discount" add ons


acbatchelor

Recommended Posts

i am using the "quantity discount" and "customer discount" add ons. i have my site setup so that if customers buy at least 4 items they get a discount. i also have a few customers that i give a percentage discount to their account. does anyone know how to setup the quantity discount so that it does not give a discount to the customers that receive the percentage discount from the other add on? the quantity discount add on has an option where it does not give the discount if the customer uses a coupon so i am thinking that there should be a way to disable it when using the customer discount.

Link to comment
Share on other sites

I made this on my shop, works like a charm.

 

In the file catalog/includes/modules/ot_loyalty_discount.php after:

function process() {
global $order, $ot_subtotal, $currencies, $customer_id;
$od_amount = $this->calculate_credit($this->get_order_total(), $this->get_cum_order_total());

Add this:

// Check if customer gets already customer_discount, if yes, disable this module.
$query = tep_db_query("select customer_discount from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'"); 
$query_result = tep_db_fetch_array($query);
$od_pc = $query_result['customer_discount'];
	if ($od_pc==0){

 

Find:

} // end of function process()

 

Above add:

} // end of customer check

 

Maybe you have to add $customer_id to the global string, like above.

 

Have fun,

cosmo

Link to comment
Share on other sites

I don't know if you are talking about the same addon as i am. my file that the addon works through is ot_qty_discount but yours is called ot_loyalty_discount. I looked and i have a function process() but some of the code under that is different. example ( i don't have get_cum_order_total). i also don't have "//end function process()" in my file. i have not touched the code, this is the way it came.

 

i tryed to put this code in there anyway and i get an error when i go to the checkout_confirmation page.

 

 

 

1054 - Unknown column 'customer_discount' in 'field list'

 

select customer_discount from customers where customers_id = '1'

 

[TEP STOP]

 

here is the code around this area

 

function process() {
     global $order, $currencies, $ot_subtotal;

     $od_amount = $this->calculate_discount($this->get_order_total());
     if ($this->calculate_tax == 'true') $tod_amount = $this->calculate_tax_effect($od_amount);

     if ($od_amount > 0) {
       if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') $title_ext = sprintf(MODULE_QTY_DISCOUNT_PERCENTAGE_TEXT_EXTENSION ,$this->calculate_rate($_SESSION['cart']->count_contents()));
       $this->deduction = $od_amount+$tod_amount;
       $this->output[] = array('title' => sprintf(MODULE_QTY_DISCOUNT_FORMATED_TITLE, $title_ext),
                               'text' => sprintf(MODULE_QTY_DISCOUNT_FORMATED_TEXT, $currencies->format($od_amount)),
                               'value' => $od_amount);
       $order->info['total'] -= $this->deduction;
       $order->info['tax'] -= $tod_amount;
       if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction;
     }
   }

   function calculate_discount($amount) {
     global $qty_discount, $order_total_array;

     $od_amount = 0;
     if ((MODULE_QTY_DISCOUNT_DISABLE_WITH_COUPON == 'true') && (isset($_SESSION['cc_id']))) return $od_amount;

     $qty_discount = $this->calculate_rate($_SESSION['cart']->count_contents());
     if ($qty_discount > 0) {
       if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') {
         $od_amount = round((($amount*10)/10)*($qty_discount/100), 2);
       } else {
         $od_amount = round((($qty_discount*10)/10), 2);

Edited by acbatchelor
Link to comment
Share on other sites

If you receive an error message: Unknown column 'customer_discount' in 'field list', you forgot a step in the installation of customer discount:

 

ALTER TABLE customers ADD customer_discount DECIMAL(5,2) DEFAULT '0' NOT NULL;

 

The rest stays the same, I think in your case it should look like this:

 

function process() {
global $order, $currencies, $ot_subtotal, $customer_id;

$od_amount = $this->calculate_discount($this->get_order_total());
if ($this->calculate_tax == 'true') $tod_amount = $this->calculate_tax_effect($od_amount);

// Check if customer gets already customer_discount, if yes, disable this module.
$query = tep_db_query("select customer_discount from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");
$query_result = tep_db_fetch_array($query);
$od_pc = $query_result['customer_discount'];
	if ($od_pc==0){

if ($od_amount > 0) {
if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') $title_ext = sprintf(MODULE_QTY_DISCOUNT_PERCENTAGE_TEXT_EXTENSION ,$this->calculate_rate($_SESSION['cart']->count_contents()));
$this->deduction = $od_amount+$tod_amount;
$this->output[] = array('title' => sprintf(MODULE_QTY_DISCOUNT_FORMATED_TITLE, $title_ext),
'text' => sprintf(MODULE_QTY_DISCOUNT_FORMATED_TEXT, $currencies->format($od_amount)),
'value' => $od_amount);
$order->info['total'] -= $this->deduction;
$order->info['tax'] -= $tod_amount;
if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction;
}
} // end of customer check
}

Link to comment
Share on other sites

i did do that step but in the contribution it says customers_discount DECIMAL(8,2) not customer_discount DECIMAL(5,2)

 

i tried to do it anyway. i added the customer_discount to my database and it still did not work, no error but it still did both the quantity and customer discount.

 

i also tried changing all of your code from customer_discount to customers_discount but it still did not work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...