Faquir Faquir - 6 months ago 20
PHP Question

Edit weight based shipping titles in OpenCart

I'm using weight based shipping but I don't want the weight information to be displayed in the checkout page. Right now the displayed information is "USA (Weight: 0.00kg) $24.30", but all I want to be displayed is "USA $24.30".

In controller/checkout/shipping I'm printing the $this->data['shipping_methods'] variable, getting the following array:

Array
(
[weight] => Array
(
[title] => Weight Based Shipping
[quote] => Array
(
[weight_11] => Array
(
[id] => weight.weight_11
[title] => USA (Weight: 0.00kg)
[cost] => 24.3
[tax_class_id] => 0
[text] => $24.30
)

)

[sort_order] => 1
[error] =>
)
)


What I need is to, for each $this->data['shipping_methods']['weight']['quote'], change the title to a substr to minus 16 characters, in order display only the country info (USA, in this case).

How can I do this?

Answer

Open up file catalog/model/shipping/weight.php, find this line:

'title'        => $result['name'] . '  (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')',

replace with

'title'        => $result['name'],

done.

Best when applied via vQmod extension.

Comments