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:

Total number of boxes for an order (packaging) 06 Jan 2014 09:04 #1

  • manuxx
  • manuxx's Avatar Topic Author
Hi Reinhold


For the transport system we need to define the total number of boxes an order has, for now we do it manually.

We sell per kg but we have no clue on how to make the system tell us the number of boxes an order may have depending on the total kg.

We have boxes of 5,10 and 15 kg.

An order of 30 kg would be 2 boxes of 15 kg, therefore that value "2" is the one we need.


Is this even possible? I have been searching for hours but can't find a solution, I encountered your documentation about the total packaging.

Is there a field for total packaging dependent on kg somewhere?


I have seen the fields in the products dimensions but we can't really set product units there since we sell per kg and not units.

We have some products sold as 1 kg and others as boxes of 10 or 15 kg.


Regards

VM 2.024c and Joomla 2.5.16

Total number of boxes for an order (packaging) 11 Jan 2014 13:58 #2

Dear manuxx,
That sounds like a quite intricate problem. Do I understand you correctly that you only need the final weight of the order to calculate the number of boxes? E.g. an order of 27 kg would be one box of 15kg, one of 10kg and 2 boxes of 1kg?

Or would that also depend on the purchased items? E.g. Product A is one box of 15kg and product B is one box of 10kg. If you have 2xA and 1xB, the order would be 50kg with 3 boxes (2 boxes A and 1 box B), but if the order has 5xB, then the order has also 50kg, but this time with 5 boxes (5 boxes for 5 products B).

In the first case (only depending on total weight), you might even be able to achieve this with the latest beta version 3.96 of the shipping by rules plugin (I have not tested these rules, so there might be a typo or so, but you should get the idea):
Variable=boxes15; Value=floor(Weight/15)
Variable=boxes10; Value=floor( (Weight - 15*boxes15) / 10)
Variable=boxes5; Value=floor( (Weight - 15*boxes15 - 10*boxes10) / 5)
Variable=boxes1; Value=ceil( (Weight -15*boxes15 - 10*boxes10 - 5*boxes5) )
Variable=totalboxes; Value=boxes15 + boxes10 + boxes5 + boxes1
Name=Shipping in boxes (using {totalboxes} boxes: {boxes15}x15kg, {boxes10}x10kg, {boxes5}x5kg, {boxes1}x1kg); shippping=totalboxes*3.64

The idea of this is called "greedy algorithm" in optimization. You first try to stuff as much as possible into 15kg boxes, and the rest in 10kg box (if more than 10kg is left), the rest in a 5kg box (if more than 5kg is still left) and the rest in 1kg boxes.
With version 4.0 (3.96 is the beta-testing version for version 4.0), you can define your own variables like the boxes15, boxes10, etc. in my example. So as long as you can base your calculations on other existing variables, things will work just fine.

However, in the second case (product-dependent number of boxes), I don't see any way to let my plugin do the calculation, as this needs a deeper inspection of the items in the cart.

Best regards,
Reinhold

Total number of boxes for an order (packaging) 11 Jan 2014 14:37 #3

  • manuxx
  • manuxx's Avatar Topic Author
Wow thanks a lot for the reply, yeah Reinhold I always bring you mind blowing issues eh ;)

The easiest way is the total weight calculation yes, and that could work for us.

The ideal case is the other option but weight is more than valid.


In our case boxes are just 5, 10 and 15 kg but I think your rules could manage that no?

If and order is 27 kg it would be 2 boxes of 15 kg or 1 of 15 kg and 1 of 10 kg and one of 5 kg, is valid in both cases.


If an order has a total weight of 17 kg it would be 1 box of 15 kg and 1 box of 5 kg.

The idea is to use the less number of boxes possible.


I see your plugin can print this info which is great but that would show where exactly? in the shipment name?

If that is the case that would be great cause we could export that value and print it per order so our warehouse guys know the number of boxes an order has.

My remaining doubt is how to integrate that in to our current rules:

