Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25
  1. #11
    Join Date
    Sep 2011
    Posts
    86
    Plugin Contributions
    0

    Default Re: Blocking usage of Group Discount & Discount Coupons

    Ok,

    I am doing something wrong.

    Here is the code in the order I have it.
    // bof: stop discount coupon for anyone in a customer group
    global $db;
    $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . $_SESSION['customer_id'] . "'");
    if ($chk_group->fields['customers_group_pricing'] > 0) {
    $allow_discount = false;
    } else {
    $allow_discount = true;
    }

    if ($discount_coupon->fields['coupon_code'] == 'abc123') {
    global $db;
    $chk_group = $db->Execute("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . $_SESSION['customer_id'] . "'");
    if ($chk_group->RecordCount() > 0) {
    $allow_discount = false;
    } else {
    $allow_discount = true;
    }
    }

    I have it starting at line 500 of the ot_coupon.php.

    Is this right?

    Please I am sorry, but I think I need to know what line it should be inserted at.

  2. #12
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Blocking usage of Group Discount & Discount Coupons

    It might be better to write it this way for that function:
    Code:
      function credit_selection() {
        global $discount_coupon;
        // note the placement of the redeem code can be moved within the array on the instructions or the title
    
    // bof: stop discount coupon for anyone in a customer group
        global $db;
        $allow_discount = true;
        $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . $_SESSION['customer_id'] . "'");
        if ($chk_group->fields['customers_group_pricing'] > 0) {
          $allow_discount = false;
        }
    
    
        if ($allow_discount) {
        // eof: stop discount coupon for anyone with an order
        $selection = array('id' => $this->code,
                           'module' => $this->title,
                           'redeem_instructions' => MODULE_ORDER_TOTAL_COUPON_REDEEM_INSTRUCTIONS . ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_REMOVE_INSTRUCTIONS : ''),
                           'fields' => array(array('title' => ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_TEXT_CURRENT_CODE . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $discount_coupon->fields['coupon_code'] . '</a><br />' : '') . MODULE_ORDER_TOTAL_COUPON_TEXT_ENTER_CODE,
                                                   'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'),
                                                   'tag' => 'disc-'.$this->code
                           )));
        }
        return $selection;
      }
    Then for blocking the coupon abc123 from customers with previous orders go to the function collect_posts and add the test for that coupon ...
    Code:
    // bof: coupon abc123 for first time customers only
        if ($discount_coupon->fields['coupon_code'] == 'abc123') {
          global $db;
          $chk_group = $db->Execute("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . $_SESSION['customer_id'] . "'");
          if ($chk_group->RecordCount() > 0) {
            $foundvalid = false;
          }
        }
    // eof: coupon abc123 for first time customers only
    
            if (!$foundvalid) {
              $this->clear_posts();
            }
    First, set that the coupon is valid, then do the two tests and only worry about setting the coupon as invalid based on the IF conditions ...

    If neither are valid, the the coupon is valid, if either the group is valid or the coupon is abc123 and there is a previous order, the the coupon would not processes ...

    See if that works better ...

    The reason for the change is, the first condition on the Customer Groups is to stop ALL coupons from happening for a customer in a group ... the second one is to only stop a specific coupon from a customer with a previous order and not stop the customer for using other coupons that might be valid ...
    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: v1.5.5]
    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!

  3. #13
    Join Date
    Sep 2011
    Posts
    86
    Plugin Contributions
    0

    Default Re: Blocking usage of Group Discount & Discount Coupons

    Ok,

    trying it today,

    I am still a little worried about at what line of the ot_coupon.php I should be inserting this new code though.

  4. #14
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Blocking usage of Group Discount & Discount Coupons

    The first part, I gave you the whole function credit_selection so that you can just replace that with the new code ...

    The second one, look for the existing code:
    Code:
            if (!$foundvalid) {
              $this->clear_posts();
            }
    and place the new code in RED above it ...
    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: v1.5.5]
    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!

  5. #15
    Join Date
    Sep 2011
    Posts
    86
    Plugin Contributions
    0

    Default Re: Blocking usage of Group Discount & Discount Coupons

    Ok, here is what I did.

    I went into the adim coupon, and added abc123 with the 10% discount.

    I copied the code exaclly as you had it in the example.

    I am confused by the following statment "Then for blocking the coupon abc123 from customers with previous orders go to the function collect_posts and add the test "

    the coupon works but it does not stop me an existing user from using it. I do not know if this matters but I added the COWAO, and I try making the purchase without logging in.

  6. #16
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Blocking usage of Group Discount & Discount Coupons

    Might be my fault, change the IF from:
    Code:
        if ($discount_coupon->fields['coupon_code'] == 'abc123') {
    to read:
    Code:
        if ($dc_check == 'abc123') {
    I just noticed the variable to check changed in that function ...
    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: v1.5.5]
    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!

  7. #17
    Join Date
    Sep 2011
    Posts
    86
    Plugin Contributions
    0

    Default Re: Blocking usage of Group Discount & Discount Coupons

    I made the change, but I might still be doing something wrong, because the code still let me the excisting customer use the discount.

  8. #18
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Blocking usage of Group Discount & Discount Coupons

    What version Zen Cart are you running?

    Are you able to test without the COWAO?
    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: v1.5.5]
    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!

  9. #19
    Join Date
    Sep 2011
    Posts
    86
    Plugin Contributions
    0

    Default Re: Blocking usage of Group Discount & Discount Coupons

    I am running 1.3.9, I can either login or turn off COWAO.

    I am still a little confused by the following statment

    "Then for blocking the coupon abc123 from customers with previous orders go to the function collect_posts and add the test"

    I will try turning COWAO off first.

  10. #20
    Join Date
    Sep 2011
    Posts
    86
    Plugin Contributions
    0

    Default Re: Blocking usage of Group Discount & Discount Coupons

    Ok,

    When i login it does NOT let me use the new coupon.

    Now do you think there is a way to make this work with out having them login, My boss "WIFE" who's buisness it is, does not want to force everyone to have an account to make a purchase.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Disable coupons and group discounts when quantity discount applied?
    By abcisme in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 12 Nov 2015, 12:31 PM
  2. v154 Group Pricing Discount and Discount Coupons show on checkout, paypal/eway charge full
    By edvon in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 22 Sep 2015, 02:27 PM
  3. Set max discount for Group Discount + Discount + etc.
    By KEnik in forum Setting Up Specials and SaleMaker
    Replies: 0
    Last Post: 16 Jun 2010, 05:39 PM
  4. Restrict Wholesale or Discount Group users from using coupons
    By BettyBoop28 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 25 Feb 2010, 12:52 AM
  5. Can I restrict Discount Coupons if Group Discount used?
    By mitch_h in forum General Questions
    Replies: 3
    Last Post: 5 Nov 2009, 02:25 AM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR