Cart Review Problems

Posts: 40
Joined: 10/10/2007

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

AttachmentSize
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
Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

Line 164.
The key of each quote should be the accessorial key. If you're only doing international, it should start with 2 and then increase sequentially.

To do this the easy way, change the foreach() loop on line 153 to

<?php
 
foreach (_uc_auspost_services(null,$type) as $key => $accessorial) {
?>

Then you can use $quotes[$key] = array(...) and _uc_auspost($key, $quote['days']) instead of that business with array_flip().

Posts: 40
Joined: 10/10/2007

Awesome. Thanks for the reply and for taking the time to look at it.

Like I said, i'm not a PHP developer (I'm a Systems Admin by "trade"), so any help is greatly appreciated.

Also, thanks for all your work on ubercart. It's the only open-source cart that I could recommend to anybody - it's just neat, feature packed, and nicely extensible.

Posts: 40
Joined: 10/10/2007

That worked nicely.

I've never used foreach in that way. That's quite handy. Certainly beats "that business" with array_flip() Eye-wink Sticking out tongue

Posts: 53
Joined: 10/07/2007

Awesome work Daniel.

Will be closely following this one, as it is essential for all Australian users.

Great work too (As usual) Lyle.

Ryan..

Posts: 59
Joined: 08/08/2007
Early adopter... addicted to alphas.Getting busy with the Ubercode.

Just wondering where the development of the AustPost shipping module is. I was going to have to develop one from scratch for a new shop I'm working on, but if this one is on it's way, I wouldn't mind helping finishing it up. Has it progressed, or is the download above still an up-to-date version?

Cheers,
Steph

Posts: 40
Joined: 10/10/2007

