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


Shipping by ZIP & Weight 28 May 2014 15:11 #1

  • darren.mrtn1
  • darren.mrtn1's Avatar Topic Author

I'm trying to set up shipping that will check ZIP and weight group to get price

I have spent hours and tried all ways but I always get the lowest rate (22) even though the product I'm testing is 52kg

here is an eg
Name=3003; ZIP==3003; Weight<25; Shipping=22;
Name=30031;ZIP==3003; 25<=Weight<=50; Shipping=42
Name=30032;ZIP==3003; 50<=Weight<=100; Shipping=62

where am I going wrong? PLEASE help


Shipping by ZIP & Weight 02 Jun 2014 11:09 #2

It might be an issue with the weight units. Can you add a term
Name=3003 weight is {weight}; ZIP==.....

This should print out the weight of the order in the shipment name and can giveyou an idea of the magnitude...

See also www.open-tools.net/forum/shipping-by-rul...t-kilogram.html#4945 and www.open-tools.net/documentation/shippin...emart.html#debugging

Best regards,

Shipping by ZIP & Weight 07 Jun 2014 07:39 #3

  • darren.mrtn1
  • darren.mrtn1's Avatar Topic Author
Thank you for your reply,

I did get this working, however I then changed it from ZIP to city as the shipping rates can vary quiet a lot within one ZIP code in Australia
The problem I have now is that although it is working fine, it is extremely slow (25 - 30 seconds)to load the cart and then to change address, change quantity, select shipping method etc. is equally as slow

I have a heap of rules as I have set it up for 16000 suburbs based on suburb name then ZIP (as some states have suburbs with the same name) then it calculates by weight, so most of these suburbs have 2 rules each which gives me approx 32000 rules

here is an example for 1 suburb

Weight<50; Name=3011SEDDON WEST; City=="SEDDON WEST" OR City=="Seddon West" OR City=="seddon west"; ZIP==3011; Shipping=ceil(((18.3+(1.18*Weight)*1.159)*1.1),5)
Weight>50; Name=3011SEDDON WEST; City=="SEDDON WEST" OR City=="Seddon West" OR City=="seddon west"; ZIP==3011; Shipping=ceil((((18.3+(1.18*Weight)+41.6)*1.159)*1.1),5)

I have entered these rules in groups off 100 (100 lines of code per shipping rule in VM) as it wont save with much more than 100 lines

Is there anyway to speed up the checkout page without losing any of the rules?


Shipping by ZIP & Weight 19 Jun 2014 19:51 #4

I don't think there is an easy way around the speed issue, because VM calls the plugin at least twice on each page load to offer/calculate the shipping costs. Each time all rules have to be parsed and converted from a huge string into mathematical expression trees, and then checked for a match with the current cart values. Unfortunately, there is no caching possible, either.

The only possible solution would be to optimize your rules structure...
Basing anything on the entered city name is not a good idea in any case, because users will used lots of different spellings with typos etc., which cannot be handled with that approach.

Regarding the limited length for the rules: VM dedicates a database field of max. ~19.000 characters to each shipping method to store its configuration. Of course, this implies that all rules of a shipping method must not be longer that 19.000 characters (actually a bit less, since other settings also need to be stored)...

Sorry that I can't be more constructive, but the performance issue can only be solved by reducing the number of your rules...

Best regards,
  • Page:
  • 1