cancel
Showing results for 
Search instead for 
Did you mean: 

How to set Magento 2 Totals title

Highlighted

How to set Magento 2 Totals title

I have setup a custom total "oversized_shipping_fee" however I am not able to set the title in the js totals object for some reason as seen below:
my code is as follows:


class OversizedShippingFee extends AbstractTotal
{

/**
* @var Client
*/
private $client;

/**
* OversizedShippingFee constructor.
* @param Client $client
*/
public function __construct(Client $client)
{
$this->_code ='oversized_shipping_fee';
$this->client = $client;
}

/**
* @param Quote $quote
* @param **bleep**(), $fee);
$quote->setData('oversized_shipping_fee', $fee);
$quote->setData('oversized_shipping_fee_code', $feeObject->getData('code'));
$quote->setData('oversized_shipping_fee_title', 'test');
}
return $this;
}

/**
* @param Quote $quote
* @param Total $total
* @return array
*/
public function fetch(Quote $quote, Total $total)
{
$fee = $this->getFee($quote)->getData('price');
$sku = $this->getFee($quote)->getData('description');


$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/total_segment.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info($sku);

return [
'code' => $this->getCode(),
'value' => $fee,
'title' => 'test'
] ;


}

/**
* @param Quote $quote
* @return DataObject
*/
private function getFee(Quote $quote): DataObject
{
$request = $this->client->createRequest();
$request->initRequest($quote);
try {
return $this->client->send($request)->getOversizedShippingFee();
} catch (ApiException $ignore) {
return new DataObject();
}
}
}