Zen Cart Logo
Forums / Bug Reports / [Done v1.5.0] Error message fixed restricting coupons (v1.3.9h)

[Done v1.5.0] Error message fixed restricting coupons (v1.3.9h)

Views: 1,339

Results 1 to 2 of 2
5 Feb 2011, 8:24 PM
#1
buzzworm2 avatar

buzzworm2

New Zenner

Join Date:
Nov 2008
Posts:
16
Plugin Contributions:
0

[Done v1.5.0] Error message fixed restricting coupons (v1.3.9h)

(add-ons installed: EasyPopulate, Image Handler 2)

I was getting an error message when restricting coupons in the "Product Restrictions" section.

I selected "Add All Category Products" from the dropdown and got the following:

1146 Table 'yorkshir_jfaz1.products_to_categories' doesn't exist
in:
[select products_id from products_to_categories where categories_id = '11' and products_id not in (select product_id from coupon_restrict where coupon_id = '1')]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

I found the problem in coupon_restrict.php.

The SQL statement wasn't adding the table prefix, as defined in database_tables.php. Here's the original statement and my fixed version (starting on line 61 in coupon_restrict.php):

        //$new_products_query = "select products_id from products_to_categories where categories_id = '" . $_GET['build_cat'] . "' and products_id not in (select product_id from coupon_restrict where coupon_id = '" . $_GET['cid'] . "')";
        $new_products_query = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $_GET['build_cat'] . "' and products_id not in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "')";

The next statement in the file also had the problem, so here's my fixed version (not sure how to test this one):

        $new_products_query = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $_GET['build_cat'] . "' and products_id in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_restrict = '" . $status . "' and coupon_id = '" . $_GET['cid'] . "')";

I'm not a php developer and am new to Zen Cart so I'm happy that I feel like I contributed something. Forgive me if this is already covered somewhere - I searched by couldn't find it.

5 Feb 2011, 11:05 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.5.0] Error message fixed restricting coupons (v1.3.9h)

Good catch. Thanks.