Visser Labs

Sunday, November 8, 2009

Flat Rate Shipping for Australian States and Country Regions

flatrate-polaMy delving into Instinct’s WP E-Commerce plugin for WordPress has raised a few questions and now that I have had some spare time I’ve prepared some Visser-style hacks and solutions!

I recently raised in Hot Aussie Topics for WP E-Commerce that there was no shipping calculator supporting flat-rate shipping for Australian states which were manageable within the WordPress Administration and selectable by customers at checkout, well here’s my fix.

  • Login to WordPress Adminstrator
  • Under General Settings set the Base Country/Region to Australia and save changes
  • Using your favourite FTP manager navigate to /wp-content/plugins/wp-e-commerce/shipping/... and with your preferred text editor open flatrate.php
  • Ensure you have an original copy of flatrate.php stored on your computer.
  • On line #39 paste the following…
    case 'AU':
    $output .= "<tr class='rate_row'><td>Australian Capital Territory</td><td>$<input type='text' size='4' name='shipping[au-act]' value='{$shipping['au-act']}'></td></tr>";
    $output .= "<tr class='rate_row'><td>New South Wales</td><td>$<input type='text' size='4' name='shipping[au-nsw]' value='{$shipping['au-nsw']}'></td></tr>";
    $output .= "<tr class='rate_row'><td>Northern Territory</td><td>$<input type='text' size='4' name='shipping[au-nt]' value='{$shipping['au-nt']}'></td></tr>";
    $output .= "<tr class='rate_row'><td>Queensland</td><td>$<input type='text' size='4' name='shipping[au-qld]' value='{$shipping['au-qld']}'></td></tr>";
    $output .= "<tr class='rate_row'><td>South Australia</td><td>$<input type='text' size='4' name='shipping[au-sa]' value='{$shipping['au-sa']}'></td></tr>";
    $output .= "<tr class='rate_row'><td>Tasmania</td><td>$<input type='text' size='4' name='shipping[au-tas]' value='{$shipping['au-tas']}'></td></tr>";
    $output .= "<tr class='rate_row'><td>Victoria</td><td>$<input type='text' size='4' name='shipping[au-vic]' value='{$shipping['au-vic']}'></td></tr>";
    $output .= "<tr class='rate_row'><td>Western Australia</td><td>$<input type='text' size='4' name='shipping[au-wa]' value='{$shipping['au-wa']}'></td></tr>";
    break;
  • On what was line #54 replace the following with my updated version:
    Original: if (get_option('base_country')=='NZ') {
    Updated: if (get_option('base_country')=='NZ' || get_option('base_country') == 'AU') {
  • On what was line #92 add in the following between the NZ and US ‘case’ entries:
    case 'AU':
    $shipping_quotes["Australian Capital Territory"] = (float)$flatrates['au-act'];
    $shipping_quotes["New South Wales"] = (float)$flatrates['au-nsw'];
    $shipping_quotes["Northern Territory"] = (float)$flatrates['au-nt'];
    $shipping_quotes["Queensland"] = (float)$flatrates['au-qld'];
    $shipping_quotes["South Australia"] = (float)$flatrates['au-sa'];
    $shipping_quotes["Tasmania"] = (float)$flatrates['au-tas'];
    $shipping_quotes["Victoria"] = (float)$flatrates['au-vic'];
    $shipping_quotes["Western Australia"] = (float)$flatrates['au-wa'];
    break;
  • Save changes and upload the updated flatrate.php to your web server.
  • Within WordPress Administrator open General Settings and switch to the Shipping tab
  • Select Flat Rate under Internal Shipping Calculators and save changes
  • Hover over the Flat Rate checkbox and click on Edit
  • Under Flat Rate in the right column of the Shipping tab fill in your fixed rate pricing for each Australian state
  • Click Update to save changes

That’s it, you’ve just hooked up flat rate pricing for Australian customers! Now jump on the front-end and test to ensure that when Australia is set from the drop-down that your prices are coming up. We’re all learning here so if there’s any problems let me know in the comments or send me an e-mail for personal assistance.

3 Comments »

  1. Mark Williams
    December 21

    Gday mate – quick question from a n00b – we build simple WP sites for small business in Australia and we’re looking to add an ecom string to our bow. This looks good what you’ve done here – can I ask: would this mean if Instinct release a new update, we’d have to then go back and recopy in this hack?

    ps – we build all our WP sites using Thesis – which seems to cut the dev time down quite considerably – I dunno if you’ve had any experience with that or not.

    Cheers mate, Mark ;)

  2. December 21

    Hey Mark, you’re spot on. Each time you upgrade a client’s WP E-Commerce you’ll need to bring across the hack/changes.

    Assuming you’ve got a file/folder comparison application you can merge the changes between your existing code and the latest release of WP E-Commerce. I use Beyond Compare 3.

  3. Mark Williams
    December 21

    Ok Michael no worries – and thanks for the heads up with Beyond Compare 3 – I’ll give it a shot ;)

Leave a comment

The perfect comment is interesting, on-topic and/or highly amusing.