1

对于某些产品,我希望有一个与默认值不同的特殊结帐完成消息。

我知道我可以通过将默认重定向页面更改为其他内容来做到这一点。 [我不确定这是否会带来另一个问题]

但是,我想知道是否有解决此问题的标准/更好的方法。

谢谢!,

D

4

2 回答 2

1

考虑字符串覆盖模块。这是关于它的引用(来自模块的项目页面):

提供一种快速简便的方法来替换网站上的任何文本。

特征:

  • 轻松替换任何通过t()
  • 语言环境支持,允许您覆盖任何语言的字符串
  • Ability to import/export *.po files, for easy migration from the Locale module
  • Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.
于 2010-04-12T07:57:05.847 回答
0

我想我想的唯一其他可能的方法是覆盖ubercart 用于显示消息的主题功能。这似乎是最有意义的。

在这种情况下,我会覆盖theme_uc_cart_complete_sale

我可以设置一个

$_SESSION['is_special_product'] == TRUE;

然后将 $message 设置为我的 $special_message(如果已设置)。

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

最后,要从我的模块中覆盖,我需要挂钩到预处理挂钩:

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;
    }
}

需要注意的是,在您的模块中拥有此功能是不够的。只有在调用覆盖主题函数的模板文件时才会调用预处理函数。

更多细节可以在http://drupal.org/node/223430找到

于 2010-04-09T20:24:40.760 回答