Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Disable coupons and group discounts when quantity discount applied?

Disable coupons and group discounts when quantity discount applied?

Views: 1,896

Results 1 to 8 of 8
20 Jun 2014, 8:08 PM
#1
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

Disable coupons and group discounts when quantity discount applied?

We offer quantity discounts when you buy a case of products. We don't want to allow coupons or group discounts on cases. Would anyone be able to help me modify the code so that if a product has a quantity discount applied, coupons and group discounts would not apply?

22 Jun 2014, 4:18 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Disable coupons and group discounts when quantity discount applied?

I have the solution on the Discount Coupons that can work for you ...

Customize the file:
/includes/modules/order_total/ot_coupon.php

and add the code in RED:

  function get_order_total($couponCode)
  {
    global $order;
    $orderTaxGroups = $order->info['tax_groups'];
    $orderTotalTax = $order->info['tax'];
    $orderTotal = $order->info['total'];
    $products = $_SESSION['cart']->get_products();
    for ($i=0; $i<sizeof($products); $i++) {
[B]// bof: no discount on Products with Product Discount quantities products_discount_quantity
      global $db;
      $no_discount = false;
      $sql = "SELECT products_id from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " WHERE products_id = '" . (int)$products[$i]['id'] . "'";
      $chk_discount = $db->Execute($sql);
      if ($chk_discount->RecordCount() > 0) $no_discount = true;
//echo 'ot_coupon products_id: ' . (int)$products[$i]['id'] . ' RecordCount(): ' . $chk_discount->RecordCount() . ' Discounted: ' . ($no_discount ? 'YES' : 'NO') . '<br><br>';
[/B]      if ([B]$no_discount ||[/B] !is_product_valid($products[$i]['id'], $couponCode)) {
[B]// eof: no discount on Products with Product Discount quantities products_discount_quantity
[/B]        $products_tax = zen_get_tax_rate($products[$i]['tax_class_id']);
        $productsTaxAmount = (zen_calculate_tax($products[$i]['final_price'], $products_tax))   * $products[$i]['quantity'];
        $orderTotal -= $products[$i]['final_price'] * $products[$i]['quantity'];
        if ($this->include_tax == 'true') {

For the Group discounts, this is going to be more complicated and if I get time, I will try to workout some kind of solution for that ...

12 Nov 2015, 1:16 AM
#3
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Disable coupons and group discounts when quantity discount applied?

Ajeh:

I have the solution on the Discount Coupons that can work for you ...

Customize the file:
/includes/modules/order_total/ot_coupon.php

and add the code in RED:

function get_order_total($couponCode)
{
global $order;
$orderTaxGroups = $order->info['tax_groups'];
$orderTotalTax = $order->info['tax'];
$orderTotal = $order->info['total'];
$products = $_SESSION['cart']->get_products();
for ($i=0; $i<sizeof($products); $i++) {
[B]// bof: no discount on Products with Product Discount quantities products_discount_quantity
global $db;
$no_discount = false;
$sql = "SELECT products_id from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " WHERE products_id = '" . (int)$products[$i]['id'] . "'";
$chk_discount = $db->Execute($sql);
if ($chk_discount->RecordCount() > 0) $no_discount = true;
//echo 'ot_coupon products_id: ' . (int)$products[$i]['id'] . ' RecordCount(): ' . $chk_discount->RecordCount() . ' Discounted: ' . ($no_discount ? 'YES' : 'NO') . '<br><br>';
[/B]
if ([B]$no_discount ||[/B] !is_product_valid($products[$i]['id'], $couponCode)) {
[B]// eof: no discount on Products with Product Discount quantities products_discount_quantity
[/B]
$products_tax = zen_get_tax_rate($products[$i]['tax_class_id']);
$productsTaxAmount = (zen_calculate_tax($products[$i]['final_price'], $products_tax)) * $products[$i]['quantity'];
$orderTotal -= $products[$i]['final_price'] * $products[$i]['quantity'];
if ($this->include_tax == 'true') {

> 
> For the Group discounts, this is going to be more complicated and if I get time, I will try to workout some kind of solution for that ...

will this also apply to Swguy quantity discount module?
12 Nov 2015, 1:18 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Disable coupons and group discounts when quantity discount applied?

I am afraid that you'd have to ask swguy on that one ... :lookaroun

12 Nov 2015, 1:22 AM
#5
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Disable coupons and group discounts when quantity discount applied?

I have asked him few times but did not get answer yet. I will post here if find solution.

12 Nov 2015, 11:07 AM
#6
swguy avatar

swguy

Administrator

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

Re: Disable coupons and group discounts when quantity discount applied?

The answer is no.

BTW, asking me a question, getting an answer, and then asking a completely different question and waiting less than 24 hours actually doesn't constitute "asking him a few times and not getting an answer."

12 Nov 2015, 11:20 AM
#7
jsarwar avatar

jsarwar

Zen Follower

Join Date:
Jul 2012
Posts:
347
Plugin Contributions:
0

Re: Disable coupons and group discounts when quantity discount applied?

swguy:

The answer is no.

BTW, asking me a question, getting an answer, and then asking a completely different question and waiting less than 24 hours actually doesn't constitute "asking him a few times and not getting an answer."

I have included same question in PM, email and other forum post as I am still looking to restrict customers to use / get only 1 discount of your module not all. I have replied to your PM explaining question again.

12 Nov 2015, 11:31 AM
#8
swguy avatar

swguy

Administrator

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

Re: Disable coupons and group discounts when quantity discount applied?

So your question is really "can the discounts know about each other so they can know not to apply to the same item?" The answer is no; they don't know about each other. Most have specific item exclusion user exits that you can add products to by hand, but each discount is individual and is not aware of the operation of other discounts.