Skip to content

Commit 72033b3

Browse files
wigmanspeedy008
authored andcommitted
Replace hardcoded CarierCode from createShippingMethod()
By taking carrier_code from $this->getCarrierCode(), which fetches $_code from this class, we make it easier to extend the default TableRate class. With this change, creating a new TableRate carrier is as easy as: Creating a new TableRate class such as ```class ExpressTablerate extends \Magento\OfflineShipping\Model\Carrier\Tablerate { /** * @var string */ protected $_code = 'express'; // phpcs:ignore }``` And creating the a new <config><default><carriers> node in config.xml: ``` <express> <active>0</active> <sallowspecific>0</sallowspecific> <condition_name>package_weight</condition_name> <include_virtual_price>1</include_virtual_price> <model>[NameSpace]\Shipping\Model\Carrier\ExpressTablerate</model> <name>Table Rate</name> <title>Best Way</title> <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> <handling_type>F</handling_type> </express>```
1 parent 848e1f9 commit 72033b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private function createShippingMethod($shippingPrice, $cost)
267267
/** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */
268268
$method = $this->_resultMethodFactory->create();
269269

270-
$method->setCarrier('tablerate');
270+
$method->setCarrier($this->getCarrierCode());
271271
$method->setCarrierTitle($this->getConfigData('title'));
272272

273273
$method->setMethod('bestway');

0 commit comments

Comments
 (0)