Results 1 to 10 of 13

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Restrict shipping module to specific category

    Hello. I'll try to be as specific as possible as shortly as possible. :)

    I am using the FedEx module by numinix located here: https://www.numinix.com/fedex-web-se...b3bf343cd189ce

    What would be the easiest way to disable this shipping module and only allow it to be selected for certain categories? Specifically, the categories are 17-23. 18-23 are all subcategories of 17 like this:
    [FONT="Courier New"]
    17->18->20
    ------->21
    --->19->22
    ------->23
    [/FONT]

    So basically I have two modules, USPS and FedEx. I want USPS to always show, and I want FedEx to only show as an option for the above categories. I'm also fine with creating a new column in the products table if necessary but I'm thinking that won't be needed.

    As always, thanks for your help.

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

    Default Re: Restrict shipping module to specific category

    What happens if 3 Products come from master_categories_id 20, 21, 22 and/or 23 and 1 product comes from another master_categories_id ... does FedEx show?
    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
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Re: Restrict shipping module to specific category

    Good catch. That actually brings up another question I'll post at the end of this reply.

    Preferably, FedEx would only show when all products are in those categories.

    The other question that comes to mind (and I can ask elsewhere if needed) would be if there is a way to not allow checkout if the cart has mixed items. Maybe give a message saying items xxx must be purchased separately. Would be cool since I have some hazmat items that have to ship separately.

    Thanks again.

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

    Default Re: Restrict shipping module to specific category

    You can customize the FedEx with the code in RED to only show if ALL products in the cart use master_categories_id 20, 21, 22 and 23 with:
    Code:
          if (zen_get_shipping_enabled($this->code)) {
    			  $this->enabled = ((MODULE_SHIPPING_FEDEX_EXPRESS_STATUS == 'True') ? true : false);
          }
          
        if (!IS_ADMIN_FLAG) {
          global $cart;
          $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','20');
          $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','21');
          $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','22');
          $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','23');
          
          if ($_SESSION['cart']->count_contents() == $chk_cat) {
            $this->enabled = false;
          }
        }
          
    
    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
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Re: Restrict shipping module to specific category

    Not sure if I did something wrong, but it shows FedEx no matter what. Below is the first section of the module code:

    PHP Code:
    <?php
    class fedexwebservices {
     var 
    $code$title$description$icon$sort_order$enabled$tax_class$fedex_key$fedex_pwd$fedex_act_num$fedex_meter_num$country;

    //Class Constructor
      
    function fedexwebservices() {
        global 
    $order$customer_id$db;
        
        @
    define('MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY''PpFEn9QGjnR4Wdb2');
        @
    define('MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD''u4hXPKKcpKBw9RQ4n1hBvsJAH');
        @
    define('MODULE_SHIPPING_FEDEX_WEB_SERVICES_INSURE'0); 
        
    $this->code             "fedexwebservices";
        
    $this->title             MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_TITLE;
        
    $this->description      MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEXT_DESCRIPTION;
        
    $this->sort_order        MODULE_SHIPPING_FEDEX_WEB_SERVICES_SORT_ORDER;
        
    $this->handling_fee     MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE;
        
    //$this->icon = DIR_WS_IMAGES . 'fedex-images/fedex.gif';
        
    $this->icon ''
        if (
    zen_get_shipping_enabled($this->code)) {
          
    $this->enabled = ((MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATUS == 'true') ? true false);
        }
        if (!
    IS_ADMIN_FLAG) {
          global 
    $cart;
          
    $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','20');
          
    $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','21');
          
    $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','22');
          
    $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','23');
          
          if (
    $_SESSION['cart']->count_contents() == $chk_cat) {
            
    $this->enabled false;
          }
        }
        
    $this->tax_class        MODULE_SHIPPING_FEDEX_WEB_SERVICES_TAX_CLASS;
        
    $this->fedex_key        MODULE_SHIPPING_FEDEX_WEB_SERVICES_KEY;
        
    $this->fedex_pwd        MODULE_SHIPPING_FEDEX_WEB_SERVICES_PWD;
        
    $this->fedex_act_num    MODULE_SHIPPING_FEDEX_WEB_SERVICES_ACT_NUM;
        
    $this->fedex_meter_num  MODULE_SHIPPING_FEDEX_WEB_SERVICES_METER_NUM;
        if (
    defined("SHIPPING_ORIGIN_COUNTRY")) {
          if ((int)
    SHIPPING_ORIGIN_COUNTRY 0) {
            
    $countries_array zen_get_countries(SHIPPING_ORIGIN_COUNTRYtrue);
            
    $this->country $countries_array['countries_iso_code_2'];
          } else {
            
    $this->country SHIPPING_ORIGIN_COUNTRY;
          }
        } else {
          
    $this->country STORE_ORIGIN_COUNTRY;
        }
        if ( (
    $this->enabled == true) && ((int)MODULE_SHIPPING_FEDEX_WEB_SERVICES_ZONE 0) ) {
          
    $check_flag false;
          
    $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" MODULE_SHIPPING_FEDEX_WEB_SERVICES_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;
          }
        }
      }

      
    //Class Methods
    EDIT:

    Also, I just noticed that it does NOT show FedEx when items in the categories 20-23 are added, but if an item from another category is added then it shows FedEx.
    Last edited by Lanbo; 26 Mar 2012 at 04:02 PM. Reason: MORE INFO

  6. #6
    Join Date
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Re: Restrict shipping module to specific category

    Since categories 15 and 16 are the only ones that cannot ship FedEx (I probably should have mentioned that, sorry), I changed it to this and it appears to work properly. Do you foresee any problems with anything?

    PHP Code:
        if (!IS_ADMIN_FLAG) {
          global 
    $cart;
          
    $chk_cat 0;
          
    $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','15');
          
    $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','16');
          
          if (
    $chk_cat 0) {
            
    $this->enabled false;
          }
        } 
    Thanks again.

 

 

Similar Threads

  1. v150 USPS shipping module...trying to restrict shipping options programmatically
    By ecclescake in forum Addon Shipping Modules
    Replies: 11
    Last Post: 13 Dec 2024, 05:24 AM
  2. v151 Restrict Specific Items from 1st Class Shipping - USPS Module
    By jstevens in forum Addon Shipping Modules
    Replies: 5
    Last Post: 22 Jun 2014, 03:03 AM
  3. Finding way to restrict paypal as payment method for specific item or category?
    By gisco in forum Setting Up Categories, Products, Attributes
    Replies: 20
    Last Post: 29 Apr 2010, 04:38 PM
  4. look for specific module to restrict others on site
    By outlawcat in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 20 Apr 2009, 03:54 PM
  5. Restrict Product Category to specific customers
    By Le Grice in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 20 Mar 2007, 05:33 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