Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / Hide coupon field in certain item is in cart?

Hide coupon field in certain item is in cart?

Locked

Started by marcopolo on 19 Aug 2010, 12:06 PM · Views: 967

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
19 Aug 2010, 12:06 PM
#1
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
525
Plugin Contributions:
2

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!

marcopolo
Zen Cart 2.2.2 | PHP 8.5.12 | MariaDB 10.11.14

19 Aug 2010, 6:24 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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!

19 Aug 2010, 6:36 PM
#3
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
525
Plugin Contributions:
2

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?

marcopolo
Zen Cart 2.2.2 | PHP 8.5.12 | MariaDB 10.11.14

19 Aug 2010, 11:06 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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:

    // 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:

  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!

19 Aug 2010, 11:28 PM
#5
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
525
Plugin Contributions:
2

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

your awesome thank you!

marcopolo
Zen Cart 2.2.2 | PHP 8.5.12 | MariaDB 10.11.14

20 Aug 2010, 1:17 AM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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!

20 Aug 2010, 10:49 AM
#7
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
525
Plugin Contributions:
2

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

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

marcopolo
Zen Cart 2.2.2 | PHP 8.5.12 | MariaDB 10.11.14