@@ -120,15 +120,31 @@ public function collectRates(\Magento\Quote\Model\Quote\Address\RateRequest $req
120120 if ($ blacklist === true ) {
121121 return $ result ;
122122 }
123+
124+ $ ratesAdded = false ;
125+
123126 foreach ($ this ->getMethods () as $ key => $ title ) {
127+ if ($ key === 'fallback ' ) {
128+ continue ;
129+ }
124130 $ method = $ this ->getShippingMethod ($ request , $ key , $ blacklist );
125131 if ($ method ) {
126132 $ this ->debugLogger ->info ("CARRIER successfully added method $ key to RateRequest " );
127133 $ result ->append ($ method );
134+ $ ratesAdded = true ;
128135 } else {
129136 $ this ->debugLogger ->info ("CARRIER failed to add method $ key to RateRequest " );
130137 }
131138 }
139+
140+ if (!$ ratesAdded ) {
141+ $ method = $ this ->getShippingMethod ($ request , 'fallback ' , $ blacklist );
142+ if ($ method ) {
143+ $ this ->debugLogger ->info ("Appending fallback shipping method. " );
144+ $ result ->append ($ method );
145+ }
146+ }
147+
132148 $ this ->debugLogger ->info ('CARRIER --- collect rates finished ' , $ result ->asArray ());
133149 return $ result ;
134150 }
@@ -173,10 +189,12 @@ protected function getShippingMethod(
173189 $ toBusiness = $ this ->presetService ->defaultToBusiness ($ this ->storeManager ->getStore ()->getId ());
174190 $ requestOptions = array_keys ($ presetOptions );
175191
176- $ sizes = $ this ->capabilityService ->getSizes ($ this ->storeManager ->getStore ()->getId (), $ toCountry , $ toPostalCode , $ toBusiness , $ requestOptions );
177- if (empty ($ sizes )) {
178- $ this ->debugLogger ->info ("CARRIER method $ methodKey not available due to capabilities " , ['options ' => $ requestOptions , 'response ' => $ sizes ]);
179- return null ;
192+ if ($ methodKey !== 'fallback ' ) {
193+ $ sizes = $ this ->capabilityService ->getSizes ($ this ->storeManager ->getStore ()->getId (), $ toCountry , $ toPostalCode , $ toBusiness , $ requestOptions );
194+ if (empty ($ sizes )) {
195+ $ this ->debugLogger ->info ("CARRIER method $ methodKey not available due to capabilities " , ['options ' => $ requestOptions , 'response ' => $ sizes ]);
196+ return null ;
197+ }
180198 }
181199
182200 // Calculate service costs
@@ -380,6 +398,7 @@ public function getTrackingUrl($trackerCode)
380398 protected function getMethods ($ key = null )
381399 {
382400 $ methods = [
401+ PresetService::SHIPPING_METHOD_STANDARD => __ ('Standard delivery ' ),
383402 PresetService::SHIPPING_METHOD_DOOR => __ ('Standard delivery ' ),
384403 PresetService::SHIPPING_METHOD_EVENING => __ ('Evening delivery ' ),
385404 PresetService::SHIPPING_METHOD_NO_NEIGHBOUR => __ ('No neighbour delivery ' ),
0 commit comments