Since it's possible to put html on service name in #display_title in hook_commerce_shipping_service_info(), it should be allowed in checkout/review to.

So in commerce_shipping_pane_review, replace @service by !service.

Example :

/**
 * Implements hook_commerce_shipping_service_info().
 */
function chronopost_shipping_commerce_shipping_service_info() {

  $shipping_services['chronopost'] = array(
    'title' => t('Chronopost'),
    'description' => t('Home delivery.'),
    'display_title' => '<span id="chronopost-logo"></span>' . t('Chronopost'),
    'shipping_method' => 'chronopost',
    'price_component' => 'shipping',
    'callbacks' => array(
      'rate' => 'chronopost_default_service_rate',
    ),
  );
  return $shipping_services;
}

in commerce_shipping.checkout_pane.inc, replace @service by !service to allowed html markup.

/**
 * Checkout pane callback: show the selected shipping service on the review pane.
 */
function commerce_shipping_pane_review($form, $form_state, $checkout_pane, $order) {
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

  // Loop over all the line items on the order.
  foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
    // If the current line item is a shipping line item...
    if ($line_item_wrapper->type->value() == 'shipping') {
      // Return its label and formatted total price.
      $total_price = $line_item_wrapper->commerce_total->value();
      $rate = commerce_currency_format($total_price['amount'], $total_price['currency_code'], $line_item_wrapper->value());
      return t('!service: @rate', array('!service' => $line_item_wrapper->line_item_label->value(), '@rate' => $rate));
    }
  }
}

Comments

goz’s picture

Title: Allow html on service name review » Allow html on service name in pane review
goz’s picture

Here patch to make this.

goz’s picture

Status: Active » Needs review
joelpittet’s picture

Title: Allow html on service name in pane review » Allow HTML on service name and rate in pane review
StatusFileSize
new841 bytes
new980 bytes

@GoZ let's do this for both. The rate is already escaped heavily in commerce_currency_format().

In my case I've overridden that format_callback and wrapped the code and symbol in a span tag for styling purposes and escaped the variable going into them.

joelpittet’s picture

And if this can't make it in, we can fallback to hook_commerce_checkout_pane_info_alter;)


/**
 * Implements hook_commerce_checkout_pane_info_alter().
 *
 * Use new checkout pane callbacks, for adding the fields to payment details.
 */
function MODULE_commerce_checkout_pane_info_alter(&$checkout_panes) {
  $checkout_panes['commerce_shipping']['callbacks']['review'] = 'MODULE_commerce_shipping_pane_review';
}

/**
 * Checkout pane callback: show the selected shipping service on the review pane.
 */
function MODULE_commerce_shipping_pane_review($form, $form_state, $checkout_pane, $order) {
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

  // Loop over all the line items on the order.
  foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
    // If the current line item is a shipping line item...
    if ($line_item_wrapper->type->value() == 'shipping') {
      // Return its label and formatted total price.
      $total_price = $line_item_wrapper->commerce_total->value();
      $rate = commerce_currency_format($total_price['amount'], $total_price['currency_code'], $line_item_wrapper->value());
      return t('!service: !rate', array('!service' => $line_item_wrapper->line_item_label->value(), '!rate' => $rate));
    }
  }
}


googletorp’s picture

Sorry for missing this.

I don't see why we shouldn't include this, review and committed.

googletorp’s picture

Status: Needs review » Fixed

  • googletorp committed 7e8be64 on 7.x-2.x authored by GoZ
    Issue #2344739 by GoZ, joelpittet, googletorp: Allow HTML on service...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.