So I've already seen a couple of the other answers to this question on the site, however, my problem is still persisting.
Whenever someone tries to purchase an item using PayPal Express, when they click "Pay Now" it sends them to the Magento Review Page and throws the error "Please specify shipping method". However, if the user goes back to the PayPal Express page, and tries to pay again, it will go through just fine.
Whilst digging through the Magento files to try and see the issue, I've tried the following things.
Set the Timeout Callback on the shipping options to 6s
Added
/**
* Start Customization
*/
if (!$rate) {
Mage::logException(new Exception("Rate was empty inside quote validate method, trying to forcefully recalculate"));
$this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
$this->getQuote()->setTotalsCollectedFlag(false);
$this->getQuote()->collectTotals();
$rate = $address->getShippingRateByCode($method);
}
/** End Customization **/
From This Question
And I've tried logging the entire process.
What I've gathered from everything is that it looks as though Magento isn't picking up the Shipping Method returned by PayPal, as the Method and Rate from the function _validate()
(in /app/code/community/sale/service/quote.php) are Both empty when the pay now action is processed.
Paypal is definitely returning the shipping methods too.
If you need any extra code etc, just comment below.
Any help would be greatly appreciated. 🙂
Thanks!
Best Answer
We have had the exact same error. Flow is like :
case
a. If I set no shipping method and click continue I see the error "Please specify a shipping method"
b. If a shipping method is prepopulated thus the select element is set and I only click continue I see the error "Please specify a shipping method"
c. If we set the select element through JS to a default vallue only if it is unset even then I see the error "Please specify a shipping method"
ridiculous fix
It is an almost ridiculous fix, but it works. We added the following code to force the select value to a certain default if empty, and even if already on the default value. After that we trigger the updateshippingmethod button click and submit.
Actual problem
The only problem we actually had was that - coming back from Paypal the Shipping Method was empty and users needed to select a shipping method. The problem was that customers clicked CONTINUE like 10 times before they noticed the error (or abandoned) - So we decided to auto-set a default shipping method. Only this 'setting' of the default shipping method does somehow not transfer to the quote
I am very open to alternative fixes
Fix