(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.


Reply With Quote
