Shipping by Rules for VirtueMart

IMPORTANT ANNOUNCEMENT: Plugin development ceased, all plugins made available freely (GPL)

With great sadness we have to announce that we are ceasing development of all our VirtueMart, WooCommerce and Joomla plugins. Effective immediately, all our plugins -- even those that were paid downloads -- are made available for free from our homepage (GPL license still applies), but we cannot and will not provide any support anymore.

It has been a great pleasure to be part of the thriving development communities of VirtueMart as well as WooCommerce. However, during the last year it became painstakingly clear that in addition to a full-time job, a young family and several other time-consuming hobbies at professional level (like being a professional singer) the plugin development and the support that it requires is not sustainable and is taking its toll. It has been an honor, but it is now time to say good bye!



The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1


Weight based per kilo shipping rule 10 Jun 2013 10:22 #1

  • illusiondrmr
  • illusiondrmr's Avatar Topic Author
Hello and thanks for this perfect tool !
I've just purchased Advanced shipping rules and my question is (before my poor mathematic mind blow up ;>) the following :

I got the following rule from the transport company here in country : Weight less or equal we got a fixed price of 2.90euro. For every other kilo the price is affected plus 1 euro (+1). The following rule i made up according to your examples is the following :

Name=Less or equal 2Kg; 10000<=ZIP<20000; Weight<=2; Shipping=2.90
Name=Over 2Kg; 10000<=ZIP<20000; 2<Weight; Shipping=2.90+1*(Weight-2)

HOWEVER, lets say we got a weight of 2.5 kilos. The shipping result is 3.40. Which aint what we want. We want the cost to be 3.90. (because is IN THE RANGE of 2<weight<3). Same way goes if we suppose we got a number of kilos @ 3.5. The price should be 2.9 + 1 + 1 = 4.90.

Could you please give the correct mathematic rule for this case, because my poor mathematic mind cant handle it !!

Thnx !!

Weight based per kilo shipping rule 15 Jun 2013 14:28 #2

Rounding up the weight variable is not (yet?) implemented in the plugin, so for now you'll have to resort to some workarounds. See e.g. the example section on the homepage: open-tools.net/component/content/article...ipping-by-rules.html

In short: you can use the modulo operator (%) to cut off the decimal part of the weight and then add 1.

Weight based per kilo shipping rule 15 Jun 2013 14:53 #3

  • illusiondrmr
  • illusiondrmr's Avatar Topic Author
Thanks for the answer,

Could you please give me exactly the rule for the example i set above? ( for weight>2 , each additional kilo cost + 1euro ).

Weight based per kilo shipping rule 15 Jun 2013 15:08 #4

I haven't tested it, but something like the following should work in the latest version 2.4.7:
Name=Over 2kg; 10000<=ZIP<20000; 2<Weight; Shipping=2.90+(weight-0.000001+1)-( (weight-0.000001) % 1);

Weight based per kilo shipping rule 15 Jun 2013 15:30 #5

  • illusiondrmr
  • illusiondrmr's Avatar Topic Author
Just tested, for a weight of 2.5 kilos the shipping cost result is 6.40euro(where it should be 3.90). Guess something aint working right ;<

Weight based per kilo shipping rule 15 Jun 2013 17:09 #6

First, please install the latest version 2.4.7, which fixes a bug with the % operator. This should result in costs of 5.90.

And secont, of course I forgot to subtract the 2 for the first two kgs. So simply subtract 2 froml the shipping variable in the rule, and things should work.

Weight based per kilo shipping rule 17 Jun 2013 13:52 #7

  • illusiondrmr
  • illusiondrmr's Avatar Topic Author
Yes ! That works ! (With the latest version)

EDIT : Seems that something is wrong again ;>

Shipping rule : 2.70euro for 2 kilos. For 2 kilos and over, the cost increasing 0.80 each kilo. So, we should have results of 3.50, 4,30, 5,10 etc

Using this rule :
Name=Over 2 kilos - Total amount; 500==ZIP; 2<Weight; Shipping=2.70+(weight-0.000001+0.80)-( (weight-0.000001) % 1) - 2
Got the following results :

For 2.5 kilos result is 3.50 (correct)
For 3.5 kilos result is 4.50 (wrong) (Should be 4.30)
For 4.5 kilos result is 5.50 (wrong) (Should be 5.10)
For 5.5 kilos result is 6.50 (wrong) (Should be 5.90)

I assume that i got something wrong in my shipping rule ??

EDIT2 : Got the correct rule after 1 hour of tryings ;p

Name=Test modulo; 500==ZIP; 2<Weight; Shipping=2.70+0.80*( (Weight-0.000001+1)-( (Weight-0.000001) % 1) )-1.60

One last question :

Is it possible to show the Total amount of Weight ? For example something like this :

Name=Over 2 kilos - Total amount : "$Weight"; 500==ZIP; 2<Weight; Shipping=2.70+0.80*( (Weight-0.000001+1)-( (Weight-0.000001) % 1) )-1.60

(Where $Weight would show to the customer the total amount of weight).

Weight based per kilo shipping rule 19 Jun 2013 15:00 #8

Version 3.0.0 is now available, which adds the following features:
-) Functions like round(..), ceil(...), max(...), min(...)
-) New variables TotalPackaging, MinPackaging and MaxPackaging
-) Variable substitutions in the rule names: {varname} will be replaced by the value

With that version, you can simply use ceil(Weight) to round the weight up to the next full kg.

And your other suggestion is also implemented: e.g. {weight} in the rule name will be replaced by the total weight of the order.

Weight based per kilo shipping rule 19 Jun 2013 15:33 #9

  • illusiondrmr
  • illusiondrmr's Avatar Topic Author
Well done reinhold..

Example : 2.60 for the first 2 kilos and + 0.80 for every extra kilo

So it seems like the rule will be as simple as :

Name=Over 2 kilos - Total weight : {Weight}; 10000<=ZIP<20000 OR 80100<=ZIP<=80200; 2<Weight; Shipping=2.60+0.80*(ceil(Weight)-2)

Thank you very much..

Weight based per kilo shipping rule 19 Jun 2013 22:57 #10

Yes, that rule looks like it should implement your description.

[SOLVED] Weight based per kilo shipping rule 20 Jun 2013 08:39 #11

  • illusiondrmr
  • illusiondrmr's Avatar Topic Author
Problem solved.
  • Page:
  • 1