Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

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!

×

Notice

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

TOPIC:

Additional kg rules - weight based shipping 23 Feb 2014 10:29 #1

  • manuxx
  • manuxx's Avatar Topic Author
Hi Reinhold

This are our real rules from the shipping company:

Equal or less than 6 kg= 4.81 €
Equal or less than 11 kg= 5.77 €
Equal or less than 16 kg= 6.73 €
Additional kg 0.30 €

The additional kg means that to the quantity of 6.73 € you add up 0.30 € per each extra kg (superior to 16 kg).

This means that an order of 19 kg would be:

6.73 € (16 kg) + 0.30*3= 0,90 € (3 extra kg)= total 19 kg= 7.63 €

Until now we did it this way, using intervals of 5 kg, which is not the ideal for the customer:
Name=max 6kg; 01000<=ZIP<07000; Weight<=6; Shipping=4.81
Name=max 11kg; 01000<=ZIP<07000; 6<Weight<=11; Shipping=5.77
Name=max 16kg; 01000<=ZIP<07000; 11<Weight<=16; Shipping=6.73
Name=max 21kg; 01000<=ZIP<07000; 16<Weight<=21; Shipping=8.65
Name=max 26kg; 01000<=ZIP<07000; 21<Weight<=26; Shipping=10.58
etc

Can you please inspire us if there is any possible way to make a rule for those additional kg?

We know we can write a line for each kg but maybe there is a formula to avoid that.

Regards

Additional kg rules - weight based shipping 23 Feb 2014 18:40 #2

  • manuxx
  • manuxx's Avatar Topic Author
Name=Shipping; Weight<101; Shipping=6.73+(Weight-16)*0.35

This seems to work but im getting weird roundings in the results.

Additional kg rules - weight based shipping 24 Feb 2014 13:20 #3

Your rule is almost correct: You said that each additional kg is 30c but the formula has 35c per additional kg.

I would use the following set of rules (practically no changes to yours, except for the 30c):
Name=max 6kg; 01000<=ZIP<07000; Weight<=6; Shipping=4.81
Name=max 11kg; 01000<=ZIP<07000; 6<Weight<=11; Shipping=5.77
Name=max 16kg; 01000<=ZIP<07000; 11<Weight<=16; Shipping=6.73
Name=above 16kg; 01000<=ZIP<07000; 16<Weight<101; Shipping=6.73 + (Weight-16)*0.3

Additional kg rules - weight based shipping 24 Feb 2014 13:54 #4

  • manuxx
  • manuxx's Avatar Topic Author
Thanks Reinhold

Now the last doubt is with the roundings.

Name=Weight<101; Shipping=6.73+floor(Weight-15)*0.3

The floor there is intended to round the weight, example: 18.200 kg weight to 18.00 kg this seems to work although im not sure is placed correctly.



Now the doubt is for example

A shipping resulting in 8.02 € we would like to round it to 8.00 €

We tried this but it didnt work out:

Name=Bultos {totalboxes}; Weight<101; Shipping=floor(6.73+floor(Weight-15)*0.3)

Regards

Additional kg rules - weight based shipping 24 Feb 2014 14:09 #5

Ah, right, you want the weight rounded to whole kg. Do you want 30c per full kg, or per partial kg (i.e. if an order has 17.7kg, do you want to charge one or two extra kg above 16kg?)

If you want to charge 30c per partial kg (2kg in the example above), you need to use ceil instead of the floor.

Regarding the rounding of the filnal shipping costs: What exactly didn't work?

Also, how exactly do you want the rounding to work? Do you always want to round down the the next lower Euro-amount? e.g. do you want to round 6.93€ to 6 or 7€? How do you want to adjust 7.53€?

Reinhold

Additional kg rules - weight based shipping 24 Feb 2014 14:20 #6

  • manuxx
  • manuxx's Avatar Topic Author


As you can see the shipping here should be 7.30 but dont know where that cent comes from, maybe from the tax?

So the idea would be to round that to 7.30.

---

Weight rounded to whole kg yes, if an order has 17.7kg charge 2 kg yes, maybe we are wrong using "floor" there.

6.93€ to 7€?

7.53 € to 7.50 or even 7.55 (intervals of 5 cents)

I guess this one is a difficult one.


What it didnt work with:


Name=Bultos {totalboxes}; Weight<101; Shipping=floor(6.73+floor(Weight-15)*0.3)

Is that some shippings had the same cost even with additional kgs added, so different weights had same cost.

Regards

Additional kg rules - weight based shipping 25 Feb 2014 13:38 #7

How do you arrive at the 7.30€ at all? Do you have a sales tax of 8.5%? That's a bit more than 7.30, so rounding might indeed cause this effect. In VM, all costs are given and stored ex tax internally, so when adding the tax, rounding might cause these issues.

On the other hand, if you want to have nice shipping costs with tax included, you can simply use ShippingWithTax=7.30 (or of course the appropriate formula for weights above 16kg), which should calculate the net shipping automatically.

Regarding your rounding problem: Of course if you round to whole Euros, three different kg amounts will result in the same shipping costs.

You can roun to muliples of 0.1 or 0.05, though, by using the (optional) second argument of the round/floor/ceil functions:
open-tools.net/documentation/shipping-by...emart.html#functions

Best regards,
Reinhold

Additional kg rules - weight based shipping 25 Feb 2014 13:51 #8

  • manuxx
  • manuxx's Avatar Topic Author
Oh sorry tax is 4% (fruits & vegs)

Therefore 6.73 + 4% tax= 7 €

with the formula above we are supposed to add 0.30 € per kg which it does.

However the system shows 7.31 €


I saw the documentation for:

round(val, unitval)
floor(val, unitval)
ceil(val, unitval)

But dont really know how it works, I believe we are using it only on a first level,

We are considering just using decimals since nowadays is more common and not such a big issue, is something normal for fruits, ugly but usual.

Regards

Additional kg rules - weight based shipping 25 Feb 2014 14:27 #9

Ah, thanks for the tax explanation: The 31c are actually 30c + 4% tax => 31.2 cents... If you don't need to tax the shipping costs, then you need to set the tax rule in the plugin config accordingly.

Regarding the rounding functions:

Some examples:
round(7.36, 0.1) will round to multiples of 10c => 7.4
round(7.36, 0.05) will round to the nearest 0.05c value => 7.35
round(7.38, 0.05) will round to the nearest 0.05c value => 7.40

floor will always round up, ceil will always round down, round will round to the nearest e.g. 5c value.

This is exactly the functionality that you were thinking in yesterday's post.

Additional kg rules - weight based shipping 27 Feb 2014 12:11 #10

  • manuxx
  • manuxx's Avatar Topic Author
Well many thanks Reinhold. This was really helpfull for us.

As a final question:

Name=Testperkg; Weight<101; Shipping=6.73+floor(Weight-15)*0.3

Imagine for all the result of this formula= Shipping=6.73+floor(Weight-15)*0.3 I want to apply rounding as you explained:

round(7.36, 0.05) will round to the nearest 0.05c value => 7.35

What confused me a bit here is that 7.36 is a value, but how can I apply it to the resulting value of the formula instead of a concrete value, so that the calculated shipping always gets rounded as you described to the nearest 0.05c value.


Regards

Additional kg rules - weight based shipping 27 Feb 2014 21:14 #11

You simply wrap the round( , 0.05) around the whole formula:
Shipping=round(6.73+floor(Weight-15)*0.3, 0.05)

Best regards,
Reinhold

[SOLVED] Additional kg rules - weight based shipping 02 Mar 2014 19:34 #12

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