Shipping Quote based on Per Cent of Total Order

By | May 18, 2008

In the past few days I noticed a couple of people wanting to charge postage based on a percentage of the total order amount.

I’ve not come across any pre-existing code that enables this in a correct way – I do know of a `hack` to the “products weight” field, but the problem with that is obvious – what happens if a shop owner wants to use the weight feature of the products? There’s probably other contributions but I like to make my own if I can.

So, I decided to spend a little time making my own “Percentage Shipping” contribution…

Introducing the “Club osCommerce % Shipping Module”

Snazzy name, eh? OK, so basically, in your admin area, you enable the “percent” shipping method and input the % rate you wish to charge – the default value is 10.00%. You can also add a “handling charge” if you need to – the default rate for this is zero.

Have a look at this video

It’s kind of hard to see, but in the admin, I set the rate to 10.00% with a 4.95 handling charge. I then checked out a $39.99 product, and got a shipping quote of $8.95 – this being

$4.00 (10% of $39.99, rounded up)
$4.95 (handling charge)
—–
$8.95

There you have it. A nice easy contribution that will allow you to use shipping based on the value of the order. If you want to make changes to it, please go right ahead. If you want to change the wording, this is done in the LANGUAGE file that is a part of the download.

Get it

You can download this at the official osCommerce add-ons site.

Beer Me!

I would really appreciate it if anyone who uses this module would “buy me a beer” – the “beers” that I receive allow me to spend more time creating osCommerce add-ons etc – cheers, santé, prost!

11 thoughts on “Shipping Quote based on Per Cent of Total Order

  1. Patrick

    Hello from the beer country (Belgium),
    Your contrib was the one I was waiting for.
    I install it on my OSCMax 2 RC3 and it works.
    Easy to install and to configure, for a newbie what else to ask 🙂
    Just, for people who are working with multiple language, don’t forget to insert the /language/***/module/shipping/… in the different language files.
    Again thank you very much.
    Patrick

  2. Gary Post author

    Hi Patrick – thanks for letting me know it works with oscmax 🙂

    There’s nothing better than a Belgian Beer, cheers.

  3. Jason Farrow

    Have you experienced getting your mod to work with the GoogleCheckout mod?
    Google knows nothing of percent when you install your mod.

  4. Gary Post author

    Jason – never tried it. Couldn’t tell you. This is only a shipping modification, hence should work OK with all other contributions that are coded correctly.

  5. Mike

    Awesome, this is what I’ve been looking for! How could I add another percentage level? Say I have two options: 1 option for express post that I set to 8% and one for regular post that I’d set to 4%. Just rename the php files and install?

  6. Gary Post author

    Mike – you’d probably need to rename the files and ALSO rename the “functions” etc inside those files. Cheers, Gary

  7. blackhawk

    hello,
    is there a way with this module to set a flate rate of 9.95 below the total of 101.00 dollars and then do the percentage by the total if the total order is over 100 dollars?

    thanks!

  8. Gary Post author

    Yes – you would need to add in an extra box input in the admin screen, then get the cart amount in the module and determine what to charge. Fairly straightforward.

    I can quote you if you wish. oscshops@gmail.com

  9. Gary Post author

    Little bug found in this module. Fix;

    Find this:

    // class methods
    function quote($method = ”) {
    global $order;

    Change to:

    // class methods
    function quote($method = ”) {
    global $order, $cart;

    Find this:

    ‘cost’ => ($order->info[‘total’] * (MODULE_SHIPPING_PERCENT_COST/100)) + MODULE_SHIPPING_PERCENT_HANDLING)));

    Change to:

    ‘cost’ => ($cart->show_total() * (MODULE_SHIPPING_PERCENT_COST/100)) + MODULE_SHIPPING_PERCENT_HANDLING)));

  10. Gary Post author

    Peter – follow the install instructions, should be very straightforward.

Leave a Reply

Your email address will not be published.