Sorry for the lack of feedback guys. I am subscribed to this thread, but I must have email notifications turned off (or they're getting eaten by my spam filter).

I've got the basics happening with my version of the module. It's attached to this post.

I haven't yet gotten around to implementing some sort of disclaimer. Australia Post requires you to use a disclaimer nowadays if you're using their eDRC.

A side note, I'm not sending item dimensions to the DRC as they have no bearing on the actual quote cost or shipping time. I suppose we could add some internal validation down the track, but for my purposes this is fine as it is.

Have a try and let me know how you go.

AttachmentSize
Australia Post Shipping Quote module v1.036.49 KB
Posts: 11
Joined: 11/27/2007

Hi and thank you for the module.

As there's no readme file - could you please tell me - what should be done in order to use the module? As I have enabled it through Drupal interface, set up all parameters and it doesn't seem to show up during checkout.

I have tried two independent websites with different OS/PHP/MySQL versions (one of them has the latest) and there's still no difference.

Is there any specific requirements for the module to work? Or what could be wrong with the module?

Posts: 11
Joined: 11/27/2007

Hi, Again.

Here're few error message I receive from admin/store/settings/quotes/methods (Shipping quote settings) page:

"Dividing by zero in ..." don't remember the line number - the actual code of this line is:
$pkg_weight = ($weight / $num_packages);

After I specified $num_packages = 1; I am receiving the following error (through messages):

* No measurement passed to the _length_to_mm function of uc_auspost
* No measurement passed to the _length_to_mm function of uc_auspost
* No measurement passed to the _length_to_mm function of uc_auspost
* No measurement passed to the _length_to_mm function of uc_auspost

I have also disable all other shipping options and left only auspost ON - now shipping quotes bring no result at all.

Any ideas?
I am using Ubercart alpha8

Posts: 40
Joined: 10/10/2007

Without looking at my code yet, do your products specify weights and dimensions?

Posts: 40
Joined: 10/10/2007

Also, you need to select which shipping methods you'd like to use in the uc_auspost settings area

Posts: 40
Joined: 10/10/2007

I've attached a new version which ignores products which don't specify a weight. I would have liked to have been able to attach both an admin and customer comment to the order denoting which products weren't included in the quote - but i'm under the impression that you can't use uc_order_comment_save until the next stage of checkout (review).

I'm not going to include any instructions yet, as it's only posted up here for testing purposes.

A few notes:
- After installing, make sure you select which shipping methods you would like to use. None are selected by default
- Make sure that all your products include weights. The other dimensions don't matter too much. They have no bearing on the actual quote, so I don't use them. I was not going to go to the hassle of writing "boxing" code that calculates package dimensions when multiple items are packed together. Reading about that by the developer of the osCommerce or ZenCart AusPost module developer was enough to turn me off that idea.
- The onus is on the store admin to make sure that their products are physically shippable - and to use the 'Product and its derivatives are shippable' property of each product. I'm about to re-include code which checks if $product->shippable is 'true'. If it isn't, the product obviously won't be included in the quote.

AttachmentSize
uc_auspost.zip27.14 KB
Posts: 1
Joined: 03/04/2008

Just a note to inform that (to the best of my knowledge) shipping dimensions do influence postage costs.

For parcels exceeding 1kg 'actual' weight, AusPost assesses based upon 'Actual' or 'Cubic' weight: Whichever is greater. Cubic weight is LxWxH(m) x250.
I ship large, lightweight items and I find this policy is enforced at my LPO. The eDeliver DRC should be taking this into account when it returns postage costs.

I'm not currently using Ubercart but this may be relevant to those creating/using this module.

Posts: 40
Joined: 10/10/2007

I am no longer using or maintaining this module or the eWay module, so whoever needs it can feel free to use it or rewrite it.

Posts: 2
Joined: 03/13/2008

Hi Daniel. Thanks for you efforts on both the Auspost and the eway modules. I am currently in the early stages of development using ubercart with drupal. I have a fair amount of experience with drupal but this is my first time trying ubercart. I tried using the e-commerce modules a while back (a couple of years ago) but got frustrated and in the end I developed a site using a combination of drupal and zen cart. (I noted your reference to zencart in this thread).

The same client now wants a 'new' integrated website/online store so I'm trying to get ubercart working. I am not a coder but a sys-admin like you. (I play around with basic bits and pieces)...

My main reason for posting is to say "thanks" for the work you have done so far and to indicate that "I'm here" to anyone else looking at these two issues: Auspost & eWay.

I do have access to a 'live' eWay account so if I can help someone with testing, I'm happy to do so.

The eway module currently doesn't appear to be working (for me) in test mode. I have done a few test runs and it appears to work (payment appears to be accepted) but it does this even when it shouldn't (ie. when I purposely use the wrong 'test' amount etc). It sets the order status to 'pending' and and not 'payment received' or 'complete' ( a good thing!) but from the users point of you, it says "Thank you for you order" and leaves the impression the order was successful. No errors.

Anyway, all this is just by way of a 'heads up' for anyone else out there playing with the eway module.

Cheers.

Posts: 53
Joined: 10/07/2007

Damn,m

Sad to hear that.

I will ask my mate if he would take a look at it.

perhaps we should raise a bounty for this one?, it's pretty critical that Australians get this one working....

thanks for all your work Daniel, it is really appreciated...

Posts: 2
Joined: 04/09/2008

Is anyone using this successfully? ive installed the module into modules folder, and it comes up in Shipping quote settings, where i can set up all the options for it but in checkout i get the default message:

"There were problems getting a shipping quote. Please verify the delivery and product information and try again.
If this does not resolve the issue, please call in to complete your order."

i have a default postage address set and am using an australian address as the buyer.
ive tried installing it in the ubercart directory with the same result.
sorry if my problem is a bit vague but im still a noob at drupal/ubercart

Posts: 2
Joined: 04/09/2008

*cough* please disregard above... i had not set my address in store settings, only shipping settings

yes im a noob

sorry Sticking out tongue

Posts: 5
Joined: 05/06/2008

What are the hurdles still existing ?

Thank you

Best regards

Administrator
holeepassion.com