Zen Cart Logo
Forums / General Questions / Enable ot_coupon based on a variable

Enable ot_coupon based on a variable

Views: 507

Results 1 to 4 of 4
4 May 2018, 2:55 PM
#1
lindasdd avatar

lindasdd

Zen Follower

Join Date:
Jun 2007
Posts:
474
Plugin Contributions:
0

Enable ot_coupon based on a variable

I'd like to enable or disable the ot_coupon based on a variable in the database.

More specifically, I would like to disable the gift code field for wholesale customers.

My main hang up is that the ot_coupon section doesn't have an "$this>enabled" section to work off of.

I've attempted to stick an if statement into ot_coupon to disable it or change the coupon value to zero, but it just breaks.

Thoughts?

4 May 2018, 6:08 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,081
Plugin Contributions:
56

Re: Enable ot_coupon based on a variable

I did this a couple of years ago for a client by editing /includes/modules/order_total/ot_coupon.php's check function:

/**
  * Enter description here...
  *
  * @return unknown
  */
 function check() {
   global $db;
//-bof-20131129-lat9-Don't enable if the customer is a dealer.
   if (isset($_SESSION['customer_whole']) && $_SESSION['customer_whole'] != '0') {
     $this->check = false;
     
   } elseif (!isset($this->check)) {
//-eof-20131129-lat9
     $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COUPON_STATUS'");
     $this->check = $check_query->RecordCount();
   }

   return $this->check;
 }

... and adding the following script (named header_php_nocouponfordealer.php) to /includes/modules/pages/checkout_payment:

<?php
if (isset($_SESSION['customer_whole']) && $_SESSION['customer_whole'] != '0') {
    foreach ($order_total_modules->modules as $otm => $current_module) {
        if ($current_module == 'ot_coupon.php') {
            unset($order_total_modules->modules[$otm]);
            break;
        }
    }
}
5 May 2018, 9:14 PM
#3
lindasdd avatar

lindasdd

Zen Follower

Join Date:
Jun 2007
Posts:
474
Plugin Contributions:
0

Re: Enable ot_coupon based on a variable

Works. Thank you!

6 May 2018, 10:51 AM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,081
Plugin Contributions:
56

Re: Enable ot_coupon based on a variable

Yea! You're very welcome.