Skip to content

magento/magento2#23143: Code optimization for the offline shipping methods #23144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/code/Magento/OfflineShipping/Model/Carrier/Flatrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function __construct(
}

/**
* Collect and get rates
*
* @param RateRequest $request
* @return Result|bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
Expand Down Expand Up @@ -97,6 +99,8 @@ public function collectRates(RateRequest $request)
}

/**
* Get count of free boxes
*
* @param RateRequest $request
* @return int
*/
Expand All @@ -120,14 +124,18 @@ private function getFreeBoxesCount(RateRequest $request)
}

/**
* Get allowed shipping methods
*
* @return array
*/
public function getAllowedMethods()
{
return ['flatrate' => $this->getConfigData('name')];
return [$this->_code => $this->getConfigData('name')];
}

/**
* Returns shipping price
*
* @param RateRequest $request
* @param int $freeBoxes
* @return bool|float
Expand All @@ -154,6 +162,8 @@ private function getShippingPrice(RateRequest $request, $freeBoxes)
}

/**
* Creates result method
*
* @param int|float $shippingPrice
* @return \Magento\Quote\Model\Quote\Address\RateResult\Method
*/
Expand All @@ -174,6 +184,8 @@ private function createResultMethod($shippingPrice)
}

/**
* Returns free boxes count of children
*
* @param mixed $item
* @return mixed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ protected function _updateFreeMethodQuote($request)
*/
public function getAllowedMethods()
{
return ['freeshipping' => $this->getConfigData('name')];
return [$this->_code => $this->getConfigData('name')];
}
}
4 changes: 3 additions & 1 deletion app/code/Magento/OfflineShipping/Model/Carrier/Pickup.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public function __construct(
}

/**
* Collect and get rates
*
* @param RateRequest $request
* @return \Magento\Shipping\Model\Rate\Result
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
Expand All @@ -75,6 +77,6 @@ public function collectRates(RateRequest $request)
*/
public function getAllowedMethods()
{
return ['pickup' => __('Store Pickup')];
return [$this->_code => __('Store Pickup')];
}
}