magepal / magento2-custom-shipping-rate

Create your own Custom Shipping rates for admin order or a predefined sets of shipping methods for frontend customers.
http://www.magepal.com
93 stars 32 forks source link

getAllowedMethods doesn't return methods set in config #17

Closed juhanihaapala closed 4 years ago

juhanihaapala commented 5 years ago

Magento version #: any

Edition (EE, CE, OS, etc): Open Source

Expected behavior:

getAllowedMethods to return methods set in config

Actual behavior:

getAllowedMethods return one with the carrier name image

Steps to reproduce:

Preconditions

srenon commented 5 years ago

Could you provide more information on what you are trying to do

if you take a look at the FedEx module

public function getAllowedMethods()
{
    $allowed = explode(',', $this->getConfigData('allowed_methods'));
    $arr = [];
    foreach ($allowed as $k) {
        $arr[$k] = $this->getCode('method', $k);
    }

    return $arr;
}

 <field id="allowed_methods" translate="label" type="multiselect" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
          <label>Allowed Methods</label>
          <source_model>Magento\Fedex\Model\Source\Method</source_model>
          <can_be_empty>1</can_be_empty>
</field>

But if you take a look at Flatrate

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

So what allows methods are you trying to use

juhanihaapala commented 5 years ago

I made pr what I mean

srenon commented 4 years ago

@juhanihaapala ... thanks for the PR