Page 1 of 3

[Module] Royal Mail Advanced

Posted: Wed Jun 17, 2009 7:34 pm
by Martin
Title: Royal Mail Advanced Module
Author: Martin Smallridge (WebSnail)
License: Commercial (No redistribution)
Cost: £59.95
Support: 12 months included
Version: 1.0.13
Compatible: 4.0.7 / 5.0.0 - 5.0.6 / 6.0.0 - 6.1.8 (Other 4.x versions should be compatible)
ScreenCast: http://www.snailsolutions.co.uk/_casts/RM-Advanced/

Purchasing: Store link

Summary:
This module extends and replaces the rather slipshod effort from Interspire (which is currently out of date)

Primary features:
  • Large Letter Rates (including recorded option) now added
  • Appropriate packet rate is dropped if Large Letter rate is available for same service to avoid confusion.
  • Automated switch over to the new rates for April 30th 2012 (rates apply from day earlier)
  • Recorded delivery services added (Special Delivery, AirSure, International signed for, etc...)
  • Countries re-organised into zones according to the Royal Mails own documentation
  • Provides ALL weights as delineated in RM's own information tables (not the rough boundaries originally provided)
  • Defaults the test system to the UK
  • Added 2012 rates
  • Corrected missing Canary Islands info & added Kosovo as country code [XK]
  • Force recorded/tracked delivery options for orders greater than £X value.
    • UK on/off and trigger order value
    • International on/off and trigger order value
    • Updated test quote system to allow proper testing.
  • Tracked and UK ParcelForce 24/48 services added
  • Force Special Delivery option for orders greater than £Y value (for UK Orders)
  • Option to Add 20% VAT to shipping cost for those who are VAT registered and have to pass this on to the customer.
  • ...
Further information
http://www.snailsource.com/forum/viewforum.php?f=27

Re: [Module] Royal Mail Advanced

Posted: Sat Jul 11, 2009 11:02 pm
by Martin
As suggested by a couple of folks I've added a screencast about this module so you can see it in action so's to speak...

http://www.snailsolutions.co.uk/_casts/RM-Advanced/

Re: [Module] Royal Mail Advanced

Posted: Fri Jan 01, 2010 1:46 pm
by Martin
Just created an update for this thanks to a bug report received this morning.

There was a PHP warning regarding a missing index for the $rm_datepoint array.

This was caused by the lack of a 2010 index value in the array and more accurately my lack of foresight. I've now added in some sanity checking code that checks for this problem before it becomes a full PHP warning and allows for it to gracefully fail without losing the log reporting issue if the normal point for a Royal Mail pricing update has passed.

Short version:
- bug fixed
- Code doesn't produce error to customer
- Code does produce a "RoyalMail Adv Mod: Missing this years datafile" error in the store log if there has been no new pricing file for the current year if April 6th has passed for the current year (RM tend to release new pricing every UK tax year).


The fix is simple to apply without downloading a new update..

Open:
module.royalmail.php

Find:

Code: Select all

                		// The default data.
                		$rm_datepoint[2008]['stamp'] = gmmktime((-$this->_buffer),0,0,4,7,2008);
                		$rm_datepoint[2008]['data'] = "royalmail-2008.csv";

										// 2009 data (April 6th start)
                		$rm_datepoint[2009]['stamp'] = gmmktime((-$this->_buffer),0,0,4,6,2009); 
                		$rm_datepoint[2009]['data'] = "royalmail-2009.csv";
                		
                		/*
                		 * The pricing data is put into royalmail-YEAR.csv files
                		 * 	The YEAR is set to the year the new prices start so prices from 06-April-2009 => royalmail-2009.csv
                		 * The system checks $rm_datepoint[X]['stamp'] for the GMT timestamp
                		 * If the point has passed it sets $rm_thisyear to this year (eg: 2009)
                		 * If not it reverts to the previous years prices (eg: 2008)
                		 */
                		$tmp = gmdate("Y", time());
Replace with:

