Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    57
    Plugin Contributions
    0

    Default Hide Table Shipping Module from Certain Customers

    Hi,
    Basically, what I'd like to do is to control which shipping and payment modules are displayed depending on

    which discount group a customer belongs to. I have a wholesale customer that I've added to discount group with ID 1 in my Customers - Discount Group section of Admin. I have the table shipping module and store pickup modules installed. I'd like to hide both these options if my wholesale customer signs in but display them to everybody else.
    I've inserted a function into the table shipping module code that I felt would control this. The PHP

    function verify_customer_group() SHOULD return true if the current user is in discount group ID 1 and false

    if not. Once I get this working for table shipping, I can apply the function to the store pickup module and potentially, any other module I'd like to hide/display for wholesale customers.
    Based on this, I did the following - the file is located in includes/modules/shipping/table.php:

    Code:
    <?php
    /**
     * @package shippingMethod
     * @copyright Copyright 2003-2005 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: table.php 4184 2006-08-21 03:36:36Z ajeh $
     */
    /**
     * Enter description here...
     *
     */
    class table extends base {
      /**
       * Enter description here...
       *
       * @var unknown_type
       */
      var $code;
      /**
       * Enter description here...
       *
       * @var unknown_type
       */
      var $title;
      /**
       * Enter description here...
       *
       * @var unknown_type
       */
      var $description;
      /**
       * Enter description here...
       *
       * @var unknown_type
       */
      var $icon;
      /**
       * Enter description here...
       *
       * @var unknown_type
       */
      var $enabled;
      /**
       * Enter description here...
       *
       * @return table
       */
    
    
      function table() {
        global $order, $db;
    
        $this->code = 'table';
        $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_TABLE_TAX_BASIS;
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false);
        }
    
        // function returns true if user is in discount group id 1, false if not.
        function verify_customer_group() {
           global $db;
    
           $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where 
    
    customers_id = '" . (int)$_SESSION['customer_id'] . "'");
           $group = $group_query->fields['customers_group_pricing'];
           switch($group) {
               case 1:
                    return true; // include these groups
           }
           return false;  // exclude all others
        }
    
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_ZONE > 0) && (verify_customer_group()) ) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . 
    
    MODULE_SHIPPING_TABLE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by 
    
    zone_id");
          while (!$check->EOF) {
            if ($check->fields['zone_id'] < 1) {
              $check_flag = true;
              break;
            } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
              $check_flag = true;
              break;
            }
            $check->MoveNext();
          }
    
          if ($check_flag == false) {
            $this->enabled = false;
          }
        }
      }
    ......
    Thanks for any help!
    Bearaman

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

    Default Re: Hide Table Shipping Module from Certain Customers

    Controlling the $this->enabled is the key ...

    Look how that is altered in the shipping modules now for various conditions and you can add your own to control this even further ...
    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!

 

 

Similar Threads

  1. Hide table rate shipping under a certain weight
    By Kcin in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 20 Jul 2020, 04:45 PM
  2. v153 How to disable table rate shipping module after certain weight
    By samuxul in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 4 Mar 2015, 04:45 AM
  3. v151 Hide module from certain state
    By jimmie in forum Addon Shipping Modules
    Replies: 40
    Last Post: 14 Dec 2014, 09:15 PM
  4. v139h Hide COD payment method from certain customers?
    By TroyC in forum General Questions
    Replies: 3
    Last Post: 5 Apr 2013, 04:19 PM
  5. Hide certain products from a group of users
    By mohammedsk in forum Basic Configuration
    Replies: 4
    Last Post: 29 Dec 2009, 06:31 AM

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