Actually, it is displaying the unmodified data send from the fastway server.
It does, but only in certain circumstances.
Let me explain ... there is a bit of an evolution processes going on here. The original postage delay was very simple because only one source of data was used, namely, Australia Post, and it supplied a single number/digit to indicate the estimated days delivery to the client, so all the module needed to do was add the number of days delay to this number, then add a bit of text to make it obvious what the number stood for, the text of course being 'Days Estimated delivery'
This was fine until I started adding other carriers each of which had their own methods of specifying the delivery time. SO, to mitigate this issue I added code to skip this behaviour with the new carriers. For all practical purposes this worked quite well, but what I didn't realise though that I failed to exclude FastWay from being treated in this manner... and because PHP doesn't enforce script coding habits instead of producing an error, it was allowing the code to add the days delay to a "number" like ("2 to 3").. it does this by ignoring anything after the '2', so if the dals delay was '3' then the reported estimate for "2 to 3" plus 4 = 6.
Now, because this is working only due to a bug, the number is now a single digit, so the client text "Day Estimated Delivery" was correctly/incorrecty added and everything appeared fine.
Anyway, I discovered this 'bug' whilst adding the Platinum Parcel methods and noted that the estimated days returned for these were no longer using the standard AustPost single number/no text - So I have been/am seeking a method to both fix the bug AND allow the differently formatted data from the server. To do this, A bit of lateral thinking gave me the idea of using the length of the string(s) returned, so if a "long" string was returned (such as "not avialalbe to all locations" then the module should display the string, 'as is'. If the string was short, then assume it was a number (or range of numbers) and then add the postage delay and other text.
I chose to make the 'switch' at 5 characters.. "2 to 3" is 6 characters so it is being displayed as is.
To revert back to the previous bevaviour edit line 572 of /includes/modules/ozpost.php and change
if (strlen($quote->days) > 4 )
to
if (strlen($quote->days) > 6 )
Anyway, that said, I still need to do some serious thinking/tinkering in regards to how to deal with this in the future... as mentioned, it currently only works with fastway due to an oversight combined with loose (poor) coding, the days delay has never had any affect with the other courier times.
I'm also not at all happy with the various inconsitancy of formats ... TNT for example estimates a particular date (taking weekends and holidays into account), Australia Post returns just a single number (for all but platinum)
Fastway provides a range of days, but only the numbers, no text, and so on.
It'd be nice if I had the server return them all in the same format, my *personal* preference would the format used by TNT, where it specifies a partcular date, but I can't just jump into doing that, because then it will break the postage delay stuff completely, and to mitigate this issue means the days-delay needs to be sent to the server so that they can be added *before* the request, rather than after the results are returned (Bugger, I meant to add that to this release so that if I did get around to looking at it serverside the client code wouldn't need to be updated again. Oh well. Next time.
The other (simpler) option would be to convert the very informative date based estimates down to the number of days format and add the delay client side...
Other than my current neglect to send the delay_days to the server it is theoretically possible to support both methods with no other changes to the client code.
Anyway, that's the story regarding this change... if you have any thoughts, opinions or suggestions as to how you'd like to see the estimated delivery times in the future then I'm all ears.
Cheers
Rod
Bookmarks