Skip to content

Code optimization for the offline shipping methods. #23143

@atwixfirster

Description

@atwixfirster

Summary (*)

Flat Rate, Free Shipping, and Store Pickup shipping methods use protected $_code variable to provide information about carrier's code.

For example, Flat Rate shipping method:

class Flatrate extends AbstractCarrier implements CarrierInterface
{
    /**
     * @var string
     */
    protected $_code = 'flatrate';

...

In the getAllowedMethods() function for this shipping method we have:

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

So, carrier's code is duplicated.

Examples (*)

Proposed solution

Use $this->_code in the getAllowedMethods() function of Flat Rate, Free Shipping, and Store Pickup.

For example, a code optimization for Flat Rate will look like:

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

Metadata

Metadata

Assignees

Labels

Fixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedimprovement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions