Search code examples
twigopencartshipping-method

HTML codes won't work in OpenCart shipping Method label


I want to have custom code in my shipping Method label but by default, OpenCart stops the code I think for security reasons with adding quote before and after my code, so it won't work and show correctly.

Is there any way to fix this problem?

Also is there any security issues that I might face by doing this? (since it's a checkbox I personally think it's safe)

Thank you guys please check this image I have sent you. OpecCart shipping_method file

Best regards


Solution

  • It is not a template issue. Go to catalog/model/extension/shipping/xshippingpro.php There you will find

    $quote_data['xshippingpro'.$tab_id] = array(
    

    And inside of it

    'text'         => $this->currency->format($this->tax->calculate($cost, $xshippingpro['tax_class_id'], $this->config->get('config_tax')),$currency_code)
    

    You can add your custom code here, only here, if you want to modify only X Shipping.

    You can change title to

    'text'         => '<span style="color: #d1383d; font-weight: bold;">' . $this->currency->format($this->tax->calculate($cost, $xshippingpro['tax_class_id'], $this->config->get('config_tax')),$currency_code) . '</span>'
    

    UPDATED

    To set custom text in title in the same document find

    'title'        => $xshippingpro['name'][$language_id],
    

    change to

    'title'        => 'custom text <span style="color: #d1383d; font-weight: bold;">' . $xshippingpro['name'][$language_id] . '</span>custom text',
    

    UPDATE 2

    To use custom html like in you example (overwrite security), change

    'title'        => $xshippingpro['name'][$language_id],
    

    into

    'title'        => html_entity_decode($xshippingpro['name'][$language_id], ENT_QUOTES, 'UTF-8'),