If a custom checkout message body for is created at "admin/store/settings/checkout/edit/messages" then the new message will be dispalyed to the user on completion of the checkout without the special tokens "!new_username" or "!new_password" being replaced by their actual values.

The problem arises in function uc_cart_complete_sale (file uc_cart.module) because the string substition is done when the default message is retrieved in the line

    'uc_msg_order_' . $type => strtr(uc_get_message('completion_' . $type), $variables),

but this message text is later replaced by the custom version in the line

    $message = variable_get($id, $message);

The solution is to remove the "strtr" function call from the first line and add it to the second one. This will have trhe effect of passing all the messages through the function, but this should not cause problems. It will in fact provide opportunities to add special tokens to any of the messages at a later time if that is required.

The resulting code is then:

  $messages = array(
    'uc_msg_order_submit' => uc_get_message('completion_message'),
    'uc_msg_order_' . $type => uc_get_message('completion_' . $type),
    'uc_msg_continue_shopping' => uc_get_message('continue_shopping'),
  );
  foreach ($messages as $id => &$message) {
    $message = strtr(variable_get($id, $message), $variables);
    $message = token_replace_multiple($message, array('global' => NULL, 'order' => $order));
    $message = check_markup($message, variable_get($id . '_format', FILTER_FORMAT_DEFAULT), FALSE);
  }

This problem is still present in the head of branch 6.x-2.x.

I will prepare and post a patch.

Comments

jayelless’s picture

Status: Active » Needs review
StatusFileSize
new1 KB

Patch attached.

longwave’s picture

Status: Needs review » Fixed

This was already fixed in 7.x in commit 738fee1d, so I modified your patch to be closer to 7.x for consistency. Thanks for the report!

jayelless’s picture

Thanks for the update.

I notice that the 6.x-2.x branch has a number of changes since the 2.7 release. Is there likely to be a 6.x-2.8 release sometime soon?

Cheers!

longwave’s picture

6.x-2.8 is indeed "coming soon" but there is no fixed release date.

Status: Fixed » Closed (fixed)

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