Magento – Magento 1.9 – Please specify a shipping method

magento-1.9paypalpaypal-express

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 :

  • Magento cart
  • In cart click paypal express
  • Click ok continue etc paypal
  • Return to Magento paypal/express/review page (template/paypal/express/review.phtml)

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

<script type="text/javascript">
    //<![CDATA[
    // submit buttons are not needed when submitting with ajax
    $('review_submit').hide();
    if ($('update_shipping_method_submit')) {
        $('update_shipping_method_submit').hide();
    }

        var selectThis = 'postnl_matrixrate';
        var ppcookieName = 'paypalexpress';
        var selectOption = $("shipping_method").getValue();
        var selectCookie = Mage.Cookies.get(ppcookieName);
        if ((selectOption == '' || selectOption == selectThis) && !selectCookie) {
            $$('select#shipping_method option').each(function(o) {
                if(o.readAttribute('value') == selectThis) { // note, this compares strings
                    o.selected = true;
                    Mage.Cookies.set(ppcookieName,'clicked');
                    $('update_shipping_method_submit').click();
                    // throw $break; // remove this if it's a multi-select
                }
            });
        }

    <?php if ($this->getUseAjax()):?>
    OrderReviewController.prototype._submitOrder = function() {
        <?php /** SNH CUSTOM 7-9-2018 Need to trigger a button click here to respect the pre-selected shipping method **/?>

        $('update_shipping_method_submit').click();