File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1312,13 +1312,20 @@ public function getResponse()
1312
1312
*/
1313
1313
public function getAllowedMethods ()
1314
1314
{
1315
+ $ allowedMethods = explode (', ' , (string )$ this ->getConfigData ('allowed_methods ' ));
1315
1316
$ isUpsXml = $ this ->getConfigData ('type ' ) === 'UPS_XML ' ;
1316
1317
$ origin = $ this ->getConfigData ('origin_shipment ' );
1317
- $ allowedMethods = $ isUpsXml
1318
+
1319
+ $ availableByTypeMethods = $ isUpsXml
1318
1320
? $ this ->configHelper ->getCode ('originShipment ' , $ origin )
1319
1321
: $ this ->configHelper ->getCode ('method ' );
1322
+
1323
+ $ filteredMethods = array_filter ($ availableByTypeMethods , function ($ methodCode ) use ($ allowedMethods ) {
1324
+ return in_array ($ methodCode , $ allowedMethods );
1325
+ }, ARRAY_FILTER_USE_KEY );
1326
+
1320
1327
$ methods = [];
1321
- foreach ($ allowedMethods as $ methodCode => $ methodData ) {
1328
+ foreach ($ filteredMethods as $ methodCode => $ methodData ) {
1322
1329
$ methods [$ methodCode ] = $ methodData ->getText ();
1323
1330
}
1324
1331
Original file line number Diff line number Diff line change @@ -404,6 +404,7 @@ public function countryDataProvider()
404
404
* @param string $methodType
405
405
* @param string $methodCode
406
406
* @param string $methodTitle
407
+ * @param string $allowedMethods
407
408
* @param array $expectedMethods
408
409
* @return void
409
410
*/
@@ -412,11 +413,18 @@ public function testGetAllowedMethods(
412
413
string $ methodType ,
413
414
string $ methodCode ,
414
415
string $ methodTitle ,
416
+ string $ allowedMethods ,
415
417
array $ expectedMethods
416
418
): void {
417
419
$ this ->scope ->method ('getValue ' )
418
420
->willReturnMap (
419
421
[
422
+ [
423
+ 'carriers/ups/allowed_methods ' ,
424
+ ScopeInterface::SCOPE_STORE ,
425
+ null ,
426
+ $ allowedMethods
427
+ ],
420
428
[
421
429
'carriers/ups/type ' ,
422
430
ScopeInterface::SCOPE_STORE ,
@@ -449,13 +457,23 @@ public function allowedMethodsDataProvider(): array
449
457
'method ' ,
450
458
'1DM ' ,
451
459
'Next Day Air Early AM ' ,
460
+ '' ,
461
+ [],
462
+ ],
463
+ [
464
+ 'UPS ' ,
465
+ 'method ' ,
466
+ '1DM ' ,
467
+ 'Next Day Air Early AM ' ,
468
+ '1DM,1DML,1DA ' ,
452
469
['1DM ' => 'Next Day Air Early AM ' ],
453
470
],
454
471
[
455
472
'UPS_XML ' ,
456
473
'originShipment ' ,
457
474
'01 ' ,
458
475
'UPS Next Day Air ' ,
476
+ '01,02,03 ' ,
459
477
['01 ' => 'UPS Next Day Air ' ],
460
478
],
461
479
];
You can’t perform that action at this time.
0 commit comments