Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Check If User Logged In Rate Topic   - - - - -

 
  • gabbo
  • Junior Member
  • Trial users
  • Join Date: 04-May 11
  • 92 posts

Posted 06 May 2014 - 05:10 AM #1

What syntax do I use in "layout editor" (block with smarty support) to check if user logged in?
<ul>
{if userlogedin?}
<li><a href="{"orders.search"|fn_url}">Orders</a></li>
{/if}
<li><a href="{"wishlist.view"|fn_url}">Wishlist</a></li>
<li><a href="{"product_features.compare"|fn_url}">Comparelist</a></li>
</ul>


 
  • cscartrocks
  • Member
  • Members
  • Join Date: 24-Jan 11
  • 1850 posts

Posted 06 May 2014 - 05:25 AM #2


{if $auth.user_id}


One Step Checkout Addon - The ultimate checkout experience
Best CS-Cart SEO addon - CS-Cart SEO Ultimate Addon
PM for 365-day support and custom development service


 
  • gabbo
  • Junior Member
  • Trial users
  • Join Date: 04-May 11
  • 92 posts

Posted 06 May 2014 - 03:08 PM #3

{if $auth.user_id}


Works great, thanx..

 
  • atlaswu
  • Member
  • Members
  • Join Date: 15-Jun 13
  • 30 posts

Posted 12 June 2014 - 02:28 AM #4

I add the code to a new block:

{if $auth.user_id}
<i class="f-icon-heart"></i><a href="{"wishlist.view"|fn_url}" rel="nofollow">{__("wishlist")}{if $wishlist_count > 0} ({$wishlist_count}){/if}</a>
{/if}

The wishlist link works, but it does not show the count of wishlist?

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12156 posts

Posted 12 June 2014 - 02:53 AM #5

What context are you in? Why do you expect $wishlist_count variable to be set? I don't think it's done globally for all pages.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • atlaswu
  • Member
  • Members
  • Join Date: 15-Jun 13
  • 30 posts

Posted 12 June 2014 - 06:18 AM #6

I want to make like this...
Attached File  螢幕快照 2014-06-12 下午2.14.57.png   28.9KB   38 downloads

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12156 posts

Posted 12 June 2014 - 06:35 PM #7

Then you'll have to set your $wishlist_count variable.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22944 posts

Posted 13 June 2014 - 07:36 AM #8

I want to make like this...
Attached File  螢幕快照 2014-06-12 下午2.14.57.png   28.9KB   38 downloads


Try
{$smarty.session.wishlist.products|count}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • atlaswu
  • Member
  • Members
  • Join Date: 15-Jun 13
  • 30 posts

Posted 13 June 2014 - 12:00 PM #9

Try

{$smarty.session.wishlist.products|count}

{if $auth.user_id}
<i class="f-icon-heart"></i><a href="{"wishlist.view"|fn_url}" rel="nofollow">{__("wishlist")}{if $smarty.session.wishlist.products|count > 0} ({$smarty.session.wishlist.products|count}){/if}</a>
{/if}
It's working!! I really appreciate your help.

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22944 posts

Posted 13 June 2014 - 12:45 PM #10

You are welcome!

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 105 posts

Posted 16 January 2015 - 11:37 AM #11

Is there a way to access the status that is held in
{$auth.user_id}
in a PHP script (obviously on same server!) rather than within Smarty Template?

I already use
{$auth.user_id}
{$user_info.firstname}
{$user_info.lastname}
{$user_info.email}
{$auth.usergroup_ids[2]}

to pull user data into a complex custom form loaded via iframe which is only accessible to logged in users.

What I must achieve to make my new version of this form work, is to be able to dynamically (via ajax) test for user logged in status to enable a 'Save' button.

So, unregistered user can view the form and play with it with disabled/hidden 'Save' button. Then, if they want to save/submit the data they have to login or register (via modal or pop-up window) then they will be able to submit/save the form...

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22944 posts

Posted 16 January 2015 - 02:17 PM #12

Try

$_SESSION['auth']['user_id']

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 105 posts

Posted 16 January 2015 - 04:18 PM #13

Thank you @eComLabs

I will do that!

:-)

 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 105 posts

Posted 16 January 2015 - 04:38 PM #14

Not working at first attempt - will persevere... and report back!

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12156 posts

Posted 16 January 2015 - 08:36 PM #15

correct test would be:
if( !empty($_SESSION['auth']['user_id']) )
Use of
{$auth.user_id}
should also work. But if not, using
{$smarty.session.auth.user_id}
would do the same and prevent the overhead of any ajax requests.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Wilko
  • Advanced Member
  • Members
  • Join Date: 14-Feb 13
  • 105 posts

Posted 19 January 2015 - 09:07 AM #16

@tbirnseth

Thank you for that - my reasoning for ajax call is that I do not want the visitor to have to reload the form i.e.

Visitor/User Plays With Form [not logged in/registered] > Visitor then wants to save/submit their input > Link to Log-in/Register [new tab/modal window] > Enable 'Save/Submit' Button > Bingo! [Without re-loading form].

I could of course just set a cookie to save the the form values temporarily for non logged in / registered visitor but I would prefer not to do it that way... there is also quite a lot of data / fields in the form...

:)