3

i have created a shipping method extension in which shipping rate is correctly and even error message is also set when it conditions are sattisfied.

My question is when i am trying to set a the error message it is pulling the default message "Sorry, no quotes are available for this order at this time."

Below is my code

$result = Mage::getModel('shipping/rate_result');
$show = true;
if($show && $price > 0 && !$this->_error){
    $method = Mage::getModel('shipping/rate_result_method');
    $method->setCarrier($this->_code);
    $method->setMethod($this->_code);
    $method->setCarrierTitle($this->getConfigData('title'));
    $method->setMethodTitle($methodName);
    $method->setPrice($price);
    $method->setCost($price);
    $result->append($method);
}else{
    $error = Mage::getModel('shipping/rate_result_error');
    $error->setCarrier($this->_code);
    $error->setCarrierTitle($this->getConfigData('name'));

    if($this->_error){
        $msg = "Shipping rate cannot be calculated.";
    }else{
        $msg = $this->getConfigData('specificerrmsg');
    }
    $error->setErrorMessage($msg);
    $result->append($error);
}
return $result;
6

For the googlers landing on this page, here is the solution :

To always display the carrier, Magento is looking for the showmethod attribute in your carrier configuration. You should add this code in your config.xml :

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <default>
        <carriers>
            <my_carrier>
                <showmethod>1</showmethod>
            </my_carrier>
        </carriers>
    </default>
</config>

With that, your error message should display.

  • Thanks! Your answer is correct. I had the same problem and this fix it. – Unknown May 6 '15 at 10:15
  • @hellimac thank you for sharing valuable information – manokarthick karthick Feb 7 '17 at 8:54
0

Code for Error Message:

$message = $this->__('Got an error');
Mage::getSingleton('core/session')->addError($message);

For this case may be you can check your config.xml:

<type>I</type>
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
<handling_type>F</handling_type>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.