Skip to content

Commit 63a908c

Browse files
authored
ENGCOM-5215: #23143: Code optimization for the offline shipping methods #23144
2 parents ab4b9e8 + ba59522 commit 63a908c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

app/code/Magento/OfflineShipping/Model/Carrier/Flatrate.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public function __construct(
6969
}
7070

7171
/**
72+
* Collect and get rates
73+
*
7274
* @param RateRequest $request
7375
* @return Result|bool
7476
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -97,6 +99,8 @@ public function collectRates(RateRequest $request)
9799
}
98100

99101
/**
102+
* Get count of free boxes
103+
*
100104
* @param RateRequest $request
101105
* @return int
102106
*/
@@ -120,14 +124,18 @@ private function getFreeBoxesCount(RateRequest $request)
120124
}
121125

122126
/**
127+
* Get allowed shipping methods
128+
*
123129
* @return array
124130
*/
125131
public function getAllowedMethods()
126132
{
127-
return ['flatrate' => $this->getConfigData('name')];
133+
return [$this->_code => $this->getConfigData('name')];
128134
}
129135

130136
/**
137+
* Returns shipping price
138+
*
131139
* @param RateRequest $request
132140
* @param int $freeBoxes
133141
* @return bool|float
@@ -154,6 +162,8 @@ private function getShippingPrice(RateRequest $request, $freeBoxes)
154162
}
155163

156164
/**
165+
* Creates result method
166+
*
157167
* @param int|float $shippingPrice
158168
* @return \Magento\Quote\Model\Quote\Address\RateResult\Method
159169
*/
@@ -174,6 +184,8 @@ private function createResultMethod($shippingPrice)
174184
}
175185

176186
/**
187+
* Returns free boxes count of children
188+
*
177189
* @param mixed $item
178190
* @return mixed
179191
*/

app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ protected function _updateFreeMethodQuote($request)
144144
*/
145145
public function getAllowedMethods()
146146
{
147-
return ['freeshipping' => $this->getConfigData('name')];
147+
return [$this->_code => $this->getConfigData('name')];
148148
}
149149
}

app/code/Magento/OfflineShipping/Model/Carrier/Pickup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function __construct(
5858
}
5959

6060
/**
61+
* Collect and get rates
62+
*
6163
* @param RateRequest $request
6264
* @return \Magento\Shipping\Model\Rate\Result
6365
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -75,6 +77,6 @@ public function collectRates(RateRequest $request)
7577
*/
7678
public function getAllowedMethods()
7779
{
78-
return ['pickup' => __('Store Pickup')];
80+
return [$this->_code => __('Store Pickup')];
7981
}
8082
}

0 commit comments

Comments
 (0)