Ill post them here for you:
Name=Península, max 6kg; 01000<=ZIP<07000; Weight<=6; Shipping=4.81
Name=Península, max 11kg; 01000<=ZIP<07000; 7<=Weight<=11; Shipping=5.77
Name=Península, max 16kg; 01000<=ZIP<07000; 12<=Weight<=16; Shipping=6.73
Name=Península, max 21kg; 01000<=ZIP<07000; 17<=Weight<=21; Shipping=8.65
Name=Península, max 26kg; 01000<=ZIP<07000; 22<=Weight<=26; Shipping=10.58
Name=Península, max 31kg; 01000<=ZIP<07000; 27<=Weight<=31; Shipping=11.54
Name=Península, max 36kg; 01000<=ZIP<07000; 32<=Weight<=36; Shipping=13.46
Name=Península, max 41kg; 01000<=ZIP<07000; 37<=Weight<=41; Shipping=15.38
Name=Península, max 46kg; 01000<=ZIP<07000; 42<=Weight<=46; Shipping=17.31
Name=Península, max 51kg; 01000<=ZIP<07000; 47<=Weight<=51; Shipping=19.23
Name=Península, max 61kg; 01000<=ZIP<07000; 52<=Weight<=61; Shipping=23.08
Name=Península, max 71kg; 01000<=ZIP<07000; 62<=Weight<=71; Shipping=26.92
Name=Península, max 81kg; 01000<=ZIP<07000; 72<=Weight<=81; Shipping=30.77
Name=Península, max 91kg; 01000<=ZIP<07000; 82<=Weight<=91; Shipping=34.62
Name=Península, max 100kg; 01000<=ZIP<07000; 92<=Weight<=101; Shipping=38.46
Name=Spain, Weight=>102; 01000<=ZIP<07000; Shipping=38.46+(Weight-101)*0.1
Name=Baleares, max 6kg; 07000<=ZIP<08000; Weight<=6; Shipping=10.58
Name=Baleares, max 11kg; 07000<=ZIP<08000; 7<=Weight<=11; Shipping=10.58
Name=Baleares, max 16kg; 07000<=ZIP<08000; 12<=Weight<=16; Shipping=13.46
Name=Baleares, max 21kg; 07000<=ZIP<08000; 17<=Weight<=21; Shipping=15.38
Name=Baleares, max 26kg; 07000<=ZIP<08000; 22<=Weight<=26; Shipping=17.31
Name=Baleares, max 31kg; 07000<=ZIP<08000; 27<=Weight<=31; Shipping=17.31
Name=Baleares, max 36kg; 07000<=ZIP<08000; 32<=Weight<=36; Shipping=19.23
Name=Baleares, max 41kg; 07000<=ZIP<08000; 37<=Weight<=41; Shipping=24.04
Name=Baleares, max 46kg; 07000<=ZIP<08000; 42<=Weight<=46; Shipping=26.92
Name=Baleares, max 51kg; 07000<=ZIP<08000; 47<=Weight<=51; Shipping=28.85
Name=Baleares, max 61kg; 07000<=ZIP<08000; 52<=Weight<=61; Shipping=30.77
Name=Baleares, max 71kg; 07000<=ZIP<08000; 62<=Weight<=71; Shipping=38.46
Name=Baleares, max 81kg; 07000<=ZIP<08000; 72<=Weight<=81; Shipping=43.27
Name=Baleares, max 91kg; 07000<=ZIP<08000; 82<=Weight<=91; Shipping=48.08
Name=Baleares, max 100kg; 07000<=ZIP<08000; 92<=Weight<=101; Shipping=52.88
Name=Spain, Weight>102; 07000<=ZIP<08000; Shipping=38.46+(Weight-101)*0.1
Name=Península, max 6kg; 08000<=ZIP<35000; Weight<=6; Shipping=4.81
Name=Península, max 11kg; 08000<=ZIP<35000; 7<=Weight<=11; Shipping=5.77
Name=Península, max 16kg; 08000<=ZIP<35000; 12<=Weight<=16; Shipping=6.73
Name=Península, max 21kg; 08000<=ZIP<35000; 17<=Weight<=21; Shipping=8.65
Name=Península, max 26kg; 08000<=ZIP<35000; 22<=Weight<=26; Shipping=10.58
Name=Península, max 31kg; 08000<=ZIP<35000; 27<=Weight<=31; Shipping=11.54
Name=Península, max 36kg; 08000<=ZIP<35000; 32<=Weight<=36; Shipping=13.46
Name=Península, max 41kg; 08000<=ZIP<35000; 37<=Weight<=41; Shipping=15.38
Name=Península, max 46kg; 08000<=ZIP<35000; 42<=Weight<=46; Shipping=17.31
Name=Península, max 51kg; 08000<=ZIP<35000; 47<=Weight<=51; Shipping=19.23
Name=Península, max 61kg; 08000<=ZIP<35000; 52<=Weight<=61; Shipping=23.08
Name=Península, max 71kg; 08000<=ZIP<35000; 62<=Weight<=71; Shipping=26.92
Name=Península, max 81kg; 08000<=ZIP<35000; 72<=Weight<=81; Shipping=30.77
Name=Península, max 91kg; 08000<=ZIP<35000; 82<=Weight<=91; Shipping=34.62
Name=Península, max 100kg; 08000<=ZIP<35000; 92<=Weight<=101; Shipping=38.46
Name=Spain, Weight>102; 08000<=ZIP<35000; Shipping=38.46+(Weight-101)*0.1
Name=Península, max 6kg; 36000<=ZIP<38000; Weight<=6; Shipping=4.81
Name=Península, max 11kg; 36000<=ZIP<38000; 7<=Weight<=11; Shipping=5.77
Name=Península, max 16kg; 36000<=ZIP<38000; 12<=Weight<=16; Shipping=6.73
Name=Península, max 21kg; 36000<=ZIP<38000; 17<=Weight<=21; Shipping=8.65
Name=Península, max 26kg; 36000<=ZIP<38000; 22<=Weight<=26; Shipping=10.58
Name=Península, max 31kg; 36000<=ZIP<38000; 27<=Weight<=31; Shipping=11.54
Name=Península, max 36kg; 36000<=ZIP<38000; 32<=Weight<=36; Shipping=13.46
Name=Península, max 41kg; 36000<=ZIP<38000; 37<=Weight<=41; Shipping=15.38
Name=Península, max 46kg; 36000<=ZIP<38000; 42<=Weight<=46; Shipping=17.31
Name=Península, max 51kg; 36000<=ZIP<38000; 47<=Weight<=51; Shipping=19.23
Name=Península, max 61kg; 36000<=ZIP<38000; 52<=Weight<=61; Shipping=23.08
Name=Península, max 71kg; 36000<=ZIP<38000; 62<=Weight<=71; Shipping=26.92
Name=Península, max 81kg; 36000<=ZIP<38000; 72<=Weight<=81; Shipping=30.77
Name=Península, max 91kg; 36000<=ZIP<38000; 82<=Weight<=91; Shipping=34.62
Name=Península, max 100kg; 36000<=ZIP<38000; 92<=Weight<=101; Shipping=38.46
Name=Spain, Weight>102; 36000<=ZIP<38000; Shipping=38.46+(Weight-101)*0.1
Name=Península, max 6kg; 39000<=ZIP<60000; Weight<=6; Shipping=4.81
Name=Península, max 11kg; 39000<=ZIP<60000; 7<=Weight<=11; Shipping=5.77
Name=Península, max 16kg; 39000<=ZIP<60000; 12<=Weight<=16; Shipping=6.73
Name=Península, max 21kg; 39000<=ZIP<60000; 17<=Weight<=21; Shipping=8.65
Name=Península, max 26kg; 39000<=ZIP<60000; 22<=Weight<=26; Shipping=10.58
Name=Península, max 31kg; 39000<=ZIP<60000; 27<=Weight<=31; Shipping=11.54
Name=Península, max 36kg; 39000<=ZIP<60000; 32<=Weight<=36; Shipping=13.46
Name=Península, max 41kg; 39000<=ZIP<60000; 37<=Weight<=41; Shipping=15.38
Name=Península, max 46kg; 39000<=ZIP<60000; 42<=Weight<=46; Shipping=17.31
Name=Península, max 51kg; 39000<=ZIP<60000; 47<=Weight<=51; Shipping=19.23
Name=Península, max 61kg; 39000<=ZIP<60000; 52<=Weight<=61; Shipping=23.08
Name=Península, max 71kg; 39000<=ZIP<60000; 62<=Weight<=71; Shipping=26.92
Name=Península, max 81kg; 39000<=ZIP<60000; 72<=Weight<=81; Shipping=30.77
Name=Península, max 91kg; 39000<=ZIP<60000; 82<=Weight<=91; Shipping=34.62
Name=Península, max 100kg; 39000<=ZIP<60000; 92<=Weight<=101; Shipping=38.46
Name=Spain, Weight>=102; 39000<=ZIP<60000; Shipping=38.46+(Weight-101)*0.1
Name=Península, max 6kg; 53000<=ZIP<99999; Weight<=6; Shipping=4.81
Name=Península, max 11kg; 53000<=ZIP<99999; 7<=Weight<=11; Shipping=5.77
Name=Península, max 16kg; 53000<=ZIP<99999; 12<=Weight<=16; Shipping=6.73
Name=Península, max 21kg; 53000<=ZIP<99999; 17<=Weight<=21; Shipping=8.65
Name=Península, max 26kg; 53000<=ZIP<99999; 22<=Weight<=26; Shipping=10.58
Name=Península, max 31kg; 53000<=ZIP<99999; 27<=Weight<=31; Shipping=11.54
Name=Península, max 36kg; 53000<=ZIP<99999; 32<=Weight<=36; Shipping=13.46
Name=Península, max 41kg; 53000<=ZIP<99999; 37<=Weight<=41; Shipping=15.38
Name=Península, max 46kg; 53000<=ZIP<99999; 42<=Weight<=46; Shipping=17.31
Name=Península, max 51kg; 53000<=ZIP<99999; 47<=Weight<=51; Shipping=19.23
Name=Península, max 61kg; 53000<=ZIP<99999; 52<=Weight<=61; Shipping=23.08
Name=Península, max 71kg; 53000<=ZIP<99999; 62<=Weight<=71; Shipping=26.92
Name=Península, max 81kg; 53000<=ZIP<99999; 72<=Weight<=81; Shipping=30.77
Name=Península, max 91kg; 53000<=ZIP<99999; 82<=Weight<=91; Shipping=34.62
Name=Península, max 100kg; 53000<=ZIP<99999; 92<=Weight<=101; Shipping=38.46
Name=Spain, Weight>=102; 53000<=ZIP<99999; Shipping=38.46+(Weight-101)*0.1

