Hi (Gordon?)
I've moved on to a site where I need to calculate shipping costs for delivery inside Australia. I'd love some hints about the steps I would need to take.
In zen-cart there is an module for calculating Australia Post delivery, I don't know what the equivalent would be in drupal, or if there is one. I've had a fruitless search on Drupal and Google.
Thanks in advance.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | australiapost_3.inc | 12.82 KB | gordon |
| #25 | australiapost_2.inc | 13 KB | sime |
| #24 | australiapost_1.inc | 9.19 KB | mrmachine |
| #20 | australiapost_0.inc | 7.35 KB | mrmachine |
| #19 | australiapost.inc | 7.47 KB | mrmachine |
Comments
Comment #1
Andy_Lowe commentedI don't think there is a module to calculate Australian Post yet.
If you are willing to write some code (or pay someone else to), there is a module called shipcalc here:
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/con...
which will get you off to a start. It is a module for calculated shipping via UPS, so you will still have some work to do to make it with Australian Post, but it is a start.
Cheers,
Andy
Comment #2
simeThanks ajlowe for the quick response! This is the pointer I needed.
Comment #3
wellsy commentedthere is a module which works very well for Australia Post for oScommerce.
Perhaps it can be ported to drupal?
http://www.oscommerce.com/community/contributions,648
Comment #4
simeWell by the time I'm done with it, it will be more like a "hack" than a "port". :-)
But that's my intention, either that or the zen-cart equiv which I have used.
Comment #5
Andy_Lowe commentedzen cart is a (IMHO improvement on and) fork of oscommerce. Last time I looked, they used the same shipping api, so the modules should be nearly identical. Note that the shipcalc module uses both the checkoutapi and the shippingapi. You can get a good idea of what is going on here:
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/doc...
and in the shipping.module file.
Comment #6
simealrighty, I will have a go at this. but this will be a drupalian baptism of fire for me. remember, even Bender gets scared sometimes.
Comment #7
Ludwig commentedWe will put our hands up for testings if you need that.
We are Australian developers (previously using OsCommerce for ecommerce sites.)
We "need" the AusPost calcs for Drupal which we are slooowly migrating to...
Comment #8
simeThankyou Ludwig
I appreciate the support. My progress so far. I have applied for cvs access, I have setup a CVS client on my windows machine. I have set up a virtual domain on my Linux test server and on that I am installing a clean HEAD installation of Drupal with e-commercie. I am now just reviewing Drupal (API, hooks, whatever) before I am ready have a close look at the shipcalc/UPS contribs.
I hope with the existing contribs to compare against, that my path will be easier. That said, it's good to know who is interested in this, especially if I get stuck and need some urgent advice from someone with a bit of dev experience.
Comment #9
gordon commentedSime: Thanks for looking at this.
You do not need cvs access to do this mode. You will not be commiting this change even if you have cvs access as it needs to be reviewed to make sure that everything is going. Checkout the ecommerce module as an anonymous user and do the development. Once you have finished create a patch and submit it here to be reviewed.
I think there are a number of Aussie people in Melbourne, I think that we should arrange a Meetup for Melbourne.
Comment #10
simeSure, it would help me a lot to know a couple of people.
Comment #11
Ludwig commentedJust checking in.
how is the development going? Is it? are you looking at it now with 4.7 in mind?
still ready, willing and able to do testing :-)
Comment #12
neclimdulThis is important but we can't start work on it till we finish revamping the shipping module. Going to mark think postponed contingent on the shipping updates.
Comment #13
mrmachine commentedPlease - anything happened with this yet? I've been waiting months to be able to get my mum's ecommerce site online, but can't really do anything till australia post shipcalc is implemented. I'm about to try and do it myself, but it's gonna take me at least another month to understand how.
Comment #14
simeSorry, no. My own customers went with basic shipping which is being added in EC5.
Comment #15
mrmachine commentedis it possible that i would also be able to use basic shipping? i'm using drupal 4.7.4 and latest ecommerce package (not cvs). if not, what versions of drupal and ecommerce do i need to use it? how do i go about getting the .inc file?
my only other option is to create about 100 non-shippable products for all of the possible postages, and have customers add the "postage product" to their shopping cart ... obviously not desirable option :)
Comment #16
simeI'll be putting this in 5.0
You're free to try some sort of simple shipping in 4.7 by jumping on this http://drupal.org/node/71718
Comment #17
mrmachine commentedWell, I'm going to have to try to build an australiapost.inc, and fast ;)
In the interests of getting help from others who also don't have much PHP expertise, I'll post a work-in-progress australiapost.inc that we can build off. I've taken the canadapost.inc and started to modify it ... however, I haven't gotten far, as I am learning as I go ... I will update the code as I learn.
I have also altered the PHP comments to include reference to stuff I don't understand what to do with, so any PHP experts, can you have a look?
For anyone who wants to help, here is the relevant documentation from Australia Post:
And, just below, is the work-in-progress australiapost.inc ... theres' a few additional code comments in there, plus a few more comments below the code:
I don't understand all the XML stuff in there - do USPS and CanadaPost require you to submit queries and receive responses in XML format?
I would really appreciate some help on this, as I'm at the stage where abandoning Drupal in favour of OSCommerce or some other CMS that "just works" is going to be just as time consuming as implementing what I need in ECommerce.
Comment #18
simeI'll help you get this up to scratch. (Prefer you either attach files here or somewhere else accessible, rather than post large code snippets in the comments.)
Comment #19
mrmachine commentedhey, thanx sime
sorry about the large snippet ...
attached here is a streamlined australiapost.inc that i've cut everything out of except for the stuff i definitely know should be there ... which doesn't leave much, lol.
some things the AusPost partner should do:
1) figure out the customers Country, and if it is Australia, only show the Domestic Methods and Rates - if any other country, only show International Methods and Rates. The if/else code for doing this was in the original canadapost.inc, i think, but i cut it out from the attached australiapost.inc so i could work with a clear head.
2) i think can pretty much use the same function/technique for the testing service as in canadapost.inc, just replacing the variables.
3) is it possible to not combine items, so that each product is shipped independently?
2) and 3) don't really matter, though ... just basic interaction and integration with the AusPost service.
if you want the Australia Post API documentation, then PM me and I'll send it to you.
oh - and here's what i've come up with on the _get_rates function so far:
does that look right?
thankyou so much if you are able to help.
Comment #20
mrmachine commentedok, i've done a crash course in PHP, and I'm sorta getting the feel for what's going on in the partners file ...
everything is working fine up until the _get_rates function ... i sorta understand how some of the partner files are doing it (specifically, the ones that just get the rates by performing operations/functions on a charge that is set in the configuration) - but i don't really get how this function is used when the data is fetched from an external source (like canadapost, ups, usps etc).
i've constructed and if/else statement in the _get_rates function so that a different Aus Post submission URL will be used, depending on whether the order is for Domestic or International delivery ... my main problem is how to load my url with the necessary variables from each item that is being ordered (postage calculation via Aus Posts calculator is done by building up a URL that contains all necessary info such as weight, destination and originating postcode, etc). Then there's also this problem: whether an order is for Domestic or International delivery, I would like to present the customer, at checkout time, with the various delivery options as defined in the first part of the *.inc file - so obviously the _get_rates function must query the cost and delivery time for all these delivery options, spit out a form that allows the customer to choose which one, and then adds the value of that selection to the orders total ....
so, can someone please look at my attached australiapost.inc file, and tell me where i'm going right, and where i'm going wrong? i've also added comments to show what i'm thinking, and what i don't know, at various stages of code.
i'm doing the best i can, but i do need help.
Comment #21
mrmachine commentedoh - and is there tool that i can use that will show me what values are being assigned by my script when i run them? that would help a great deal, especially if i could see what values - if any - are being assigned to the URL i need to build to get the rates from Australia Post.
Comment #22
gordon commentedIf you have the devel module installed you can use dprint_r() or if you have the xdebug php extension installed use var_dump().
If you need any help jump into #drupal-ecommerce and ask. Most of the EC maintainers are there during the day (AEST)
If this is going ok, I will include this into the next stable release of both 4.7 and 5 of EC.
Comment #23
gordon commentedComment #24
mrmachine commentedhere's latest one.
what it can do:
* detect if a transaction is for domestic or foreign shipping, and get the rates for a) domestic - standard, express, registered b) international - air, sea.
* detect the orders destination postcode, country.
* configure registered post cost, store postcode.
what it can't do:
* detect product weight/dimension ... these are hard-coded into the $weight, $width, $length, $height variables at the moment until i figure out how to load the product_attributes.
* don't think it can process more than 1 item per order yet.
* doesn't really take notice of configured postage options ... just returns "STANDARD", "REGISTERED" and "EXPRESS" for domestic and "AIR" and "SEA" for international, regardless of if you have disabled any of those services in the content-types settings.
* doesn't give delivery time estimation in checkout yet.
* probly other stuff.
Comment #25
simeHere's a new version. I decided to calculate shipping on every item, because there is risk otherwise of going over the limits of the auspost api. But the structure is there to take this one step further for EC5.
Please apply this patch too:
http://drupal.org/node/91948
Comment #26
mrmachine commentedunfortunately i didn't get much of a chance to look at this over the weekend. i applied the patch to shipcalc (you meant the second one?), but i get errors at checkout, and no joy (this is on drupal 4.7):
i'll be looking into this today ....
also, it is a condition of use of Australia Posts API, that the customer is shown these terms and conditions at the time of submitting the delivery-rate calculator request (maybe on the checkout page listing delivery costs would be ok ... unsure if it needs to be before that).
Comment #27
simeI think change:
if (!product_is_shippable($item)) {to
if (!product_is_shippable($item->vid)) {Not sure why I didn't have that problem...
As for the notice, yeah we should look at that we the code is ready to commit.
Comment #28
mrmachine commentedyes, that did the trick !
lookin quite good ;)
Comment #29
gordon commentedI have taken a look and it looks really great.
I have however cut out some of the cruft, to make it easier to maintain, and fixed a couple of errors.
Comment #30
simeI have committed this to HEAD. gordon, you might like to tag this first version as 4.7
Comment #31
simeSorry: http://drupal.org/cvs?commit=51232
Comment #32
(not verified) commented