Magento transaction error "Please specify a shipping method"
Asked Answered
I

2

7

We use a custom checkout extension by Templates Master called "Firecheckout". Not sure if that's relevant, but figured I should mention it. Occasionally I see a transaction failed email with the reason being "Please specify a shipping method". I've spent a long time trying to track down how this can happen and I'm lost. I have tried everything I can think of to duplicate the issue. Depending on the combination of things I do (adding/removing items from the cart, adding/removing a coupon code that changes shipping options, switching between mobile and desktop sites, etc) I have been able to make it so that the checkout page doesn't have an option selected for shipping method. However, if I try to submit the order I get an immediate red message in the shipping method section that says "Please specify shipping method" (Note the difference between what it says in the email and what it says in the error displayed on the page...missing "a"). This does not result in an error email.

Searching through the code I find that the error email is triggered in the TM_FireCheckout_Model_Service_Quote (extends Mage_Sales_Model_Service_Quote) class in the _validate method

$method= $address->getShippingMethod();
$rate  = $address->getShippingRateByCode($method);
if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
    Mage::throwException($helper->__('Please specify a shipping method.'));
}

In this case, I guess either $method or $rate is null or false, but why/how could that be? Is there anything I could do to ensure this never happens? The only difference between the FireCheckout's _validate method and the parent class's _validate method is in which fields are considered required. It does not alter the address object in any way, so the subsequent calls to getShippingMethod and getShippingRateByCode should be the same as a default install.

I can provide additional details if necessary. I'm basically trying to understand what may trigger that error and how I can reproduce it so I can ultimately patch the hole that is causing it in the first place.

Thanks!

Irish answered 30/4, 2012 at 19:42 Comment(2)
why not add a log line in _validate() Mage::log("Firecheckout: " . var_dump($method) . " | " . var_dump($rate), null, 'mydebug.log', true); to a local copy of Mage_Sales_Model_Service_Quote and tail this custom log file, perhaps add order and customer ID's as well to see if those values are persisting?Cockneyfy
I have exactly that same error, but I`m using Onestepcheckout Extension from Apptha. Any help would be appreciated.Igenia
F
0

I've encountered something similar before, but it wasn't with Firecheckout. But it was also Onestepcheckout Extension from Apptha like @Lennon. Long story short, it was a disparity in javascript handling that trashed the data. I don't have a definite answer for you but I advise you to look into what happens in between form validations and data saves on the checkout form.

What you can do to start investigating is to fire up Firebug on FF, watch the console and see if your data is still getting passed around. You can also create a simple observer module to do the following at the controler_action_predispatch event:

$request = $observer->getControllerAction()->getRequest();
Mage::log(var_export($request->getParams(),true));

..or just directly edit the controller files within your checkout routes. whatever floats your boat.

Enable logs, and tail -f var/logs/system.log. You should make sure that the requests match the log. That is how I started to solve my problem though.

Again, this isn't a "copypasta" fix or a tutorial directed at the root of the problem, but rather sharing my experience on how I diagnosed my problem from my first hand experience.

You can create a module very quickly at http://www.silksoftware.com/magento-module-creator

Fluorocarbon answered 24/12, 2012 at 13:29 Comment(0)
P
0

you need to define the shipping method after the changes. For example, in "indexController" of the Firecheckout create a function as "saveShippingAction". This function you can call via Ajax every time to change customer data, or as you prefer.

Inside place:

    $customer = Mage::getSingleton('customer/session')->getCustomer();
    $shippingData = $this->getRequest()->getParam('shipping');
    $shippingData['street'] = implode("\n", $shippingData['street']);
    $customerAddress = $customer->getAddresses();
    $customerAddress = end($customerAddress);
    $customerAddress->setIsDefaultShipping(true)->setSaveInAddressBook(true);
    $customerAddress->addData($shippingData)->save();

In this example I record delivery data back to the last address of the customer, if in your case you need to save for a new client, just create an address for him and save as delivery address.

I hope to have helped, good luck.

Puryear answered 29/9, 2016 at 17:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.