Skip to content

Commit 67c368b

Browse files
committed
MC-29444: Extra Values of UPS and USPS are in dropdown list Cart Price Rule - Condition - Shipping Method
1 parent 4b81e7b commit 67c368b

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,13 +1312,20 @@ public function getResponse()
13121312
*/
13131313
public function getAllowedMethods()
13141314
{
1315+
$allowedMethods = explode(',', (string)$this->getConfigData('allowed_methods'));
13151316
$isUpsXml = $this->getConfigData('type') === 'UPS_XML';
13161317
$origin = $this->getConfigData('origin_shipment');
1317-
$allowedMethods = $isUpsXml
1318+
1319+
$availableByTypeMethods = $isUpsXml
13181320
? $this->configHelper->getCode('originShipment', $origin)
13191321
: $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+
13201327
$methods = [];
1321-
foreach ($allowedMethods as $methodCode => $methodData) {
1328+
foreach ($filteredMethods as $methodCode => $methodData) {
13221329
$methods[$methodCode] = $methodData->getText();
13231330
}
13241331

app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ public function countryDataProvider()
404404
* @param string $methodType
405405
* @param string $methodCode
406406
* @param string $methodTitle
407+
* @param string $allowedMethods
407408
* @param array $expectedMethods
408409
* @return void
409410
*/
@@ -412,11 +413,18 @@ public function testGetAllowedMethods(
412413
string $methodType,
413414
string $methodCode,
414415
string $methodTitle,
416+
string $allowedMethods,
415417
array $expectedMethods
416418
): void {
417419
$this->scope->method('getValue')
418420
->willReturnMap(
419421
[
422+
[
423+
'carriers/ups/allowed_methods',
424+
ScopeInterface::SCOPE_STORE,
425+
null,
426+
$allowedMethods
427+
],
420428
[
421429
'carriers/ups/type',
422430
ScopeInterface::SCOPE_STORE,
@@ -449,13 +457,23 @@ public function allowedMethodsDataProvider(): array
449457
'method',
450458
'1DM',
451459
'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',
452469
['1DM' => 'Next Day Air Early AM'],
453470
],
454471
[
455472
'UPS_XML',
456473
'originShipment',
457474
'01',
458475
'UPS Next Day Air',
476+
'01,02,03',
459477
['01' => 'UPS Next Day Air'],
460478
],
461479
];

0 commit comments

Comments
 (0)