Howdy.
I'm creating a module that calculates shipping rates for Australia Post. I've been going well so far, but am now stuck on quite an annoying problem - and could do with some help.
My accessorials are as follows:
<?php
function _uc_auspost_services($id = null,$type = null){
$domestic = array(
'0' => t('Standard Delivery'),
'1' => t('Express Post Delivery')
);
$international = array(
'2' => t('International Air Delivery'),
'3' => t('International Surface Delivery'),
'4' => t('Express Courier International Document'),
'5' => t('Express Courier International Merchandise'),
'6' => t('Express Post International')
);
switch (strtolower($type)) {
case 'domestic':
$return = $domestic;
break;
case 'international':
$return = $international;
break;
case null:
$return = array_merge($domestic,$international);
break;
}
if (is_null($id)) {
return $return;
} else {
return $return[$id];
}
}
?>Therefore when _uc_auspost_shipping_method() calls the function, it gets the full list of accessorials. I also need the full list for the admin section - where you can choose which accessorials to offer.
_uc_auspost_quote() then only gets quotes for the appropriate accessorials, be it a domestic order, or an international one.
This all works fine, and the quotes are displayed properly.
Where I've run into problems is with the 'Review Order' screen. If the order is an international one, the radio buttons on the checkout screen don't assign the accessorial's ID, but rather just a normal array pointer.
See below for what I mean:
[ quote] => Array
(
[method] => auspost
[accessorials] => 0
[rate] => 112.55
[quote_form] =>
<div class="form-item"><input name="rate[auspost---0]" value="112.55" type="hidden"><label class="option"><input class="form-radio" name="quote-option" value="auspost---0" type="radio"><img class="service_logo" src="/modules/ubercart/shipping/uc_auspost/img/airmail_logo.png" alt="International Air Delivery"> <small>(10 Days)</small>: $112.55</label></div>
<div class="form-item"><input name="rate[auspost---1]" value="63.15" type="hidden"><label class="option"><input class="form-radio" name="quote-option" value="auspost---1" type="radio"><img class="service_logo" src="/modules/ubercart/shipping/uc_auspost/img/seamail_logo.png" alt="International Surface Delivery"> <small>(65 Days)</small>: $63.15</label></div>
<div class="form-item"><input name="rate[auspost---2]" value="228.50" type="hidden"><label class="option"><input class="form-radio" name="quote-option" value="auspost---2" type="radio"><img class="service_logo" src="/modules/ubercart/shipping/uc_auspost/img/eci_logo.png" alt="Express Courier International Document"> <small>(3 Days)</small>: $228.50</label></div>
<div class="form-item"><input name="rate[auspost---3]" value="266.00" type="hidden"><label class="option"><input class="form-radio" name="quote-option" value="auspost---3" type="radio"><img class="service_logo" src="/modules/ubercart/shipping/uc_auspost/img/eci_logo.png" alt="Express Courier International Merchandise"> <small>(3 Days)</small>: $266.00</label></div>
<div class="form-item"><input name="rate[auspost---4]" value="317.50" type="hidden"><label class="option"><input class="form-radio" name="quote-option" value="auspost---4" type="radio"><img class="service_logo" src="/modules/ubercart/shipping/uc_auspost/img/epi_international_logo.png" alt="Express Post International"> <small>(5
Days)</small>: $317.50</label></div>See that it's numbering the international shipping options 0-4, where it should be labelling them 2-6.:
<div class="form-item"><input name="rate[auspost---2]" value="112.55" type="hidden"></div>
<div class="form-item"><input name="rate[auspost---3]" value="63.15" type="hidden"></div>
<div class="form-item"><input name="rate[auspost---4]" value="228.50" type="hidden"></div>
<div class="form-item"><input name="rate[auspost---5]" value="266.00" type="hidden"></div>
<div class="form-item"><input name="rate[auspost---6]" value="317.50" type="hidden"></div>Therefore, when I go to the "review order" screen, the quote amount is right, but the accessorial description is wrong.
This only happens in international orders, of course, as the domestic ones are assigned the array pointers 0 and 1 anyway.
For example, choosing 'International Air Delivery' (accessorials[2]), the review page reads 'Standard Shipping'
Hopefully you get my drift.
I'd love to get this working and share it with the community. I've already got one guy waiting on it after he saw me mention it on my blog.
Can anyone enlighten me on how to fix this, or otherwise, how to only show the appropriate accessorials for domestic or international orders.
I've also attached the actual .module file. Bear in mind that it's nowhere near complete.
Thanks for taking the time to read this far, and thanks in advance to anyone who can shed some light on this for me.
Daniel
| Attachment | Size |
|---|---|
| uc_auspost.module: This is by no means anywhere near ready to use. I'm no PHP pro, so i'm probably doing things the hard way too. | 10.71 KB |






Joined: 10/10/2007