How To Check / Test If User Has Ordered In Template

We wanted to show an img / icon on the users.profile page if they have ordered.

i found another thread where someone used

function fn_my_changes_get_users($params, $fields, $sortings, $condition, $join)
{
$user['user_completed_order'] = db_get_field('SELECT COUNT(*) FROM ?:orders WHERE (email = ?s) AND status IN(?a)', $user['email'], array('C')) ? true : false;
return $params;
}

we added it to the func.php of the my_changes addon, cleared cache but still are not able to access it in the template with $user_data.user_completed_order == true;

any help is appreciated.

We wanted to show an img / icon on the users.profile page if they have ordered.

i found another thread where someone used

function fn_my_changes_get_users($params, $fields, $sortings, $condition, $join)
{
$user['user_completed_order'] = db_get_field('SELECT COUNT(*) FROM ?:orders WHERE (email = ?s) AND status IN(?a)', $user['email'], array('C')) ? true : false;
return $params;
}

we added it to the func.php of the my_changes addon, cleared cache but still are not able to access it in the template with $user_data.user_completed_order == true;

any help is appreciated.

Please try this:

function fn_my_changes_get_user_info($user_id, $get_profile, $profile_id, &$user_data)
{
    $user_data['user_completed_order'] = db_get_field('SELECT COUNT(*) FROM ?:orders WHERE (email = ?s) AND status IN(?a)', $user['email'], array('C')) ? true : false;
}

Don't forget to register the 'get_user_info' hook in my_changes/init.php.

Thank you.

Have managed to get it working, i had mis-spelled the hook name in the init.php. :faceplant: