Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    146
    Plugin Contributions
    6

    Default Coupon Restriction for Specials - Solution

    Perhaps best for someone to package and put in dowmloads section and get all the glory , just too busy at the moment to do it, but thought i would share a little mod to enable you to restrict a coupon from all items on special.
    Its pretty basic in how it works, just two buttons added to the coupon restrictions page, an add and remove button.

    The add button will search all products currently on special and will list them in the products retricted area, for that coupon for you.
    the remove button removes all restricted products, that are on special for that coupon, from the restricted products.

    File to change is /admin/coupon_restrict.php

    The above is a core file so care to be taken, as always backup before performing any mod.

    around line 36:

    After:
    Code:
     where restrict_id = '" . $_GET['info'] . "'");
        }
      }
    add:
    Code:
    if ($_GET['action']=='specials')  {
    $new_products_query = "select products_id from " . TABLE_SPECIALS . "  where status = 1 and products_id not in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "')";
    $new_products = $db->Execute($new_products_query);
    
    while(!$new_products->EOF) {
    // add all products from specials for each product not already defined in coupons_restrict
    $db->Execute("insert into " . TABLE_COUPON_RESTRICT . " (coupon_id, product_id, coupon_restrict) values ('" . $_GET['cid'] . "', '" . $new_products->fields['products_id'] . "', 'Y')");
    $new_products->MoveNext();
     }
    }  
    
    //remove specials
    if ($_GET['action']=='remove_specials')  {
     // to delete existing products from coupon code that are selected as specials coupon_code that are already in the table
    $new_products_query = "select products_id from " . TABLE_SPECIALS . "  where status = 1 and products_id in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "')";
    $new_products = $db->Execute($new_products_query);
     
    // nothing to be done
              if ($new_products->RecordCount() == 0) {
                $messageStack->add(ERROR_DISCOUNT_COUPON_DEFINED_CATEGORY . ' ' . $_POST['cPath'], 'caution');
              }
              while(!$new_products->EOF) {
                // product needs to be deleted
              $db->Execute("delete from " . TABLE_COUPON_RESTRICT . " WHERE coupon_id = '" . $_GET['cid'] . "' and product_id = '" . $new_products->fields['products_id'] . "'");
                $new_products->MoveNext();
              }  
    }
    around line 387

    After:
    Code:
    <!-- body_text_eof //-->
      </tr>
    </table>
    add:

    Code:
    <form name="restrict_specials" method="post" action="<?php echo zen_href_link('coupon_restrict.php', zen_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=specials&info=' . $cInfo->restrict_id, 'NONSSL'); ?>"><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
    <input type="submit" name="add" value="Add Specials">
    </form>
    <form name="remove_specials" method="post" action="<?php echo zen_href_link('coupon_restrict.php', zen_get_all_get_params(array('info', 'action', 'x', 'y')) . 'action=remove_specials&info=' . $cInfo->restrict_id, 'NONSSL'); ?>"><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
    <input type="submit" name="add" value="Remove Specials">
    </form>

    and that's it.

  2. #2
    Join Date
    Jan 2009
    Posts
    65
    Plugin Contributions
    0

    Default Re: Coupon Restriction for Specials - Solution

    Version 1.5


    Thanks fo your contribution. But I tried this and it did not work to restrict the coupon on a special. There are actually 2 instances of where restrict_id = '" . $_GET

    ['info'] . "'");
    }
    }

    I tried both places and did not work. Is there another trick to this?


    Thanks!

  3. #3
    Join Date
    Mar 2007
    Posts
    146
    Plugin Contributions
    6

    Default Re: Coupon Restriction for Specials - Solution

    You need to follow the instructions, no point putting code where it isn't needed.

    You need to give me more info, what aspect isn't working?
    Are the buttons shown?
    Do they add products when you click to add them?
    Do you have any products on special/discount at the moment?
    After adding the products,usig the button, they still allowed to have a discount coupon working on them?

    Its a really simple mod, so there really isn't much to go wrong.

  4. #4
    Join Date
    Feb 2012
    Posts
    15
    Plugin Contributions
    0

    Default Re: Coupon Restriction for Specials - Solution

    Worked perfectly for me thank you!!!
    If anyone's trying it, remember that once you've pasted in the first block; for the second chunk, line 387 is no longer at line 387 as you've added several lines above it with the first paste (was line 414 on mine).

 

 

Similar Threads

  1. Coupon restriction error
    By dre in forum Creating Discounts/Coupons, Gift Certificates, Newsletters
    Replies: 7
    Last Post: 30 Jun 2011, 10:09 AM
  2. Coupon Restriction
    By enzo-ita in forum General Questions
    Replies: 2
    Last Post: 29 Nov 2010, 09:28 AM
  3. Coupon for already reduced item (specials)
    By brooklyn44 in forum Creating Discounts/Coupons, Gift Certificates, Newsletters
    Replies: 0
    Last Post: 3 Sep 2009, 03:35 PM
  4. Coupon and Specials restriction
    By jeking in forum Creating Discounts/Coupons, Gift Certificates, Newsletters
    Replies: 2
    Last Post: 4 Sep 2008, 08:14 PM
  5. Coupon restriction logic
    By dbrewster in forum Creating Discounts/Coupons, Gift Certificates, Newsletters
    Replies: 3
    Last Post: 3 Jul 2006, 06:42 PM

Bookmarks

Posting Permissions

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