当我以管理员身份转到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;
}
问题在于它获取当前登录用户的商店信用,而不是下订单的用户。那么我将如何获得正确的用户呢?
答案 0 :(得分:0)
在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;
}
}