views:

115

answers:

2

There are some products for which I would like to have a special checkout complete message that would differ from the default.

I know that I could probably do this by changing the default redirect page to something else. [And I'm not sure if that would introduce another problem]

However, I would like to know if there is a standard/better way of approaching this problem.

Thanks!,

D

A: 

I guess the only other possible way of doing what I am thinking of is to override the theme function that ubercart uses to display the message. And this probably seems like it would make the most sense.

In this case I would override theme_uc_cart_complete_sale

I could set a

$_SESSION['is_special_product'] == TRUE;

and then set $message to my $special_message if it's been set.

if ($_SESSION['special_product']) {
      $special_message = t('This is my special message');
      $message = variable_get('special_product_message', $special_message;
    }

Finally, to override from my module I will need to hook into the pre-process hook:

function $modulename_prepocess_$hook(&$message) {
      if ($_SESSION['special_product']) {
      $special_message = t('This is my special message');
      $message = variable_get('special_product_message', $special_message;
    }
}

It is important to note that it is not enough to have this function in your module. The preprocess functions are only invoked when the template file that overrides the theme function is called.

More details can be found at http://drupal.org/node/223430

DKinzer
+1  A: 

http://drupal.org/project/stringoverrides

chx
Goes to show that there is usually an easier way :-)
DKinzer

related questions