As I was working on a Miva Merchant store today, I needed to show the user a link, but only if they were currently logged in. I know I have done this before, but I couldn’t find the code for the life of me. So I went to trusty ol’ Google and typed in “Miva Merchant detect if user logged in” and several other terms only to come up with nothing. So I dug through several other Merchant sites to find the code. I finally found it and have decided to post it here in case somebody else has the same problem.
UPDATE: Apparently you need to check that g.Basket:CUST_ID is not equal to zero. At first my solution only checked that it wasn’t null which was flawed.
<mvt:if expr="NOT ISNULL g.Basket:CUST_ID AND g.Basket:CUST_ID NE 0"> Welcome back, &mvte:global:customer:login;! <mvt:else> Hello anonymous user! </mvt:if>
Zack Says:
June 18th, 2008 at 9:46 pm
I’ll have to use this.
Thomas Says:
August 8th, 2008 at 10:20 am
Dear Sir,
Thanks for posting this script just came in handy for me working on a feature to show a link like MY HISTORY on a Miva store. With this if conditional statement your able to dynamically check to see if the History link should appear if the users logged in and if they are not don’t show the link because It won’t work if your not logged in.
Thanks again for your efforts!
Thomas
http://www.ecentralstores.com
Thomas Says:
August 15th, 2008 at 10:54 am
Dear Luke,
Could this function also be used in a while loop?
For example say you have this while loop around you mini basket so when the user completes their order the basket doesn’t appear to have there order inside.
Currently, the basket doesn’t refresh after the order has been placed in Miva which I’m looking for away to have this basket page refreshed once the user recieves their invoice.
Do you know of away to handle this?
Thanks
Thomas
http://www.ecentralstores.com
Luke Visinoni Says:
August 28th, 2008 at 7:58 am
Thomas, I’m not sure what you’re asking. Can you use this technique inside of a while loop? The answer to that question is yes.
Ray Says:
March 11th, 2009 at 1:52 pm
This worked great for my needs in Miva 5.5 Even added some custom "a ref" links to only show for registered distributor customers when they are logged in easily access this custom order area. Great work and thanks for the post. Saved me bunches of headache and time!