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:

Rulshipping rule by Weight, volume and zip 01 Sep 2015 13:13 #1

  • andreashsalim
  • andreashsalim's Avatar Topic Author
just pruchased the plugin...looks great!

please help with the rule

Calc Fee 1: (LXWXH)/6 x 1
calc Fee 2: Fixed rate determined by (10730<=zipcode< 11850)

when calc fee 1 > calc fee 2, then the shipment fee = calc fee 1


The shipment fee will use which ever with the higher value
is that possible to have the rule for over 8000 zipcodes? , cuz each group of zipcode
has its own fix rate

Thanks in advance

Rulshipping rule by Weight, volume and zip 03 Sep 2015 17:24 #2

Dear Andreashsalim,

The implementation of your description would be (assuming a fixed lower rate of 123456 for the given zip range):
Variable=Fee1; Value= Length*Width*Height/6*1
Name="Your Rule Name A"; 10730<=ZIP<11850; Shipping=max(Fee1, 123456)

What I don't understand about your fee1 is the "x 1". If you really want to multiplyo with 1, that term is redundant and does not have any effect. Or do you mean that each ZIP range has its own factor?

In principle it is possible to treat many zip ranges (you are talking about 8000 different zip code ranges!), by handling each zip range in a rule like in my example.
However, VirtueMart has a limitation of ca. 19000 characters for each shipment method (the sum of all rulesets of one method is relevant here). So unless you can combine several zip ranges into one rule, your complete ruleset will be too large for one shipping method. You can get around that limitation by creating two or more shipping methods and splitting the ruleset across those methods.

On the other hand, with such large rule sets I would expect quite some performance issues, because the plugin has to parse the whole ruleset for each and every modification of the cart (new product in the cart, address changes, etc.).

Is there any way to find some logic / pattern in the rate for those zip code groups.

Best regards,
Reinhold

Rulshipping rule by Weight, volume and zip 04 Sep 2015 09:49 #3

  • andreashsalim
  • andreashsalim's Avatar Topic Author
hi reinhold....
thanks for the reply.
'X 1' is multiplication and should be read as "X weight" to determine the value of the Volumetric calculation.

What i have done so far is this
============================================================
Variable=TotByVol; Value =(Ceil(MaxLength*MaxWidth*MaxHeight)/6000)*Weight
Variable=Zipcheck1;Value=10110<=ZIP<=14530
Variable=Zipcheck1;Value=30111<=ZIP<=30268

Name=JktReg;condition=Zipcheck1; TotByVol<(8000*Weight);Shipping=(8000*Weight)
Name=JktReg;condition=Zipcheck1; TotByVol>(8000*Weight);Shipping=TotByVol

Name=PalReg;condition=Zipcheck1; TotByVol<(20000*Weight);Shipping=(20000*Weight)
Name=PalReg;condition=Zipcheck1; TotByVol>(20000*Weight);Shipping=TotByVol
=============================================================================
The "constant" (ie: 8,000 and 20,000,above) represents the range of the zipcodes for cities....and the group of zipcodes that have a constant could be hundreds.

A large city may have several zipcodes and determines its cost of 8000. The above chunk of codes only represents 2 cities,namely JktReg and PalReg.

Please help with short descriptive codes handling the rules above. Thank you .

Rulshipping rule by Weight, volume and zip 13 Sep 2015 20:27 #4

Dear Andreashsalim,
Your approach is indeed the same as I would take (Except that you need to name the condition variable for PalReg Zipcheck2 ! And I would combine the two rules for each city by using the max(...) function):
Variable=TotByVol; Value =(Ceil(MaxLength*MaxWidth*MaxHeight)/6000)*Weight
Variable=Zipcheck1;Value=10110<=ZIP<=14530
Variable=Zipcheck2;Value=30111<=ZIP<=30268

Name=JktReg;condition=Zipcheck1; Shipping=max(TotByVol, 8000*Weight)
Name=PalReg; condition=Zipcheck2; Shipping=max(TotByVol, 20000*Weight)

