Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Please specify a shipping method" Exception #5021

Closed
vphat28 opened this issue Jun 14, 2016 · 23 comments
Closed

"Please specify a shipping method" Exception #5021

vphat28 opened this issue Jun 14, 2016 · 23 comments
Labels
bug report Component: Shipping Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed

Comments

@vphat28
Copy link

vphat28 commented Jun 14, 2016

Steps to reproduce

  1. Install Magento from develop branch.
  2. Install 3rd test shipping provider
  3. Able to show rate in checkout page
  4. Able to choose payment methods
  5. Click on "Place order"
  6. Exception is throwed "Please specify a shipping method"

Expected result

  1. Should go to success page

Actual result

  1. Exception is throwed "Please specify a shipping method"

I searched for the string and in file \vendor\magento\module-quote\Model\QuoteValidator.php line 53
the $method variable is null

My collectrates in shipping adapter is
$method = $this->_rateMethodFactory->create();

        $method->setCarrier($this->_code);
        $method->setCarrierTitle($this->getConfigData('name'));

        $method->setMethod('express_method');
        $method->setMethodTitle($this->getConfigData('express_title'));

        $method->setPrice($this->getConfigData('express_price'));
        $method->setCost($this->getConfigData('express_price'));

        $result->append($method);

I noticed that when I remove the underscore symple and change $method->setMethod('express_method'); to $method->setMethod('expressmethod');
the checkout went through successfully.

I wonder can I use "_" symbol in function setmethod? I don't have this problem in magento 1

@vphat28
Copy link
Author

vphat28 commented Jun 14, 2016

I need to modify my code to this , and checkout went through

        $code = str_ireplace('_','',strtolower($code) );
        $method = $this->_rateMethodFactory->create();
$method->setMethod($code);

@lutpiero
Copy link

I have remove underscore too, but no success.

The error message ("Please specify a shipping method") still showing

@vphat28
Copy link
Author

vphat28 commented Jun 16, 2016

@lutpiero you may need to covert string to lower also

@lutpiero
Copy link

Same as yours, but still no luck

@vphat28
Copy link
Author

vphat28 commented Jun 16, 2016

I found that we can't use long name :( try that

@dyushkin
Copy link
Contributor

dyushkin commented Sep 8, 2016

Hi @vphat28! Please specify what 3rd party shipping provider do you use?

@vphat28
Copy link
Author

vphat28 commented Sep 13, 2016

hi @dyushkin it's just my custom test shipping with offline payment

@bobbyshaw
Copy link

I have also been experiencing this with our Meanbee Royal Mail extension for Magento 2.

After adding a log line to \vendor\magento\module-quote\Model\QuoteValidator.php. I also can see that a method code is fetched but no rate.

The logging suggests that the method code has been truncated and so when it tries to find a rate it is unable.

Royal Mail Method: meanbee_royalmail_firstclasssignedforsma {"is_exception":false} []

The code above should be "meanbee_royalmail_firstclasssignedforsmall".

When I change the Carrier code to "rm" and therefore the shipping code reduces to "rm_firstclasssignedforsmall" without being truncated, the PayPal Express order with review step enabled works.

@magento-engcom-team
Copy link
Contributor

Hi @vphat28
Unfortunately, we can not reproduce the issue on clean Magento installation. But looks like you found a solution for your issue.

@magento-engcom-team magento-engcom-team added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Sep 30, 2017
@bobbyshaw
Copy link

@magento-engcom-team I think it would be worth adding documentation for maximum carrier + rate name length. Otherwise, it becomes quite an obtuse error when creating custom shipping methods.

@dtamajon
Copy link

@bobbyshaw, do you know which is the maximum length allowed?

@bobbyshaw
Copy link

I'm not 100% but I think it's 40 characters.

@dtamajon
Copy link

Thank you!

@tufahu
Copy link
Contributor

tufahu commented Oct 26, 2017

Thank you @vphat28 ! I've had the same issue. Removing underscore solved it.

@magento-engcom-team Have you tried it on magento 2.2.0 ? (I didn't have this issue at 2.1.9)

@BergMedia
Copy link

The issue is persistend in 2.1.9 - my shipping extension has the underscore - after remove everything works as expected. Thanks vphat28

tobias-forkel added a commit to tobias-forkel/Magento2_CustomShipping that referenced this issue Nov 30, 2017
tobias-forkel added a commit to tobias-forkel/Magento2_CustomShipping that referenced this issue Nov 30, 2017
@jimuld
Copy link
Contributor

jimuld commented Apr 6, 2018

Longer shipping method code cause issue. After minimized shipping method worked for me too.

@vphat28, thanks for kind info.

@idziakjakub
Copy link
Contributor

I have the same problem with underscore in my shipping carrier code and rate (Magento 2.2.5).
This issue is only for logged in customers.

@magento-engcom-team - I found code responsible for this issue and I in my opinion it isn't good idea do explode on shipping method code in method responsible for save payment information \Magento\Checkout\Model\PaymentInformationManagement::savePaymentInformation method:

https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Checkout/Model/PaymentInformationManagement.php#L118

    if ($shippingAddress && $shippingAddress->getShippingMethod()) {
        $shippingDataArray = explode('_', $shippingAddress->getShippingMethod());
        $shippingCarrier = array_shift($shippingDataArray);
        $shippingAddress->setLimitCarrier($shippingCarrier);
    }

I have solution for it and I will upload pull request soon.

@ccrothers
Copy link

idziakjakub is correct. That behavior is identical to issues we are having with a carrier code containing an underscore.

@sidolov
Copy link
Contributor

sidolov commented Oct 27, 2018

Hi @vphat28. Thank you for your report.
The issue has been fixed in #18689 by @idziakjakub in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@magento-engcom-team
Copy link
Contributor

Hi @vphat28. Thank you for your report.
The issue has been fixed in #18870 by @gelanivishal in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@magento-engcom-team
Copy link
Contributor

Hi @vphat28. Thank you for your report.
The issue has been fixed in #19505 by @vovsky in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

@magento-engcom-team
Copy link
Contributor

Hi @vphat28. Thank you for your report.
The issue has been fixed in #21340 by @hostep in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.9 release.

@blackstalk
Copy link

Please see my solution here: https://magento.stackexchange.com/a/320495/15474

You need to use this model \Magento\Quote\Model\Quote\Address\Rate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Shipping Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed
Projects
None yet
Development

No branches or pull requests