X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   If statement help - wholesale (https://forum.x-cart.com/showthread.php?t=30979)

abeight 05-06-2007 10:49 AM

If statement help - wholesale
 
I have certain design elements that I want to display only to wholesale members. What would this IF statement look like? v 4.0.19

Thank you!

Jon 05-06-2007 11:32 AM

Re: If statement help - wholesale
 
Try:

{if $userinfo.membershipid eq "X"}Show It{/if}

abeight 05-07-2007 05:05 PM

Re: If statement help - wholesale
 
Thanks, Jon! That worked. :)

abeight 05-08-2007 08:15 AM

Re: If statement help - wholesale
 
Actually upon further review, it looks like the elements are now being hidden from everyone, even the wholesale members.

{if $userinfo.membershipid eq "Wholesale"}

Jon 05-08-2007 08:40 AM

Re: If statement help - wholesale
 
When you add the wholesale membership, it is given a numeric id. You need to use that ID, instead of the word "Wholesale."

If you login as a wholesaler, and put this in your template, it should tell you the ID:

Code:

ID: {$userinfo.membershipid}

abeight 05-08-2007 08:45 AM

Re: If statement help - wholesale
 
Hi Jon,

I put that in home.tpl, but it doesn't output a number. Just "ID:"

I looked in the config table in the database and it looks like the numeric ID for Wholesale members is 9, but that didn't work either. *scratching head*

Jon 05-08-2007 08:49 AM

Re: If statement help - wholesale
 
What happens if you output {$userinfo}.

Does it say "Array" on the screen?

abeight 05-08-2007 08:52 AM

Re: If statement help - wholesale
 
Nothing - blank.

Jon 05-08-2007 09:01 AM

Re: If statement help - wholesale
 
Sorry, I customized the store I took the code from so much that it's hard to remember what's stock sometimes :)

Open auth.php and put this code before ?>

Code:

$userinfo = func_query_first("SELECT login,firstname,lastname,membershipid FROM $sql_tbl['customers'] WHERE login='$login'");
$smarty->assign("userinfo", $userinfo);



abeight 05-08-2007 09:05 AM

Re: If statement help - wholesale
 
That made the whole site blank. :)

Jon 05-08-2007 09:13 AM

Re: If statement help - wholesale
 
Sorry, like I said, probably too many customizations :(

Put this in your auth.php:

Code:

$userinfo = func_query_first("SELECT login,firstname,lastname,membership FROM $sql_tbl['customers'] WHERE login='$login'");
$smarty->assign("userinfo", $userinfo);



Then output to your template:

ID: {$userinfo.membership}

Let me know what is output.

abeight 05-08-2007 09:20 AM

Re: If statement help - wholesale
 
No problem, I really appreciate your help, Jon. :)

Unfortunately, that made the front-end of the site blank again.

Jon 05-08-2007 09:40 AM

Re: If statement help - wholesale
 
Are you able to provide FTP to the site? It would be easier to see the exact files and be able to debug without causing problems to the customers

abeight 05-08-2007 09:46 AM

Re: If statement help - wholesale
 
Absolutely, I'll send you a PM.

Jon 05-08-2007 10:09 AM

Re: If statement help - wholesale
 
Here's the code to us:

In auth.php before ?>

Code:

$userinfo = func_query_first("SELECT login,firstname,lastname,membership FROM $sql_tbl[customers] WHERE login='$login'");
$smarty->assign("userinfo", $userinfo);


Code in your templates:

Code:

{if $userinfo.membership eq "Wholesale"} Show Text{/if}

abeight 05-08-2007 10:23 AM

Re: If statement help - wholesale
 
Yay, it worked! :) Thank you so much, Jon!!!!

joshmoran12020 05-22-2007 12:33 PM

Re: If statement help - wholesale
 
Which template file has the homes main content information. I want a link to be displayed on the main home page as long as the user has a Premium membership

Jon 05-22-2007 12:47 PM

Re: If statement help - wholesale
 
skin1/customer/main/welcome.tpl

joshmoran12020 05-22-2007 01:00 PM

Re: If statement help - wholesale
 
I get an error when putting that code in my auth.php

Jon 05-22-2007 01:09 PM

Re: If statement help - wholesale
 
The code for 4.1.7 would be different, I believe:

Code for auth.php before ?>

Code:

$userinfo = func_query_first("SELECT login,firstname,lastname,membershipid FROM $sql_tbl[customers] WHERE login='$login'");
$smarty->assign("userinfo", $userinfo);


Code for use in template:

Code:

{* Where "X" is the numeric membershipid *}
{if $userinfo.membershipid eq "X"} Show Text{/if}


joshmoran12020 05-22-2007 01:45 PM

Re: If statement help - wholesale
 
Thank you Jon. You're the first person to give me a helpful answer (besides balinor). I really appreciate that.
Also just to verify for anyone else on 4.1.7... The above coding works entirely.

Thanks again Jon

TBone 10-21-2009 05:25 AM

Re: If statement help - wholesale
 
If you still want to use the name of the membership instead of the id use this code:

Code:

$userinfo = func_query_first("SELECT A.login,A.firstname,A.lastname,B.membership FROM $sql_tbl[customers] A, $sql_tbl[memberships] B WHERE A.login='$login' and A.membershipid = B.membershipid");
$smarty->assign("userinfo", $userinfo);


and this in your .tpl file:

Code:

{if $userinfo.membership eq "Gold Member"}


All times are GMT -8. The time now is 08:30 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.