X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   How to restrict a category by login only (https://forum.x-cart.com/showthread.php?t=72494)

xtech 07-27-2015 04:13 AM

How to restrict a category by login only
 
Hello,
I want to restrict a category which will display after registrations and logged in.How to achieve that?

The flow will be in this way
1)The customer comes in the site
2)when he is trying to access that category he will ask for registrations
3)After registrations happens he will be logged in
4)after login he can able to see that category

How to achieve that?

Thanks.

totaltec 07-27-2015 05:18 AM

Re: How to restrict a category by login only
 
This is just psuedo code, you should find and test for the actual variables to use:
Code:

{if $cat.categoryid eq 12}
  {*special behavior goes here*}
  {if $logged ne ''}
    {*Show category*}
  {else}
    {*Show message to log in with link*}
  {/if}
{else}
  {*Normal category behavior goes here*}
{/if}


xtech 07-27-2015 07:50 AM

Re: How to restrict a category by login only
 
Quote:

Originally Posted by totaltec
This is just psuedo code, you should find and test for the actual variables to use:
Code:

{if $cat.categoryid eq 12}
  {*special behavior goes here*}
  {if $logged ne ''}
    {*Show category*}
  {else}
    {*Show message to log in with link*}
  {/if}
{else}
  {*Normal category behavior goes here*}
{/if}


Thank you totalec for your quick response. Will it ask for registration and after login will it land on that category page to view?can you please provide me detail code to achieve the goal? Thanks a lot.

totaltec 07-27-2015 10:52 AM

Re: How to restrict a category by login only
 
Xtech,
What you are asking can be custom coded of course. I have provided you with an example of how to achieve what you want, it is up to you and your development team to implement it properly.

If you want to hire my team we will build this solution for you. Should only take a few hours to implement it properly.

Jon 07-27-2015 11:19 AM

Re: How to restrict a category by login only
 
It's increasingly complicated due to the way x-cart handles registrations and logins. You have to pass variables through the login and registration process to identify the success redirect as well.

xtech 07-27-2015 11:15 PM

Re: How to restrict a category by login only
 
Quote:

Originally Posted by totaltec
This is just psuedo code, you should find and test for the actual variables to use:
Code:

{if $cat.categoryid eq 12}
  {*special behavior goes here*}
  {if $logged ne ''}
    {*Show category*}
  {else}
    {*Show message to log in with link*}
  {/if}
{else}
  {*Normal category behavior goes here*}
{/if}



Working like a charm.But one issue after login and register how to redirect to that current category page not on home page or cart page?

How to achieve this?
Thanks.

totaltec 07-28-2015 04:16 AM

Re: How to restrict a category by login only
 
Look in include/login.php I would pass a variable in the URL, from your login link. Like login.php?cat_return=1.

Then test for this in the PHP file, and if found assign a variable to smarty.

Then include a hidden input field in the login form, and populate it with 0 or 1 depending on whether this return value is set.

Then on form submission and successful login, assign the $redirect_url to your special origin point if that hidden input field is populated.


All times are GMT -8. The time now is 02:59 PM.

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