Thanks a lot for help

Regards

Total number of boxes for an order (packaging) 11 Jan 2014 18:26 #4

That's a typo: shipping should be written only with double (not tripple) "p"...

Total number of boxes for an order (packaging) 11 Jan 2014 20:10 #5

  • manuxx
  • manuxx's Avatar Topic Author
Hi Reinhold

Can you tell me the values considering we use only boxes of 5,10 and 15 kg.

Everything below 5 kg is a 1 box of 5 kg.

Therefore an order with total weight 4 kg is 1 box of 5 kg.

An order of total weight 34 is 2 boxes of 15 kg and one of 5 kg.


I tried deleting the boxes1 from the code leaving it this way:
Variable=boxes15; Value=floor(Weight/15)
Variable=boxes10; Value=floor( (Weight - 15*boxes15) / 10)
Variable=boxes5; Value=ceil( (Weight - 15*boxes15 - 10*boxes10) )
Variable=totalboxes; Value=boxes15 + boxes10 + boxes5

With this 4 kg appear as 4 total boxes, i've tried using the operator 5<= the / 5 also from your example but cant get 4 kg to show as 1 box.

Regards

Total number of boxes for an order (packaging) 11 Jan 2014 20:23 #6

In the value for boxes5, the (Weight - 15*boxes15 - 10*boxes10) calculates the remaining weight for the 5kg boxes. To get the number of 5kg-boxes, you need to divide this by 5kg:
Variable=boxes5; Value=ceil( (Weight - 15*boxes15 - 10*boxes10) / 5 )

