Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    12
    Plugin Contributions
    0

    Default [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.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Error message fixed restricting coupons (v1.3.9h)

    Good catch. Thanks.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 4
    Last Post: 19 Sep 2012, 03:36 AM
  2. Replies: 2
    Last Post: 19 Sep 2012, 03:33 AM
  3. Error Message when Trying to Restrict Coupons
    By rainbows in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 13
    Last Post: 19 Apr 2011, 11:36 PM
  4. Restricting coupons to a group of products
    By steveorg in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 15
    Last Post: 15 Dec 2006, 01:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg