Posts Tagged ‘php’

TNT zone shipping module in Joomla Virtuemart

Friday, November 14th, 2008

After lots and lots of googling i couldn’t find any shipping module for Virtuemart that was suiteble for our situation.

There is some kind of module for TNT but its for TGP Post and I didn’t get it working.

So there is no other option then write a module myself.

The first steps:

(1) Shipping Zone importing

I’ve imported all country zone codes by downloading the zone PDF from TNT, copied the in Excel and wrote a PERL script for the importing.

To make it more simple to you just download the SQL file here and just run the code in phpmyadmin.

It will update zone information (zone_id) for all countries in the jos_vm_country table.

If you prefer just international country codes with shipping zone information find it here. (same data, other format)

Beware this zone data is only from the Dutch point of view ;-) This will be different for your country!

(2) Writing the module itself:

The problem is, there is a default Zone Shipping module in Virtuemart, but here in the Netherlands the shipping costs are calculated different.

For example, in the default module you can ship a product sized 30cm * 30cm * 30cm with the weight of 50 Kg for just the zone price. There’s no difference in shipping a very large/small/heavy package. Only the destination matters.

TNT caculates the weight and the volume weight. You pay the highest value.

Weight is just the weight in Kilogram.

Volume weight is the size of the package length*width*hight / 6000.

Source: http://members.ziggo.nl/mfleur/maten.html

I’m writing the PHP code for the shipping module at the moment, so hold on a week or two.

Update 19 november 2008:

I had success with writing the module. There is a working alpha version. My deadline is 31 december 2008, so working hard to make this happen. I will make it more configurable, some parameters are hardcoded at the moment.

Update 9 january 2009:

I can report the shipping module is working fine :-) It still has the be tested some more, but it working.
There is one practical problem I”m facing, the volume weight calculation.

When you have some products, you can calulate their volume. But not in witch box they will fit.

At the moment i’m tweaking this calculation for the most optimal box.

If someone has a good solution for this, please write a comment below :-)

Update 14 Juni

Thanks all for waiting! :-) I can report this module is working fine in production now. At the moment i’m VERY busy with school (tomorrow I’ll have my final exam!).

Within a short time I’ll set the code online for testing. Anyone interested in this testing?