Here's a quick & dirty patch to hide the "Click here to view your order history" section of the user page if the user has no order history to view. It leaves the Orders tab alone, so the (empty) order history is still accessible; only the misleading link is removed.
in version 1.12.2.40 of uc_order/uc_order.module, change
<?php
function uc_order_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch ($op) {
case 'view':
if ($user->uid && (($user->uid == $account->uid && user_access('view own orders')) || user_access('view all orders'))) {
$account->content['orders'] = array(
'#type' => 'user_profile_category',
'#weight' => -5,
'#title' => t('Orders'),
'link' => array(
'#type' => 'user_profile_item',
'#value' => l(t('Click here to view your order history.'), 'user/'. $account->uid .'/orders'),
),
);
}
break;
}
}
?>to
<?php
function uc_order_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch ($op) {
case 'view':
if ($user->uid && (($user->uid == $account->uid && user_access('view own orders')) || user_access('view all orders'))) {
$result = db_fetch_object(db_query("SELECT o.order_id FROM {uc_orders} AS o WHERE o.uid = %d AND o.order_status IN ". uc_order_status_list('general', TRUE), $user->uid));
if (!$result) return;
$account->content['orders'] = array(
'#type' => 'user_profile_category',
'#weight' => -5,
'#title' => t('Orders'),
'link' => array(
'#type' => 'user_profile_item',
'#value' => l(t('Click here to view your order history.'), 'user/'. $account->uid .'/orders'),
),
);
}
break;
}
}
?>(The two lines involving $result are the ones that have been added.)
Hope this helps someone besides myself!
