【问题标题】:How to customize invoice page in Ubercart 3如何在 Ubercart 3 中自定义发票页面
【发布时间】:2011-11-22 14:46:50
【问题描述】:

我需要自定义用户在 url 看到的页面:user/%user/orders/%uc_order

我尝试使用 hook_uc_order_pane

function mymodule_uc_order_pane() {
  $panes['ship_to_xx'] = array(
  'callback' => 'mymodule_uc_order_pane_ship_to_xx',
  'title' => t('Just a Test'),
  'desc' => t("Description!!"),
  'class' => 'pos-left',
  'weight' => 99,
  'show' => array('view', 'edit', 'invoice', 'customer'),
  );
  return $panes;
}

并清除了所有缓存,但这不起作用。它不显示任何内容。 你有什么建议吗?

【问题讨论】:

标签: php drupal drupal-7 ubercart


【解决方案1】:

代码没有错。 正确的做法是:

function mymodule_uc_order_pane() {
    $panes['mm_links'] = array(
    'callback' => 'mymodule_uc_order_pane_links',
    'title' => t('Just a Test'),
    'desc' => t("Description!!"),
    'class' => 'pos-left',
    'weight' => 99,
    'show' => array('customer'),
    );
    return $panes;
}

function mymodule_uc_order_pane_links($op,$order){
    $html='';
    foreach($order->products as $product){
        $node = node_load($product->nid);
        $html.='Date: '.$product->data['attributes']['Tour Date'][0].'<br/>';
        $html.='Parent ID: '.$node->field_tour['und'][0]['nid'].'<br/>';
    }   
    return ($html);
}

【讨论】:

  • 更好的是在 mymodule_uc_order_pane_links 中使用 switch($op)。在这种情况下,$op 可能是窗格主体的 'customer'、'show_title'、true 或 false 来显示标题和 'view-title' 来定义标题内容。使用 Drupal 的主题功能也比编写原始 HTML 更好。即:$build = array('#markup' => $html);return $build;
猜你喜欢
  • 2011-03-08
  • 2012-02-22
  • 2011-06-14
  • 1970-01-01
  • 2022-06-11
  • 1970-01-01
  • 2018-05-25
  • 2011-03-05
  • 2015-06-07
相关资源
最近更新 更多