0

I have created one custom shipping method, I need to change shipping method title dynamically.

public function collectRates(RateRequest $request) { if (!$this->isActive()) { return false; }

    $result = $this->_rateResultFactory->create();

    $shippingPrice = 15;//$this->getConfigData('price'); //this is updating price at run time

    $method = $this->_rateMethodFactory->create();

    $method->setCarrier($this->getCarrierCode());
    $method->setCarrierTitle($this->getConfigData('title'));

    $method->setMethod($this->getCarrierCode());
    $method->setMethodTitle("custom title");//($this->getConfigData('name')); this is not working

    $method->setPrice($shippingPrice);
    $method->setCost($shippingPrice);

    $result->append($method);
    return $result;
}

But its not working.

  • 1
    Show your code that you tried – Sohel Rana Jan 31 at 17:37
  • 1
    please post your carrier code – fmsthird Feb 1 at 8:11
  • @magefms , please check I updated my question. – Surjan Raghuwanshi Feb 1 at 9:52
  • try to set your $method->setMethod('static code of your shipping method'); and check – fmsthird Feb 1 at 9:54
  • the static code I am talking here is the group id of your custom shipping method defined in config.xml and system.xml in admin – fmsthird Feb 1 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.