Interchange Shopping Cart Australia
SummaryOnline Shipping Calculations in real time can be done on a pc instead of using LWP::UserAgent live. All the combinations ever required can be queried in one hour and a suitable table created. The result is surprisingly efficient, fast, reliable and pretested for potential conflicts.
I was finally forced to upgrade from Interchange 5.2 to 5.6 because some of my customers' browsers were being seen as search engine spiders. When they clicked "Buy Now", nothing happened.
I thought everything went pretty well, but realized LWP::UserAgent, which I was using for Australia Post Delivery Rate Calculations in real time using http get with Australia Post had broken. Gert kindly offered some suggestions regarding testing LWP::UserAgent on the command line, but with regard to it's use in Interchange, so far no explanation has been found. I have to run a whole store now and I made the decision to create a solution.
The latest country.txt from the standard store looks like this. We wish to upgrade every column except "selector". This is because Australia Post has different shipping modes from Fedex and UPS.
country.txtcode sorder region selector shipmodes name iso isonum tax no_state
AF 9 Asia AF AIR SEA Afghanistan AFG 004
AX 9 Europe AX AIR SEA Aland Islands ALA 248
I wrote (Strawberry Perl) software in notepad which recovers the old data from 7 years back. The ECONOMY mode is no longer valid and so a few lines of code were used to tidy it up.Software to assist in managing Australia Post country.txt during upgrades.
Copy country.txt from the standard shopping cart products directory and rename it country-standard.txt The country-aussievitamin.txt was likewise copied from my current installation. The output country.txt is ready to copy to the products directory of your store.
Type the commands:Fedora>rm -f /var/lib/interchange/mystore/products/*.sql
Fedora>service interchange restart
..or as appropriate on your platform.
I also copied state.txt from the latest standard shopping cart products folder to replace the current one.
LWP::UserAgent Work Around
Australia Post DRC Example URL
When you copy this url, containing the required parameters into your browser, Australia Post return the shipping cost, ETA and an error flag.http://drc.edeliver.com.au/rateCalc.asp?Height=100&Length=100&Weight=250&Width=100& Pickup_Postcode=6076&Destination_Postcode=01532&Country=AF&Service_Type=AIR&Quantity=1
Sample Australia Post DRC lookup.
All of our parcels are assumed to be 10cm x 10cm x 10cm. We use a US postcode as the destination as it works for all overseas countries.
Because LWP::UserAgent, when used from my own usertag produced neither error messages nor content I decided to use it on my pc instead. This software exhaustively queries the Australia Post DRC in one hour and produces a data file ready to replace LWP::UserAgent.Query every combination of Country, Mode and Weight interval in one hour!
There are two outputs. shippingcharge.txt creates a file with a searchable key ready to use in an interchange mysql database. When the drc returns an error, these records are filtered out and dumped in log.tx instead.
As every (as many as we need) combinations of Country, Shipping Mode and Weight are queried, country, MODE and weight are also fused into a searchable key (with one space separator).
The result looks like this:
Country/Mode/Weight in grams, Shipping Charge, Delivery time in days.
The first three columns are separated by one space and comprise a unique searchable key. The other columns are tab delimited as separate fields. The actual file has even more fields, the DRC URL, returned content and error codes.
shippingcharge.txt & shippingcharge.mysql
Set permissions. I do:chown mystore:mystore /var/lib/interchange/mystore/dbconf/mysql/*
chmod ug+rwx /var/lib/interchange/mystore/dbconf/mysql/*
chmod ug+rwx /var/lib/interchange/mystore/products/*
rm -f /var/lib/interchange/mystore/products/*.sql service interchange restart
The new table should appear in Admin Interface.NOTE: The above database excludes countries which Australia Post does not service and also Australian destinations. The reason is because I am on an Australia Post contract which already looks up shipping charges based on weight and zones (from postcodes).
Australia Post Contract Rates for Australian Destinations
Six more files will get the Australia Post Contract rates working for Australian Destinations:Copy parcels.txt to your products folder.
Copy zones.txt to your products folder.
Copy parcels.mysql to your dbconf/mysql folder.
Copy zones.mysql to your dbconf/mysql folder.
Copy shipping.asc to your products folder.
Copy australia_post_aussie.tag to your /usr/lib/interchange/code/UserTag/ folder.
Follow the above steps to set permissions and restart Interchange. You can rerun drc.pl yearly to update the CPI increase in shipping rates. Your checkout process will experience a new crispness, as looking up tables is much faster than LWP::UserAgent. Also there will be no problems when DRC is offline.
Portions copyright 2002-2018 Interchange Development Group, freely redistributable under GPL