Results 1 to 10 of 17

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Posts
    17
    Plugin Contributions
    0

    Default Seperate shipping method by category - USPS with FLAT rate for 1 master category

    Hello,
    Version is Zen Cart 1.3.7

    I know this has been gone over and I have searched and read many entries but still do not quite get how to do this.

    Our Store http://santas-village-shop.com/zen2/ sells many items, most of which can be shipped USPS and that works well. I have 3 items in Master category 5 that I would like to set a flat rate of $3 to ship. I do not want flat rate to show up on any other items.

    I will provide textual instructions to the customer to tell them these items must be purchased separately.

    SO:

    if category 5 item, flat rate $3 - No other shipping method
    If any other category USPS - No Flat rate

    A method of doing this that allows shipping costs to be added together at checkout would be ideal so that the customer doesn't have to do 2 orders if they want to purchase from category 5 and an item from another category. However as stated above, I can provide textual instructions to the customer if needed.

    Any help would be greatly appreciated

    Thank you
    Ed LaBonte
    Santa's I.T. Elf

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

    Default Re: Seperate shipping method by category - USPS with FLAT rate for 1 master category

    Have you considered checking how many Products are in the Cart from category 5 and if:

    all are from category 5 use Flat Rate ...

    none are from category 5 use USPS ...

    if 1 or more are from category 5 but other products are in the cart, adjust the price for them and use USPS ...
    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: v1.5.5]
    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 2005
    Posts
    17
    Plugin Contributions
    0

    Default Re: Seperate shipping method by category - USPS with FLAT rate for 1 master category

    Hi and Thank you!!

    That sounds great but How what where? Would you be able to give me a little more assistance?

    Thank you
    Ed

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

    Default Re: Seperate shipping method by category - USPS with FLAT rate for 1 master category

    You would edit the file:
    /includes/modules/shipping/flat.php

    and add the code in RED:
    Code:
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
          }
    
    // bof: turn off if not only Category 5 based on master_categories_id
          if (!IS_ADMIN_FLAG) {
            global $db, $cart;
            // check how many products are in the cart for products_id 12, 17, 18
            $chk_products = 0;
            $chk_products += $_SESSION['cart']->in_cart_check('master_categories_id', '5');
            if ($chk_products != $_SESSION[cart]->count_contents()) {
              // turn off shipping module
              $this->enabled = false;
            }
          }
    // eof: turn off if not only Category 5 based on master_categories_id
    
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
    Then in the USPS module:
    /includes/modules/shipping/usps.php

    add code in RED:
    Code:
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
        }
    
    // bof: turn off if only Category 5 based on master_categories_id
          if (!IS_ADMIN_FLAG) {
            global $db, $cart;
            // check how many products are in the cart for products_id 12, 17, 18
            $chk_products = 0;
            $chk_products += $_SESSION['cart']->in_cart_check('master_categories_id', '5');
            if ($chk_products == $_SESSION[cart]->count_contents()) {
              // turn off shipping module
              $this->enabled = false;
            }
          }
    // eof: turn off if only Category 5 based on master_categories_id
    
        if ($this->enabled) {
    and then in the quote for it add the code in RED:
    Code:
              $cost = preg_replace('/[^0-9.]/', '',  $cost);         
    //echo 'USPS: ' . $type . ' cost: ' . $cost . '<br>';
    
    // bof: add $5.00 if 1 or more Category 5 based on master_categories_id
            global $cart;
            // check how many products are in the cart for products_id 12, 17, 18
            $chk_products = 0;
            $extra_charge = 0.00;
            $chk_products += $_SESSION['cart']->in_cart_check('master_categories_id', '5');
            if ($chk_products > 0) {
              // charge $5.00
              $extra_charge = 5.00;
            }
          }
    
              $methods[] = array('id' => $type,
                                 'title' => $title,
                                 'cost' => ($cost * $shipping_num_boxes) + $extra_charge + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
    // eof: add $5.00 if 1 or more Category 5 based on master_categories_id
    
            }
    
            $this->quotes['methods'] = $methods;
    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: v1.5.5]
    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 2005
    Posts
    17
    Plugin Contributions
    0

    Default Re: Seperate shipping method by category - USPS with FLAT rate for 1 master category

    Good Morning!

    I have added your code in I think the right places but am having a bit of difficulty. When I upload the modified usps.php file the store does nothing when going to checkout and I cannot access the shipping modules settings under the admin page.

    Here is the code as I added it.

    thank you
    Ed
    Code:
    <?php
    /**
     * USPS Module for Zen Cart v1.3.x
     * RateV3 Updates to: January 2, 2011
     *
     * @package shippingMethod
     * @copyright Copyright 2003-2011 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: usps.php 18306 2011-01-03 01:09:49Z ajeh $
     */
    /**
     * USPS Shipping Module class
     *
     */
    class usps extends base {
      /**
       * Declare shipping module alias code
       *
       * @var string
       */
      var $code;
      /**
       * Shipping module display name
       *
       * @var string
       */
      var $title;
      /**
       * Shipping module display description
       *
       * @var string
       */
      var $description;
      /**
       * Shipping module icon filename/path
       *
       * @var string
       */
      var $icon;
      /**
       * Shipping module status
       *
       * @var boolean
       */
      var $enabled;
      /**
       * Shipping module list of supported countries (unique to USPS/UPS)
       *
       * @var array
       */
      var $countries;
      /**
       * Constructor
       *
       * @return usps
       */
    
    // use USPS translations for US shops
       var $usps_countries;
    
      function usps() {
        global $order, $db, $template, $current_page_base;
    
        $this->code = 'usps';
        $this->title = MODULE_SHIPPING_USPS_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_USPS_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_USPS_SORT_ORDER;
        $this->icon = $template->get_template_dir('shipping_usps.gif', DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . 'shipping_usps.gif';
        $this->tax_class = MODULE_SHIPPING_USPS_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_USPS_TAX_BASIS;
    
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
        }
    
    // bof: turn off if only Category 5 based on master_categories_id
          if (!IS_ADMIN_FLAG) {
            global $db, $cart;
            // check how many products are in the cart for products_id 12, 17, 18
            $chk_products = 0;
            $chk_products += $_SESSION['cart']->in_cart_check('master_categories_id', '5');
            if ($chk_products == $_SESSION[cart]->count_contents()) {
              // turn off shipping module
              $this->enabled = false;
            }
          }
    // eof: turn off if only Category 5 based on master_categories_id
    
        if ($this->enabled) {
          // check MODULE_SHIPPING_USPS_HANDLING_METHOD is in
          $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_HANDLING_METHOD'");
          if ($check_query->EOF) {
            $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_USPS_HANDLING_METHOD', 'Box', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
          }
        }
    
        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_USPS_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;
          }
        }
    
        $this->types = array('EXPRESS' => 'Express Mail',
            'FIRST CLASS' => 'First-Class Mail',
            'PRIORITY' => 'Priority Mail',
            'PARCEL' => 'Parcel Post',
            'MEDIA' => 'Media Mail',
            'BPM' => 'Bound Printed Matter',
            'LIBRARY' => 'Library'
            );
    /*
        $this->intl_types = array(
            'Global Express' => 'Global Express Guaranteed (GXG)',
            'Global Express Non-Doc Rect' => 'Global Express Guaranteed Non-Document Rectangular',
            'Global Express Non-Doc Non-Rect' => 'Global Express Guaranteed Non-Document Non-Rectangular',
            'Global Express Envelopes' => 'USPS GXG Envelopes',
            'Express Mail Int' => 'Express Mail International',
            'Express Mail Int Flat Rate Env' => 'Express Mail International Flat Rate Envelope',
            'Priority Mail International' => 'Priority Mail International',
            'Priority Mail Int Flat Rate Env' => 'Priority Mail International Flat Rate Envelope',
            'Priority Mail Int Flat Rate Box' => 'Priority Mail International Flat Rate Box',
            'Priority Mail Int Flat Rate Small Box' => 'Priority Mail International Small Flat Rate Box',
            'Priority Mail Int Flat Rate Med Box' => 'Priority Mail International Medium Flat Rate Box',
            'Priority Mail Int Flat Rate Lrg Box' => 'Priority Mail International Large Flat Rate Box',
            'First Class Mail Int Lrg Env' => 'First-Class Mail International Large Envelope',
            'First Class Mail Int Package' => 'First-Class Mail International Package',
            'First Class Mail Int Letter' => 'First-Class Mail International Letter'
            );
    */
    // update and add new shipping names 01-02-2011
    // 4 6 7 12 1 10 [17] 2 11 9 16 [24] [25] 8 [22] [23] [18] [20] 14 15 13
        $this->intl_types = array(
    // old
            'Global Express' => 'Global Express Guaranteed (GXG)**', // ID="4" 'Global Express Guaranteed (GXG)'
            'Global Express Non-Doc Rect' => 'Global Express Guaranteed Non-Document Rectangular', // ID="6" 'Global Express Guaranteed Non-Document Rectangular'
            'Global Express Non-Doc Non-Rect' => 'Global Express Guaranteed Non-Document Non-Rectangular', // ID="7" 'Global Express Guaranteed Non-Document Non-Rectangular'
            'USPS GXG Envelopes' => 'USPS GXG Envelopes**', // ID="12" 'USPS GXG Envelopes'
            'Express Mail Int' => 'Express Mail International', // ID="1" 'Express Mail International'
            'Express Mail Int Flat Rate Env' => 'Express Mail International Flat Rate Envelope', // ID="10" 'Express Mail International Flat Rate Envelope'
    // new 01-01-2011
            'Express Mail Int Legal' => 'Express Mail International Legal Flat Rate Envelope', // ID="17"
    // old
            'Priority Mail International' => 'Priority Mail International', // ID="2" 'Priority Mail International'
            'Priority Mail Int Flat Rate Lrg Box' => 'Priority Mail International Large Flat Rate Box', // ID="11" 'Priority Mail International Large Flat Rate Box'
            'Priority Mail Int Flat Rate Med Box' => 'Priority Mail International Medium Flat Rate Box', // ID="9" 'Priority Mail International Medium Flat Rate Box'
            'Priority Mail Int Flat Rate Small Box' => 'Priority Mail International Small Flat Rate Box**', // ID="16" 'Priority Mail International Small Flat Rate Box'
    // new 01-01-2011
            'Priority Mail Int DVD' => 'Priority Mail International DVD Flat Rate Box**', // ID="24"
            'Priority Mail Int Lrg Video' => 'Priority Mail International Large Video Flat Rate Box**', // ID="25"
    // old
            'Priority Mail Int Flat Rate Env' => 'Priority Mail International Flat Rate Envelope**', // ID="8" 'Priority Mail International Flat Rate Envelope',
    // new 01-01-2011
            'Priority Mail Int Legal Flat Rate Env' => 'Priority Mail International Legal Flat Rate Envelope**', // ID="22"
            'Priority Mail Int Padded Flat Rate Env' => 'Priority Mail International Padded Flat Rate Envelope**', // ID="23"
            'Priority Mail Int Gift Card Flat Rate Env' => 'Priority Mail International Gift Card Flat Rate Envelope**', // ID=18
            'Priority Mail Int Small Flat Rate Env' => 'Priority Mail International Small Flat Rate Envelope**', // ID="20"
    // old
            'First Class Mail Int Lrg Env' => 'First-Class Mail International Large Envelope**', // ID="14" 'First-Class Mail International Large Envelope'
            'First Class Mail Int Package' => 'First-Class Mail International Package**', // ID="15" 'First-Class Mail International Package'
            'First Class Mail Int Letter' => 'First-Class Mail International Letter**' // ID="13" 'First-Class Mail International Letter' // ID="13"
    
            );
    
        $this->countries = $this->country_list();
    
    // use USPS translations for US shops
        $this->usps_countries = $this->usps_translation();
    
      }
    Last edited by Ajeh; 11 Jan 2012 at 03:28 PM. Reason: fix code display

  6. #6
    Join Date
    Dec 2005
    Posts
    17
    Plugin Contributions
    0

    Default Re: Seperate shipping method by category - USPS with FLAT rate for 1 master category

    Hi,
    After further testing I find that the flat rate shows up for the category5 items and not for any other items without the usps edits. This is great. Halfway there. Thank you

  7. #7
    Join Date
    Jul 2008
    Posts
    113
    Plugin Contributions
    0

    Default MEDIA MAIL rates for specific products or categories?

    I want to add a book section to my shop, and if the only thing they're ordering is books then I need the checkout to switch over to MEDIA MAIL shipping quotes.

    I found a partial solution under the thread, Seperate shipping method by category - USPS with FLAT rate for 1 master category and I posted a question there -- but it wasn't discovered apparently.

    But the solution in that thread only allows for assigning ONE master category ID for flat rate shipping. I need about a dozen book categories (under one parent ID) and I would rather use true USPS media mail shipping - but if the flat rate is a better work-around, then that's fine.

    Are other people having this problem? I'm the only one selling books as well as other items through my shop? That seems a little surprising.
    I've searched the forum and there doesn't seem to be much info on MEDIA MAIL even though this is a very significant shipping category for anyone who sells books or DVDs.

 

 

Similar Threads

  1. v151 Flat rate shipping based on master category ID?
    By snowgoose in forum Built-in Shipping and Payment Modules
    Replies: 18
    Last Post: 26 Mar 2014, 10:35 PM
  2. Replies: 98
    Last Post: 26 Feb 2014, 08:33 PM
  3. how to have flat rate shipping options seperate for each item???
    By skyman2345 in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 17 Feb 2010, 10:55 PM
  4. Shipping method not showing for cloned flat rate zone
    By wildfashions in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 27 Apr 2009, 03:41 AM
  5. Flat rate shipping PER CATEGORY
    By apemusic in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 14 Jun 2008, 06:34 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR