cancel
Showing results for 
Search instead for 
Did you mean: 

“Please specify a shipping method” when logged in user try to place order in magento 2

SOLVED

“Please specify a shipping method” when logged in user try to place order in magento 2

I have created custom shipping module with multi rates on cart/chackout page. Everything working fine except:
Guest user able to place order and when the user logged in "Please specify a shipping method" exeception shows and not able to place order.
Please help.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

like I edited above: check if you have a "_" in your shipping code.

 

....
class Customshipping extends AbstractCarrier implements CarrierInterface
{
        /**
        * Carrier's code
        * @var string
        */
        protected $_code = 'donotuseunderlines';

....

at least it worked at my place... I guess... If so, let me know.

DI Alexander Herzog | Rent-a-Ninja.org ... don't worry, I've got this!

View solution in original post

8 REPLIES 8

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

@iqbal_alignpx Can you check for errors on your browser console? Maybe the configuration is different at website level? Have you put any condition like not allowed non-logged users? Is your guest checkout is enabled?

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

function setCarrierRates($quotes) {
        $carrersArray   = $this->_registry->registry('CarrierCodes');
        $carrersTitle   = $this->_registry->registry('CarrierTitle');
        $result = $this->_rateResultFactory->create();

        foreach ($quotes as $carrierkey => $quote) {
            foreach ($quote as $key => $carreir) {
                $method = $this->_rateMethodFactory->create();
                
                $method->setCarrierTitle($carrersTitle[$carrierkey]);
                $method->setCarrier($carrersArray[$carrierkey]);
                $method->setMethod($carreir['code']);
                $method->setMethodTitle($carreir['title']);
                $method->setPrice($carreir['rate']);

                $result->append($method);
            }
        }
        return $result;
    }

This is my function and i am not using any type of condition for users.
Allow guest checkout is enabled in admin side.

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

I do have th exact samae problem. It's a custom shipping module and the shipping_method is missing for logged in users...

 

BUT, I think I found a solution (because it works after several hours)... what is your "Shipping Method Code"?

does it have a "_"? If so, remove it and adapt the .xml files and have another try.

DI Alexander Herzog | Rent-a-Ninja.org ... don't worry, I've got this!

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

Any solution or suggestion ?

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

like I edited above: check if you have a "_" in your shipping code.

 

....
class Customshipping extends AbstractCarrier implements CarrierInterface
{
        /**
        * Carrier's code
        * @var string
        */
        protected $_code = 'donotuseunderlines';

....

at least it worked at my place... I guess... If so, let me know.

DI Alexander Herzog | Rent-a-Ninja.org ... don't worry, I've got this!

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

Other possible source of this issue worth to mention is custom carrier code length.
Because of quote_address.shipping_method column 40 chars limit, it will follow to null data inside this column after order submit. So carrier code length needs to meet two conditions.

  1. no "_" char inside
  2. length below 19 chars

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

This worked for me! I've used Tobias Forkel's custom shipping extension for a ton of projects and couldn't figure out what I was missing. 

 

Checkout line 32 here => https://github.com/tobias-forkel/Magento2_CustomShipping/blob/master/Model/Carrier/Custom.php

 

After changing every instance of "forkel_customshipping" to "forkelcustomshippin" everything magically started working again. So clearly, the removal of underscores & limiting the strlen to 19 saved the day. Thanks for sharing!

Re: “Please specify a shipping method” when logged in user try to place order in magento 2

im using stock shipping and im not so familiar with coding for magento so as far i noticed the main file to edit is :/var/www/html/magento2/vendor/magento/module-shipping/Model/Carrier/abstractCarrier.php am i right??