Posted on

Comparison operators on shipping rules

Comparison operators for shipping rules has been added on the last release of Fish and Ships. In most cases, the comparison symbols simply makes a visual disambiguation. But in some cases, will allow more human way to introduce the values. Or avoid mistakes.

To clarify, let’s look an example. Let’s say a shipping rule that set a cost up to 4 products. And another one that start at 5 or more products, the conditional selection is:

Comparisor operators on shipping rules
Comparisor operators on shipping rules

Well, a number of products is always an integer magnitude. Then, can’t be any number between 4 and 5. Never 4,5 will not fulfill any rule. It’s impossible. But… what happens with weight? Let’s say we have a shop in quilograms. Let’s say we want a rule from 0 to 10 kg (22 lb). And another one that begin on this value. Not uncommon to get decimal values. If we set 10 kg as MAX on first one, and 11 kg as MIN on second one, what happens with a 10.5 kg?!

So, to avoid this situation, we should put 10kg on the two fields: MAX for rule #1, and MIN for rule #2. But… we must take care to avoid the exact 10kg weight fulfill two rules at once. So we should to decide wich rule fulfill. In the first rule:

Comparisor operators LESS THAN OR EQUAL TO and GREATER THAN
10kg will fulfill first rule, the comparison operators on shipping rules are LESS THAN OR EQUAL TO for rule #1 and GREATER THAN for rule #2

The maximum field of rule #1 has LESS THAN OR EQUAL TO and the minimum of rule #2 has MORE THAN comparisor. This avoid double charge on exact 10kg weight.

Or if we want 10kg filfull the second rule. In this case, maximum field of rule #1 must be LESS THAN and minimum of rule #2 GREATER THAN OR EQUAL TO:

Comparisor operators LESS THAN and GREATER OR EQUAL TO
10kg will fulfill second rule, the comparison is GREATER THAN OR EQUAL TO

…this avoid also the double charge, in the other way. That’s all!!!