Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2006
    Location
    Wolverhampton, UK
    Posts
    31
    Plugin Contributions
    0

    Default Minimum Shipping Weight

    I know a few people have looked for this so thought I'd just share a small hack / solution.

    I have a UK based site where the shipping is handled by three Royal Mail modules up to 2Kg (Standard delivery, Signed for and Special Delivery). Orders over 2Kg are to be sent via courier. However we only wanted to have Royal Mail showing under 2Kg, and the courier over 2Kg.

    Disabling the Royal Mail modules over 2Kg is simple, in the shipping table the last rate is 2:x.xx so the module automatically disables over that value.

    For the courier shipping there is one price so I am using the Flat rate module that is supplied in a standard installation. However I needed to add something to disable the module under a fixed shipping rate. To do this is fairly straight forward.

    Open the file: /includes/modules/shipping/flat.php
    Save a backup of this file!! Don't skip this step.

    Look for the lines (around line 27):
    function flat() {
    global $order, $db;
    Edit them to look like this, add the bold text:
    function flat() {
    global $order, $db, $total_weight;
    Find the following lines (around line 38):
    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
    $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
    }
    After this add the following bold text.
    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
    $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
    }

    // Minimum Shipping Weight: If the shipping weight less then 2Kg disable the module
    if ($total_weight < 2)
    $this->enabled = false;
    In my example here the minimum shipping weight is 2Kg, so I am checking if the total_weight variable is less then 2, change this value to what you need.

    I'll try to sort this out as a new shipping module that can be installed and the min weight controlled through the Admin pages.

    The same instructions above work for the Table module too.

    Mat

  2. #2
    Join Date
    Mar 2008
    Location
    Cape Town & London (depends on the season)
    Posts
    2,975
    Plugin Contributions
    0

    Default Re: Minimum Shipping Weight

    Great stuff, Mat !

    However, should:-

    PHP Code:
    // Minimum Shipping Weight: If the shipping weight less then 2Kg disable the module
    if ($total_weight 2)
    $this->enabled false
    Rather be:-

    PHP Code:
    // Minimum Shipping Weight: If the shipping weight less then 2Kg disable the module
    if ($total_weight 2) {
    $this->enabled false;

    You can, of course, do the same for MAXIMIM weight by changing the > symbol for < and adjusting your values accordingly.

  3. #3
    Join Date
    Mar 2008
    Location
    Cape Town & London (depends on the season)
    Posts
    2,975
    Plugin Contributions
    0

    Default Re: Minimum Shipping Weight

    There is a small "bug" with this "hack"...

    If you set TARE settings (ADMIN>>>SHIPPING/PACKAGING>>>small / large added % or weight) to anything other than ZERO, the following happens...

    If the total net weight is LESS than 2kg (TARE), but the combined product + packaging weight is MORE than 2kg (GROSS), then the shipping cost gets calculated as 0.00.

    This means that your customer will not be charged for shipping.

    I tested this on a product weighing 1.85kg.

    With packaging factored in, the shipping weight came to 2.05kg.

    The shipping cost then displayed as £0.00

    In order for it to work, you have to disable (set to zero), the TARE settings as described above.

  4. #4
    Join Date
    Mar 2007
    Location
    USA
    Posts
    9
    Plugin Contributions
    0

    Default Re: Minimum Shipping Weight

    I have something similar to this working with UPS and Table rates. If a shipment total weight is over 499lbs, the customer is presented the options in the table rates. If it's under they get UPS (client's choice not mine).
    I've tried playing with the Tare settings and I'm not seeing any errors at all.

    Could it be that the errors you're seeing have something to do with the Royal Mail Mod? I know I made changes to both my /includes/modules/shipping/MYTEMPLATE/table.php and /includes/modules/shipping/MYTEMPLATE/ups.php files.

    Not being from the UK, the Royal Mail mod isn't one I've ever tried...just thought I'd mention this.

    ~KMK

  5. #5
    Join Date
    Apr 2009
    Posts
    4
    Plugin Contributions
    0

    Default Re: Minimum Shipping Weight

    Hello,
    Im planning to make a shipping like this:

    For every 1 kg, the shipping cost would be $5. However, if the total weight is less than 1 kg, the $5 is still applied. Meaning that, $5 is the minimum shipping charge.

    I can see that sumthing can be done here:

    Code:
    // Minimum Shipping Weight: If the shipping weight less then 2Kg disable the module 
    if ($total_weight < 2) 
    $this->enabled = false;
    but i dont know the variables. perhaps the pseudo is like this:
    Code:
    if total item weight < 1kg 
      the shipping cost for 1 kg of total weight applies
    Any ideas?

  6. #6
    Join Date
    Apr 2009
    Posts
    4
    Plugin Contributions
    0

    Default Re: Minimum Shipping Weight

    EDIT:

    Actually, in perweightunit.php, at

    Code:
    	$this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                       'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
                                                                  + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
    Ive changed it to

    Code:
    	if ($total_weight_units < 1) {
    	$this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                       'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
                                                                  + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
    	}	else {
    	$this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                       'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * 1)
                                                                 + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
        }
    However, it loaded as a blank white page

    Any help is very much appreciated. Thanks

  7. #7
    Join Date
    Apr 2009
    Posts
    4
    Plugin Contributions
    0

    Default Re: Minimum Shipping Weight

    OK guys, after fiddling with the codes, I finally got it.

    So, anyone who needs to have the funtion required on ur ZC like me, here are the codes:

    At the includes/modules/shipping/perweightunit.php, at around line 93, you will find this:

    Code:
      function quote($method = '') {
        global $order, $shipping_weight;
    	
    	$total_weight_units = $shipping_weight;
        
    	$this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                       'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
                                                                  + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
    From the codes above, find:
    Code:
    	$this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                       'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
                                                                  + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
    and replace with:


    Code:
    	
            //note that the "1" in the line below is the minimum weight for the shipping charge.  Anything weighing below 1, e.g 0.5 the shipping will still be charged as for 1
            if ($total_weight_units < 1) {
    	$this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                       'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * 1)
                                                                  + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
    	}	else {
    	$this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                       'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
                                                                      + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
    	}
    Thanks for reading

 

 

Similar Threads

  1. Any way to set minimum weight for shipping purposes?
    By johnny roastbeef in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 31 Aug 2011, 10:19 PM
  2. Enable Table Rate Shipping w/ Minimum Order Total OR Weight
    By fepb in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 7 Jul 2007, 06:19 AM
  3. Minimum shipping rate based on weight.
    By ncd in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 29 Jun 2007, 01:45 AM

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