Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Calculating Shipping based on percentage of "weight"


WoodsWalker

Recommended Posts

Hi Folks!

 

I've been running my store for some time using a table rate contribution that allows me to add multiple zones, and to use the modes "Weight", "Price", "Percentage", "Item-count", or "Per_Item".

 

I've been using the "Percentage" mode, calculating by a percentage of the order price, and that's been fine.

 

However, sometimes this leads to unrealistically high shipping quotes, because some of my products are light, and others heavy.

 

In order not to upset my set-up, which works well otherwise, I thought I might be able to calculate the shipping based on a percentage of a custom value that I would place in the "weight" column (instead of using the value in the "price" column). Just a simple change, but I'm not sure how to go about it. I've only recently begun to delve into PHP and the database itself, but will go there willingly with some help.

 

I would be most grateful for some direction. Thanks in advance!

 

~Wendy

Edited by WoodsWalker
Link to comment
Share on other sites

Well, necessity being the mother of invention, I eventually answered it myself! B)

 

The key was to look in the shipping modules I was using (the file in the table rate contribtion I am using is called "regionsclass.php", but this procedure can be adapted to most shipping modules) for:

 

$shipping =

 

In my case, this appeared in this context:

 

$shipping = ($regionsclass_table[$i+1] / 100) * $order_total_price;

 

I looked around in the code for likely possibilities, and tried replacing "$total_order_price" with a string I saw in the "weight" option part of the file, "$shipping_weight", like so:

 

$shipping = ($regionsclass_table[$i+1] / 100) * $shipping_weight;

 

...and it did exactly what I wanted. Shazam!

 

~Wendy

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...