andytc Posted January 11, 2007 Share Posted January 11, 2007 Is a hack or mod available to trigger a shipping method based on weight ? I'd like to only show certain shipping methods if the order is over or under a certain weight ? I've been trying to get this working for a while now , and have searched here and google , found a few bits of code but none work. is this possible ? any help or clue would be much appreciated Quote Link to comment Share on other sites More sharing options...
andytc Posted January 11, 2007 Author Share Posted January 11, 2007 Cracked it !! I'm sooooo happy Quote Link to comment Share on other sites More sharing options...
Photon. Posted January 12, 2007 Share Posted January 12, 2007 Cracked it !! I'm sooooo happy Do you want to share it with us? I would like to do the same. Quote Link to comment Share on other sites More sharing options...
andytc Posted January 12, 2007 Author Share Posted January 12, 2007 Ok , yes ... I compared the code from a royal mail shipping contrib that has this feature alreday and just added it my other 2 shipping modules and adjusted the weight limits to suit. It works fine , don't ask me how it works because i am not an expert , i just compared the code and amde the changes.....that said Find this code in your shipping module. It may look slightly different depending on what module you are looking at , but it will start with // class constructor // class constructor function flat() { global $order; $this->code = 'flat'; $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE; $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false); I changed my ukpostarea module to this - // class constructor function ukpostarea() { global $order, $total_weight; $this->code = 'ukpostarea'; $this->title = MODULE_SHIPPING_UKPOSTAREA_TEXT_TITLE; $this->description = MODULE_SHIPPING_UKPOSTAREA_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_UKPOSTAREA_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_UKPOSTAREA_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_UKPOSTAREA_STATUS == 'True') ? true : false); $this->num_zones = 3; if ($total_weight < 1.5) { // If total ship weight is less than 1.50Kg do not show this shipping method $this->enabled = false; } // To remove this 3.00Kg limit, simply delete these 3 lines. } the code i added is in bold , you may or may not have the zones bit. This is the code form the original roymail contrib that had this already in place - // class constructor function rmfirst() { global $order, $total_weight; $this->code = 'rmfirst'; $this->title = MODULE_SHIPPING_RMFIRST_TEXT_TITLE; $this->description = MODULE_SHIPPING_RMFIRST_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_RMFIRST_SORT_ORDER; $this->icon = DIR_WS_ICONS . 'shipping_rmuk.jpg'; // upload icon to catalog/images/icon directory $this->tax_class = MODULE_SHIPPING_RMFIRST_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_RMFIRST_STATUS == 'True') ? true : false); $this->num_zones = 1; if ($total_weight > 1.5) { // If total ship weight is over 3.00Kg do not show this shipping method $this->enabled = false; // Anything over 3Kg its not economically wise to use this method } // To remove this 3.00Kg limit, simply delete these 3 lines. } To make it not show if under a certain weight, change the section if ($total_weight > 1.5) to if ($total_weight < 1.5) the > is just replaced with < Now , i'm sure that is as clear as mud :D .... but just look at the code and compare it to your own modules that you are using and edit as required and see if it works. It's working for me fine with no problems. As i said ...i'm NOT and expert Quote Link to comment Share on other sites More sharing options...
Photon. Posted January 12, 2007 Share Posted January 12, 2007 Thank a bunch! Like magic. You may not be an expert, but you may be a wiz. Thanks. :thumbsup: I have no idea how that worked, but you saved me time. Works good with UPS because they do not ship on orders over 150lbs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.