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:

Multiply shipping cost for multiple consignments 09 May 2016 12:45 #1

  • mousehawk
  • mousehawk's Avatar Topic Author
My client wants to be able to charge weight- and postcode-based shipping, which multiplies based on how many consignments the order will be split into.

This is the delivery rate system I've already implemented but it turns out this is the pricing for ONE pallet, and some of their customers' orders will consist of more than one pallet.:
www.scotia-supplies.com/delivery/

This is how the Shipping By Rules overview looks:
i.imgur.com/0TQMLZa.png

And this is an example of how I've set up the rules:
i.imgur.com/7GJ0A01.png

A half pallet is defined as anything between 0 - 500kg. A full pallet is defined as 500kg - 1000kg.

An order of 1300kg would be split into 1 full pallet and 1 half pallet. An order of 5600kg would be split into 6 full pallets. Pallet charges would be as shown in the link above, multiplied by the number of full and half pallets.

Can you suggest what might be the best way to do this, short of duplicating all the rules and setting the multi-pallet shipping costs manually?

Thanks!

Multiply shipping cost for multiple consignments 14 May 2016 19:02 #2

Dear MouseHawk,
You can define a custom variable that calculates the number of full and half pallets:
Variable=halfpallets; Value = (ceil(Weight, 500) / 500) % 2
Variable=fullpallets; Value = (ceil(Weight, 500) - halfpallets*500) / 1000

What I do here is to round the weight up to the next full 500kg and divide by 500. E.g. 1300kg will be rounded to 1500, so after division we get 3 (half pallets). However, as two half-pallets are a full pallet, the number of required half pallets is the remainder after division by 2 (this is done with the % operator). Thus, halfpallets will either be 0 or 1.
The full pallets are calculated similarly by rounding up to the next 500kg, subtracting what is already handled by a possible half pallet, and then dividing by 1000kg.

You can then use those two variable to calculate the total shipping charges in each rule, e.g.
Name=Zone 1 ({fullpallets} full, {halfpallets} half pallets); UK_Area=="PH"; 1<=UK_District<=15; Shipping=21.28*fullpallets + 20.16*halfpallets

There is no need to create separate "full size" and "half size" shipping methods, as all rules like the above will correctly handle both cases (and also those cases where multiple pallets are involved).
There is also no need to include the weight condition, as this is already handled by the number of pallets.

Finally, please note that the AND is not really necessary, as two rule parts separated by a semicolon have the exact same effect (all rule parts need to be fulfilled, so this is an implicit AND).

Best regards,
Reinhold

Multiply shipping cost for multiple consignments 08 Jun 2016 12:27 #3

  • mousehawk
  • mousehawk's Avatar Topic Author
This is exactly what I needed, thank you so much! Absolutely spot on.

[SOLVED] Multiply shipping cost for multiple consignments 08 Jun 2016 12:28 #4

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