If you have lots of different cities, then I suppose it would be more efficient to create a dedicated plugin to determine your particular shipping costs. This could either be a standalone shipping plugin, which hardcodes the whole shipping cost structure directly in PHP, or it can be a plugin for the shipping by rules plugins (see open-tools.net/virtuemart/advanced-shipp...ipping-by-rules.html), which calculates your constants (8000 and 20000) from the ZIP and stores it into a variable or provides it as a function, which is then available in the rules. I would implement this in a plugin like:
function onVmShippingRulesRegisterCustomFunctions(&$cartvals, $cart, $products, $method, $cart_prices) {
    return array (
        'CostByZIP' => array ($this, 'calculate_cost_constant_by_zip'),
    );
}
function calculate_cost_constant_by_zip($args, $rule) {
  $zip = $args[0];
  if (10110<=$zip && $zip <=14530) {
    return 8000;
  elseif (30111<=$zip && $zip<=30268) {
    return 20000;
  } elseif (.....) {
....
  } else {
    return 0;
  }
}

You can then use this function in the rules:
Variable=TotByVol; Value =(Ceil(MaxLength*MaxWidth*MaxHeight)/6000)*Weight
Name=Shipping by zip; Shipping=max(TotByVol, CostByZIP(ZIP)*Weight)

In any case, I don't think there is an easy way around explicitly writing the checks for all zip ranges / individual zip values for your cities. Just putting this into the rules is not very efficient, because the plugin has to parse the rules for each cart modification, and parsing rules with several thousand conditions can take some time. Implementing it directly in php is certainly faster.

Best regards,
Reinhold

Rulshipping rule by Weight, volume and zip 15 Sep 2015 11:14 #5

  • andreashsalim
  • andreashsalim's Avatar Topic Author

(see open-tools.net/virtuemart/advanced-shipp...ipping-by-rules.html), which calculates your constants (8000 and 20000) from the ZIP and stores it into a variable or provides it as a function,


Still confused with the above link of plugin. Is that a kind of PHP editor that we can write the code on? If yes, then the function listed below
function onVmShippingRulesRegisterCustomFunctions(&$cartvals, $cart, $products, $method, $cart_prices) {
    return array (
        'CostByZIP' => array ($this, 'calculate_cost_constant_by_zip'),
    );
function calculate_cost_constant_by_zip($args, $rule) {
  $zip = $args[0];
  if (10110<=$zip && $zip <=14530) {
    return 8000;
  elseif (30111<=$zip && $zip<=30268) {
    return 20000;
  } elseif (.....) {
....
  } else {

could be plugged in as the rule for all 'regular' rule written on virtuemart configuration ?
(reinhold, i think the function above is GREAT ! and may accomodate my shipping rule's need, will see....)


In any case, I don't think there is an easy way around explicitly writing the checks for all zip ranges / individual zip values for your cities. Just putting this into the rules is not very efficient, because the plugin has to parse the rules for each cart modification, and parsing rules with several thousand conditions can take some time. Implementing it directly in php is certainly faster.

could u be more specific on the plugin mentioned above (before i add it on my cart), i have been searching an easy way to have the code to handle this rule. They (shipping company) have API but are reluctant to share to the public which i myself never know why, so constant fees they change, consequently must be followed by lotsa changes on the rule we make, it is painful and rediculous

Best regards,
andreas

Rulshipping rule by Weight, volume and zip 15 Sep 2015 11:19 #6

  • andreashsalim
  • andreashsalim's Avatar Topic Author
Dear Rainhold,
Would be very thankful if it works. and wont 'bother' u anymore ... :)

Rulshipping rule by Weight, volume and zip 18 Sep 2015 12:52 #7

  • andreashsalim
  • andreashsalim's Avatar Topic Author
dear reinhold,

i just downloaded and installed the 'Extensions for the Shipping by Rules Plugins for VirtueMart' whicjh I thought it could handle my case. As a matter of fact, i was really confused with the errors appeared when i typed in the functions on the configuration rule (advanced shipping rule). Did i ,miss something or simply misunderstood the plugin i just downloaded. How to implement the function 'onVmShippingRulesRegisterCustomFunctions' so it can be called on the rule, as mentioned above...thanks

Rulshipping rule by Weight, volume and zip 29 Sep 2015 23:42 #8

Dear Andreashsalim,
Sorry, that was apparently a misunderstanding. I didn't mean to indicate that you have to buy the RegExp extension plugin on that page (I'll refund, no problem).

What I rather meant was that some PHP / Joomla developer would need to use the extension template that is available for free on that page as a starting point for a custom plugin implementing your shipping cost as a function. The code that I gave above (the function onVmShippingRulesRegisterCustomFunctions etc.) was NOT meant to be entered into the rules box of the plugin / shipping method configuration. Rather it is the starting point for a PHP programmer to make a more efficient implementation of your shipping costs than thousands of rules in the shipping method configuration (which need to be interpreted on every page load of the cart page and thus has a severe performance penalty).

Sorry again for the confusion. I was thinking too much as a PHP software developer. Unless you have a PHP / Joomla developer at hand, I guess the easier approach (even though with a performance penalty) is then to simply create lots of rules like the following in the plugin configuration:
Variable=TotByVol; Value =(Ceil(MaxLength*MaxWidth*MaxHeight)/6000)*Weight
Variable=Zipcheck1;Value=10110<=ZIP<=14530
Variable=Zipcheck2;Value=30111<=ZIP<=30268

Name=JktReg;condition=Zipcheck1; Shipping=max(TotByVol, 8000*Weight)
Name=PalReg; condition=Zipcheck2; Shipping=max(TotByVol, 20000*Weight)

Best regards,
Reinhold

Rulshipping rule by Weight, volume and zip 30 Sep 2015 13:17 #9

  • andreashsalim
  • andreashsalim's Avatar Topic Author
hi reinhold,
That's what I thougt on the first place. Frankly speaking, inputting a whole bunch of rules would be devastatingly painful and The room would not accept anyway, due to virtuemart limitation.

i think the best solution would be writing PHP code to handle it, or switching to another CMS that the corresponding shipping module already exists publicly. I chosed the latter. well, i guess that's it. Thanks for the time.

Andreas.

[SOLVED] Rulshipping rule by Weight, volume and zip 01 Oct 2015 23:36 #10

Problem solved (even though switching to a different e-commerce system is not the solution we like).

Sorry to hear that you have left VM for a differen e-commerce system.

Best regards,
Reinhold
  • Page:
  • 1