Code: Select all

                		// The default data.
                		$rm_datepoint[2008]['stamp'] = gmmktime((-($this->_buffer)),0,0,4,7,2008);
                		$rm_datepoint[2008]['data'] = "royalmail-2008.csv";

						// 2009 data (April 6th start)
                		$rm_datepoint[2009]['stamp'] = gmmktime((-($this->_buffer)),0,0,4,6,2009); 
                		$rm_datepoint[2009]['data'] = "royalmail-2009.csv";

                		// TODO 2010 data (No known data at this time)
                		/* 
                		$rm_datepoint[2010]['stamp'] = gmmktime((-($this->_buffer)),0,0,4,6,2010); 
                		$rm_datepoint[2010]['data'] = "royalmail-2010.csv";
                		*/
                		
                		/*
                		 * The pricing data is put into royalmail-YEAR.csv files
                		 * 	The YEAR is set to the year the new prices start so prices from 06-April-2009 => royalmail-2009.csv
                		 * The system checks $rm_datepoint[X]['stamp'] for the GMT timestamp
                		 * If the point has passed it sets $rm_thisyear to this year (eg: 2009)
                		 * If not it reverts to the previous years prices (eg: 2008)
                		 */
                		$tmp = gmdate("Y", time());
                		
                		/*
                		 * If we don't have a $rm_datepoint value for this current year
                		 * we create a "fake" one so it won't produce an error unless we're into the 
                		 * rough boundary for a new years pricing
                		 * 
                		 * Note: The code should recognise the null file doesn't exist and use the
                		 * previous years data file while creating an error in the store log if
                		 * the usual point for a new pricing file has passed.
                		 */
                		if(!array_key_exists($tmp, $rm_datepoint)) {
                			$rm_datepoint[$tmp]['stamp'] = gmmktime((-($this->_buffer)),0,0,4,6,$tmp);
                			$rm_datepoint[$tmp]['data'] = "royalmail-null.csv";
                		}

Re: [Module] Royal Mail Advanced

Posted: Thu Jan 06, 2011 2:57 pm
by Martin
Just to note that I've just found out that the various Channel Islands are handled in a completely different way to other counties, etc...

Ref: http://www.royalmail.com/portal/rm/jump ... d=92300754

So, I'll need to do some editing and an update of the module over the next week. I can't move quicker unfortunately because it's not a simple fix/update and I'm already snowed under as it is... But it will get dealt with.

Re: [Module] Royal Mail Advanced

Posted: Wed Jan 12, 2011 10:59 pm
by Martin
I've just completed an update that provides the correct functionality for Channel Islands as follows:
  • Identifies "countries" that are actually part of the UK (eg: Isle of Man, Jersey, Guernsey)
  • Correctly identifies the Royal Mail services available to these locations
  • Provides errors for test quote when incorrect service chosen
  • Recognises these locations should only be using Royal Mail domestic services and doesn't list International services
It doesn't currently identify these locations to remove unavailable services (eg: 9am Special delivery for Guernsey) if the location has been chosen as a county/state of the UK. This will be dealt with in the next update.

Latest versions available from store for those with a current subscription

Re: [Module] Royal Mail Advanced

Posted: Sat Jan 29, 2011 10:01 pm
by Martin
The changes to the way Royal Mail is providing AirSure and some other services from January 31st requires a rewrite of one key part of the code that affects the way Airsure is charged.

A new module to handle the changes, except for AirSure will be released in the next 72 hours so I would recommend that you disable this service for Europe until the next full release has been made available for download.

I'm aware a few folks are approaching the end of their 18 month support contract so if yours has expired (ie: you purchased the module more than 18 months ago) please renew soon to get the latest pricing updates and module changes to match those of Royal Mail.


As an aside, I've looked at the pricing increases for April 2011-12 and there are some very serious increases indeed with the <100g small packet rate up by 19p. Hardly surprising given the increases in fuel, etc... but still a nasty shock...

Re: [Module] Royal Mail Advanced

Posted: Sat Jan 29, 2011 11:46 pm
by Martin
Did a bit of code testing and found the changes required for Euro Airsure service aren't as bad as I thought. Should have a fix fully tested and released by end of tomorrow (Sunday)

Re: [Module] Royal Mail Advanced

Posted: Sat Mar 05, 2011 10:44 pm
by busi6292
Hi Martin, where is this update you speak of? Cannot find it on Snail Source downloads when I log on.

Thanks.

Re: [Module] Royal Mail Advanced

Posted: Sun Mar 06, 2011 12:00 am
by Martin
busi6292 wrote:Hi Martin, where is this update you speak of? Cannot find it on Snail Source downloads when I log on.
The download runs out after a while so if you could PM me with your original order reference and I'll check to see what might be holding things up and/or if your 18 months has run out, etc..

Re: [Module] Royal Mail Advanced

Posted: Mon Apr 04, 2011 1:47 pm
by Martin
Ho hum... I'm sat here trying to get the new pricing data for Royalmails 2011/12 year and they've posted a dead link on their web site that just locks up anyone who attempts to connect to it...

So, somewhat hampered in my attempts to update the datasheet and module as a result...

Gotta love RoyalMail... or do I? :roll: