magento2: "Please specify a shipping method" Exception
Steps to reproduce
- Install Magento from
develop
branch. - Install 3rd test shipping provider
- Able to show rate in checkout page
- Able to choose payment methods
- Click on “Place order”
- Exception is throwed “Please specify a shipping method”
Expected result
- Should go to success page
Actual result
- 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
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 23 (9 by maintainers)
Commits related to this issue
- Rename Carrier from "meanbee_royalmail" to "rm" to make it shorter and less likely to hit a Magento bug. See https://github.com/magento/magento2/issues/5021 — committed to meanbee/magento2-royalmail by bobbyshaw 8 years ago
- Remove underscore in shipping method code. https://github.com/magento/magento2/issues/5021 — committed to tobias-forkel/Magento2_CustomShipping by tobias-forkel 7 years ago
- Remove underscore in shipping method code. https://github.com/magento/magento2/issues/5021 — committed to tobias-forkel/Magento2_CustomShipping by tobias-forkel 7 years ago
- Merge pull request #5021 from magento-tsg/2.3-develop-com-pr5 [TSG-Commerce] Tests for 2.3 (pr5) (2.3-develop) — committed to magento/magento2 by zakdma 5 years ago
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 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.
I need to modify my code to this , and checkout went through
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
I have solution for it and I will upload pull request soon.
Hi @vphat28. Thank you for your report. The issue has been fixed in magento/magento2#21340 by @hostep in 2.2-develop branch Related commit(s):
The fix will be available with the upcoming 2.2.9 release.
Hi @vphat28. Thank you for your report. The issue has been fixed in magento/magento2#19505 by @vovsky in 2.3-develop branch Related commit(s):
The fix will be available with the upcoming 2.3.2 release.
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.
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.