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.
Solved! Go to Solution.
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.
@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?
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.
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.
Any solution or suggestion ?
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.
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.
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!
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??