Forums / Bug Reports / [DONE v1.3.9] Coupon Exclusions - I Don't Understand Anymore

[DONE v1.3.9] Coupon Exclusions - I Don't Understand Anymore

Locked

Started by andy_gs on 7 Oct 2009, 10:22 AM · Views: 1,623

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
7 Oct 2009, 10:22 AM
#1
andy_gs avatar

andy_gs

Zen Follower

Join Date:
Jun 2008
Posts:
187
Plugin Contributions:
0

[DONE v1.3.9] Coupon Exclusions - I Don't Understand Anymore

Hello all,

right i create vouchers for single products by:

Top - Deny
Product 5 - Allow

this works fine.

now im trying to exclude 2 categories

My logic

Top - Allow
Cat 1 - Deny
Cat 2 - Deny

This doesn't seem to work for any category even the valid ones.

I tried denying it by products:

Top - Allow

Prod_id 5 - Deny
Prod_id 6 - Deny
Prod_id 7 - Deny
Prod_id 8 - Deny
Prod_id 9 - Deny
Prod_id 10 - Deny

still didn't work, what am i doing wrong?

regards

Andy.

oh dear gurrrddddd.

8 Oct 2009, 1:50 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: [DONE v1.3.9] Coupon Exclusions - I Don't Understand Anymore

I am moving this to the Bug Report ...

This is a bug in the function file:
/includes/functions/functions_general.php

Replace the function validate_for_category around lines 856 - 879 with this new code:

  function validate_for_category($product_id, $coupon_id) {
    global $db;
    $retVal = 'none';
    $productCatPath = zen_get_product_path($product_id);
    $catPathArray = array_reverse(explode('_', $productCatPath));
    $sql = "SELECT count(*) AS total
            FROM " . TABLE_COUPON_RESTRICT . "
            WHERE category_id = -1
            AND coupon_restrict = [B]'Y'
            AND coupon_id = " . (int)$coupon_id . " LIMIT 1"[/B];
    $checkQuery = $db->execute($sql);
    foreach ($catPathArray as $catPath) {
      $sql = "SELECT * FROM " . TABLE_COUPON_RESTRICT . "
              WHERE category_id = " . (int)$catPath . "
              AND coupon_id = " . (int)$coupon_id;
      $result = $db->execute($sql);
      if ($result->recordCount() > 0 && $result->fields['coupon_restrict'] == 'N') return true;
      if ($result->recordCount() > 0 && $result->fields['coupon_restrict'] == 'Y') return false;
    }
    if ($checkQuery->fields['total'] > 0) {
      return false;
    } else {
      return 'none';
    }
  }

Then, you can configure the coupon with the restrictions of:
Top - Allow
Cat 1 - Deny
Cat 2 - Deny

Or as:
Cat 1 - Deny
Cat 2 - Deny

See if that works better for you ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

8 Oct 2009, 2:37 PM
#3
andy_gs avatar

andy_gs

Zen Follower

Join Date:
Jun 2008
Posts:
187
Plugin Contributions:
0

Re: [DONE v1.3.9] Coupon Exclusions - I Don't Understand Anymore

thanks

ajeh

yep works fine now...

regards

Andy.

oh dear gurrrddddd.