8 replies [Last post]
zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192

Hi there,

I'm working on some tweak for the worldquote module, and one of mofification I would like to do is to return an error when there are no rules that match the customer address... (ATM it return 0$ quote).

I don't find a function that allow to return an error, I find that I have to return the $quote[] array like that :

<?php

$quotes

[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $rule->name);
?>

But I'm obliged to return an amount etc...

How can I just return an custom error message and so, don't allow customer to continue his shipment ?

oslinux's picture
Offline
Joined: 09/06/2007
Juice: 461
Re: Return an error for a shipping quote.

My thought would be: how does the shipping module know no quotes have been calculated, then recreate that state as an "error!" since it does not let you continue without having quotes ...

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: Return an error for a shipping quote.

I used to allow each quote method to set an error flag that would prevent the customer from continuing checkout. Unfortunately, it had been done badly, and it was preventing customers from selecting a quote even if there were some available. Now the error message shows up only if all quotes fail.

I do like the idea of individual error messages for quotes, though. I'll add them in so that they are displayed, but probably not affect the checkout process. Should the error message replace the "notes" field that was recently added, or should they be displayed side-by-side?

I also want to make the super error message customizable. It hasn't even been a translatable string, though if I make it configurable, it won't ever be.

setfree's picture
Offline
Uber Donor
Joined: 12/16/2007
Juice: 436
Lyle, Was the individual

Lyle,

Was the individual error messages for quotes ever implemented in uc1.x? If so, how would I go about using it?

Thanks!

setfree's picture
Offline
Uber Donor
Joined: 12/16/2007
Juice: 436
Re: Lyle, Was the individual

Never mind, I found the solution in the docs (http://www.ubercart.org/docs/api/hook_shipping_method)

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: Lyle, Was the individual

Gosh, I never got around to it. Got involved working on other parts of Ubercart.

setfree's picture
Offline
Uber Donor
Joined: 12/16/2007
Juice: 436
Lyle, I still need a little

Lyle,

I still need a little help trying to implement a custom shipping quote error message. Using the documentation, I was able to find a reference to this and used the following to return a error message from my hook_quote:

<?php
 
return array(
       
'01' => array(
         
'error' => 'This order contains a shipment that is too large for our standard LTL freight quote. Please call us at [727] 319-2300 so we can arrange for the best possible freight quote for you.'
         
),
         );       
?>

This works find except that the error message says "UNDEFINED" before it (see screenshot). I thought it might be related to the accessorial in the hook_shipping_method, so I added that in as follow:

<?php
  $methods
= array(); 
 
$enabled = variable_get('uc_quote_enabled', array('freight' => true));
 
$weight = variable_get('uc_quote_method_weight', array('freight' => 0));
 
$methods['freight'] = array(
   
'id' => 'freight',
   
'title' => t('Freight'),
     
'module' => 'uc_freight_shipping'
   
'enabled' => $enabled['freight'],
    
'weight' => $weight['freight'],
   
'quote' => array(
     
'type' => 'freight',
     
'callback' => 'freight_quote',
     
'accessorials' => array(
         
'01' => t('Freight'),
      ),
     ),
  );
  return
$methods;
}
?>

...but the problem persists. Am I missing something, or is this a bug?

Thanks for your help!

AttachmentSize
shipping_quote_error.jpg 61.5 KB
Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: Lyle, I still need a little

It looks like your returned array needs an 'option_label' key alongside the 'error'. Now that I've seen this, I probably need to go add it to some other error messages my shipping methods are returning.

setfree's picture
Offline
Uber Donor
Joined: 12/16/2007
Juice: 436
Re: Re: Lyle, I still need a little

Perfect, Thanks! Adding the 'option_label' key fixed the 'undefined' issue I was having. Thanks again~