Results 1 to 7 of 7
  1. #1
    Join Date
    May 2008
    Location
    United States
    Posts
    494
    Plugin Contributions
    1

    help question Hide coupon field in certain item is in cart?

    I'm having a hard time with this one and I can not find anything in the form that helps solve this isssue I'm having.

    I use the coupon module however I need to hide it on the checkout page completely if one particular item is in the shopping cart. Even if other items are able to use the coupon this one item needs to override everything else and remove the coupon field from the checkout page.


    I believe the page that I need to edit and add some type of IF statement is either tpl_checkout_payment_default.php in the templates directory or modules/order_total/ot_coupon.php

    Has anyone done this before, or can help me on this? My programming skills are very limited and without some code references...I'm stuck!

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

    Default Re: Hide coupon field in certain item is in cart?

    You can't just set the Restrictions for this Discount Coupon to not allow this 1 Product to receive the Discount ... rather than prevent any Discount Coupons from being used when there are 10 other Products in the cart that could have otherwise been able to use the Discount Coupon and suddenly this 1 Product goes in the cart so your customers now lose out on everything ...
    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!]
    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. #3
    Join Date
    May 2008
    Location
    United States
    Posts
    494
    Plugin Contributions
    1

    Default Re: Hide coupon field in certain item is in cart?

    This particular item is a custom item and the customers that would be adding it to the cart will know that they will not be able to use coupons, I only want to enforce it be hiding the coupon box from displaying on the checkout payment screen, that way they can not try to enter a code anyways.

    Can you help me on this?

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

    Default Re: Hide coupon field in certain item is in cart?

    You need to customize the ot_coupon.php module for a few things ...

    1 you don't want the input box to show if some products_id is in the cart ...

    2 you have to remove the Discount Coupon code if the discount coupon code was added on a valid order ... then the customer continued to shop and added in the invalid products_id ...


    In the collect_posts function add the code:
    Code:
        // bof: hide discount coupon input remove code
        global $cart;
        $chk_hide = $_SESSION['cart']->in_cart_check('products_id','12');
        if ($chk_hide > 0) {
          $foundvalid = false;
        }
        // eof: hide discount coupon input remove code
    
            if (!$foundvalid) {
              $this->clear_posts();
            }

    Change the function credit_selection to read:
    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: hide discount coupon input
        global $cart;
        $chk_hide = $_SESSION['cart']->in_cart_check('products_id','12');
        if ($chk_hide > 0) {
          // hide the input box
        } else {
        $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
                           )));
        }
        // eof: hide discount coupon input
    
        return $selection;
      }
    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!]
    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. #5
    Join Date
    May 2008
    Location
    United States
    Posts
    494
    Plugin Contributions
    1

    Default Re: Hide coupon field in certain item is in cart?

    your awesome thank you!

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

    Default Re: Hide coupon field in certain item is in cart?

    Test it well ...

    There are probably cleaner ways to do this but you needed a few things happening at once plus safeties to prevent coupon codes entered to be removed if the content of the cart changes after it is entered ...
    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!]
    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. #7
    Join Date
    May 2008
    Location
    United States
    Posts
    494
    Plugin Contributions
    1

    Default Re: Hide coupon field in certain item is in cart?

    I tested it last night and it worked perfect, thanks again!

 

 

Similar Threads

  1. v153 Discount coupon sent after purchasing a certain item
    By Josh4u in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 20 Nov 2014, 09:59 PM
  2. v151 Can I hide certain attributes in the shopping cart?
    By jelly8ean in forum Setting Up Categories, Products, Attributes
    Replies: 9
    Last Post: 7 Feb 2013, 03:22 AM
  3. Show comments field below shopping cart if cart contains certain product model
    By frank18 in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 9 Feb 2010, 11:37 AM
  4. Freeshipping it cart contains certain item(s)
    By twdhosting in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 17 Mar 2008, 06:39 PM
  5. Coupon for Free Item if certain amount purchased
    By brimsjewelry in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 11 Dec 2006, 10:47 PM

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