0

I am making a shipping extension. All the things works great but one thing no.

My collectRates function who is responsible to show all shipping methods on the frontend is checking all.

Code:

/**
 * @param RateRequest $request
 * @return bool|Result
 */
public function collectRates(RateRequest $request)
{
    if (!$this->getConfigFlag('active')) {
        return false;
    }

    // $method->setCarrierTitle($this->getConfigData('title'));
    // $method->setMethodTitle($this->getConfigData('name'));

    /** @var \Magento\Shipping\Model\Rate\Result $result */
    $result = $this->_rateResultFactory->create();

    /** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */

    $listaObjetosFrete = array();
    $listaObjetosFrete = $this->obterListaObjetosFrete($request)->data;


    foreach($listaObjetosFrete as $objetoFrete){

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

        $method->setCarrier($this->_code);
        $method->setMethod($this->_code);

        $method->setMethodTitle($objetoFrete->descricao);
        $method->setCarrierTitle($objetoFrete->descricao);

        $this->getFinalPriceWithHandlingFee($objetoFrete->preco);

        $method->setPrice($objetoFrete->preco);
        $method->setCost($objetoFrete->preco);

        $result->append($method);
    }

    return $result;
}

Checkout page who shows all shipping methods:

enter image description here

0

Solved

The code was the same..

$method->setMethod($objetoFrete->descricao);
$method->setCarrier($this->_code);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.