Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

trigger shipping method by weight ?


andytc

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...