【问题标题】:Why is the invoice page different for another user?为什么其他用户的发票页面不同?
【发布时间】:2015-02-22 14:53:20
【问题描述】:

当我以管理员身份转到admin/store/orders/50457/invoice 时,我看到以下内容:

注意它有一个“免费订单”的付款方式,底部的总金额是 0.00 美元。

当我以非管理员身份访问同一页面时,我看到以下内容: 请注意付款方式为空,订单总额为 8.21 美元。

正确的是管理员看到的,那么到底是怎么回事导致两者的行为不同?

编辑:事实证明,在我(很久以前)创建的一个名为 tf_store_credit.module 的模块中,我有以下内容:

function tf_store_credit_line_item(){

    global $user;
    $total_credit= uc_store_credit_f_get_user_credit($user->uid);

    if ($total_credit>0){
        $items[] = array
          (
            'id' => 'store-credit', // You will use this ID in the javascript 
            'title' => t('Store Credit'), // This is the text that will be displayed on the line item in the subtotal
            'callback' => 'tf_store_credit_line_item_callback', // This is the callback function
            'stored' => TRUE,
            'default' => FALSE,
            'calculated' => TRUE,
            'display_only' => FALSE,
            'weight' => 15,
          );
    }
    return $items;
}

问题在于它获取的是当前登录用户的商店信用,而不是下订单的用户。那么我该如何获得正确的用户呢?

【问题讨论】:

    标签: drupal ubercart


    【解决方案1】:

    tf_store_credit.module中,我是这样修改的:

    function tf_store_credit_line_item(){
    
        global $user;
        $total_credit= uc_store_credit_f_get_user_credit($user->uid);
    
        if ($total_credit>0 || in_array("view_orders", $user->roles)){
            $items[] = array
              (
                'id' => 'store-credit', // You will use this ID in the javascript 
                'title' => t('Store Credit'), // This is the text that will be displayed on the line item in the subtotal
                'callback' => 'tf_store_credit_line_item_callback', // This is the callback function
                'stored' => TRUE,
                'default' => FALSE,
                'calculated' => TRUE,
                'display_only' => FALSE,
                'weight' => 15,
              );
        }
        return $items;
    }
    

    在 uc_free_order.module 中,我做了类似的事情,所以“付款方式”出现了:

    function uc_free_order_payment_method() {
      global $user;
    
      if ($user->name=='blah' || $user->name=='blah2' || in_array("view_orders", $user->roles)){
          $methods[] = array(
            'id' => 'free_order',
            'name' => t('Free order'),
            'title' => t('Free order - payment not necessary.'),
            'desc' => t('Allow customers with $0 order totals to checkout without paying.'),
            'callback' => 'uc_payment_method_free_order',
            'checkout' => TRUE,
            'no_gateway' => TRUE,
            'weight' => 10,
          );
    
          return $methods;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-04-11
      • 2017-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多