I do such a test on order_invoice.tpl (for BCSE reward points - display points only for registered customers):
Code:
{if $order.login|strpos:'customer-'===0}
code for anon customers
{else}
code for registered customers
{/if}
NOTE: I call my anon customers, "customer", as set in config.php -- if you call them "anonymous", then change
strpos:'customer-'
to strpos:'anonymous-'
I also have a 4 digit order number (for now). Hopefully, it will exceed 4 digits some day, and I will have to adjust this code. That's about $11,000,000 of orders from now.
Hope this works for you.
Jeremy