Reinhold

Total number of boxes for an order (packaging) 11 Jan 2014 20:53 #7

  • manuxx
  • manuxx's Avatar Topic Author
Thanks Reinhold

That works but:

Product

Lemons (1 kg) quantity 6

Total weight 6 kg

The system assumes the [totalboxes] are 2 of 5 kg instead of 1 of 10 kg.


Guess Im doing something wrong:

I copy you all the rules ive set up following your example:
Variable=boxes15; Value=floor(Weight/15)
Variable=boxes10; Value=floor( (Weight - 15*boxes15) / 10)
Variable=boxes5; Value=ceil( (Weight - 15*boxes15 - 10*boxes10) / 5 )
Variable=totalboxes; Value=boxes15 + boxes10 + boxes5
Name=Portugal, max 6kg Bultos {totalboxes}; Weight<=6; Shipping=7.69
Name=Portugal, max 11kg Bultos {totalboxes}; 7<=Weight<=11; Shipping=8.65
Name=Portugal, max 16kg Bultos {totalboxes}; 12<=Weight<=16; Shipping=9.62
Name=Portugal, max 21kg Bultos {totalboxes}; 17<=Weight<=21; Shipping=12.50
Name=Portugal, max 26kg Bultos {totalboxes}; 22<=Weight<=26; Shipping=16.35
Name=Portugal, max 31kg Bultos {totalboxes}; 27<=Weight<=31; Shipping=20.19
Name=Portugal, max 36kg Bultos {totalboxes}; 32<=Weight<=36; Shipping=24.04
Name=Portugal, max 41kg Bultos {totalboxes}; 37<=Weight<=41; Shipping=27.88
Name=Portugal, max 46kg Bultos {totalboxes}; 42<=Weight<=46; Shipping=31.73
Name=Portugal, max 51kg Bultos {totalboxes}; 47<=Weight<=51; Shipping=35.58
Name=Portugal, max 61kg Bultos {totalboxes}; 52<=Weight<=61; Shipping=43.27
Name=Portugal, max 71kg Bultos {totalboxes}; 62<=Weight<=71; Shipping=50.96
Name=Portugal, max 81kg Bultos {totalboxes}; 72<=Weight<=81; Shipping=58.65
Name=Portugal, max 91kg Bultos {totalboxes}; 82<=Weight<=91; Shipping=66.35
Name=Portugal, max 100kg Bultos {totalboxes}; 92<=Weight<=101; Shipping=74.04
Name=Portugal; Weight>=102 Bultos {totalboxes}; Shipping=74.04+(Weight-101)*0.6

Im getting closer, the idea is to use the less number of boxes.

Regards

Total number of boxes for an order (packaging) 13 Jan 2014 16:05 #8

If you are really only interested in the total number of boxes, then it's really simple:
Variable=totalboxes; Value=ceil(Weight/15)

The idea is that you fill as many 15kg boxes as possible (Weight/15). If there is something left after that, we know that it will fit into one more box (5kg, 10kg or 15kg). The ceil does exactly that: if there is something left (i.e. Weight/15 is NOT an integer number), it will return the next hight number of boxes.

Getting the exact number of 5kg and 10kg boxes is a bit more tricky.

Reinhold

[SOLVED] Total number of boxes for an order (packaging) 13 Jan 2014 16:11 #9

  • manuxx
  • manuxx's Avatar Topic Author
Problem solved.

[SOLVED] Total number of boxes for an order (packaging) 13 Jan 2014 16:12 #10

  • manuxx
  • manuxx's Avatar Topic Author
Wow Reinhold, thats exactly what we needed, many thanks!

Our transport systems doesnt care or require how many of 5 or 10 or 15, just the total, is a margin where we can freely move since they just need the number of total boxes independent of their size.
  • Page:
  • 1