Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need help in script


Guest

Recommended Posts

Hello all

 

How can I add script which allows only registered users to view products, and guests should only see headlines

 

 

thanks

Link to comment
Share on other sites

This may give you some ideas for index.php (You would have to do similar for products_info.php)

 

This is untested so if you play about with this ensure you have backed up any files you change.

 

 

Find ...

 

<?php
 if ($category_depth == 'nested') {

Change to ...

 

<?php
$show_products = ( (tep_session_is_registered('customer_id')) ? true : false );
if ($show_products) {
 if ($category_depth == 'nested') {

 

 

Find ...

 

<?php
 }
?>
<!-- body_text_eof //-->

 

Change to ...

 

 

<?php
 }
 } elseif ($show_products == false) {
//echo $show_headlines;  // Whatever your variable is for showing headlines
// show_headlines();
// Or whatever you use to show headlines :)
 }
?>
<!-- body_text_eof //-->

 

Hope that helps

Link to comment
Share on other sites

Thank you babygurgles

 

 

I modified index.php but do not understand how to modify product_info.php I could not find that scripts in product_info.php

 

 

Also when I uploaded index.php the body dissapeared, newsdesk and products box dissapeared and where I logged in they appeared again. This is what I needed but can I do more accurately, meaning when guest is on home page it should see newsdesk and new products box but when he clicks some specific news the site must give him a notice that he cannot review until he is registered.

 

 

I am not good at php and hope you understand what I need (if you know there is something in contributions please direct me to appropriate link)

 

thank you very much

Link to comment
Share on other sites

Also when I uploaded index.php the body dissapeared, newsdesk and products box dissapeared and where I logged in they appeared again.

 

That is because you have set no headlines to show. In my example the methods to show the headlines are comented (//) out

 

i.e.

 

	//echo $show_headlines;  // Whatever your variable is for showing headlines
// show_headlines();
// Or whatever you use to show headlines :)

 

 

If you change that bit to ..

 

   $headlines = 'The user is not logged in so I am now showing headlines<br />';
echo $show_headlines;

 

You will see that a guest sees the above text.

Link to comment
Share on other sites

I did it but no notice appears :(

 

 

I need unregistered users to see home page as it is for registered users, but when guests click on some specific news or product there must be a notice

 

please register!

 

thank you

 

Also what about pdocut_info.php

 

I could not modify it

Link to comment
Share on other sites

I did it but no notice appears :(

I need unregistered users to see home page as it is for registered users, but when guests click on some specific news or product there must be a notice

 

please register!

 

thank you

 

 

Ooops my bad

$headlines = 'The user is not logged in so I am now showing headlines<br />';
echo $show_headlines;

 

Should be ..

 

		$show_headlines = 'The user is not logged in so I am now showing headlines<br />';
	echo $show_headlines;

Link to comment
Share on other sites

Thank you it really worked out,

 

And what about product_info.php you have advised to modify it too

 

What should I do for this file

 

thanks

Link to comment
Share on other sites

Firstly another little change to show the "please register"

 

		$show_headlines = echo '
	Please <a href = "' . tep_href_link(FILENAME_LOGIN) . '">register or log in</a> to view our products<p />
	The user is not logged in so I am now showing headlines<br />';
	echo $show_headlines;

 

Regarding the product_info.php, you'll have to have a go yourself or I'll have a quick bash when I come back later.

Link to comment
Share on other sites

Firstly another little change to show the "please register"

 

		$show_headlines = echo '
	Please <a href = "' . tep_href_link(FILENAME_LOGIN) . '">register or log in</a> to view our products<p />
	The user is not logged in so I am now showing headlines<br />';
	echo $show_headlines;

 

Regarding the product_info.php, you'll have to have a go yourself or I'll have a quick bash when I come back later.

 

 

thank you very much it worked, I placed <img> tag which is centered and asks guest to submit registration

 

and what about product_info.php

 

I think newsdesk_info.php must be modified no?

 

and one question if you do not mind

 

Can I make like that, when guest goes to homepage everything appears like it is for registered user, but when guest tries to click on product there is notice "Please register"

 

this script what you gave me really helped me to keep unregistered users from viewing my products, but a little more correction will be good if I can let unregistered users see product names but not content.

 

thank you very much, I will be back in 1-2 hours

 

you are very helpful person on this forum

 

thanks

Link to comment
Share on other sites

you could try the following ...

 

In /includes/application_top.php

 

find ...

 

$navigation->add_current_page();

 

Add below it ..

 

// FWRMedia mod to redirect to login when cPath is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
( ($logged_in == false && isset($_GET['cPath'])) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod

 

Try that.

Link to comment
Share on other sites

you could try the following ...

 

In /includes/application_top.php

 

find ...

 

$navigation->add_current_page();

 

Add below it ..

 

// FWRMedia mod to redirect to login when cPath is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
( ($logged_in == false && isset($_GET['cPath'])) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod

 

Try that.

 

Hello kind user

 

It really worked out for categories, when I click link in categories there is what I need (login box appears)

 

but it did not work for home page, I mean when guest enters the site there is headline (what we made yesterday),

 

I removed the script of headline from index.php and the guests see products on first page but when it clicks on it nothing happens he can view as registered users

 

we need to make so that when guest enters the site he must see as it is, but when he attempts to click on some specific product then there should be login box asking to log in or register (it really worked out for categories box)

 

thanks

 

see attached image to be clarified

 

logal6.th.jpg

Link to comment
Share on other sites

kind user

 

please be back :(

just one problem, I cannot sell anyting withought fixing this problem :(

 

 

I have helped where I can but I'm not going to do it all for you. I'm currently working for paying clients.

 

Good luck

Link to comment
Share on other sites

Hello kind user

 

It really worked out for categories, when I click link in categories there is what I need (login box appears)

 

but it did not work for home page, I mean when guest enters the site there is headline (what we made yesterday),

 

I removed the script of headline from index.php and the guests see products on first page but when it clicks on it nothing happens he can view as registered users

 

we need to make so that when guest enters the site he must see as it is, but when he attempts to click on some specific product then there should be login box asking to log in or register (it really worked out for categories box)

 

thanks

 

If it really worked for categories, DUPLICATE your actions for everything you want the unregistered user blocked from.

Link to comment
Share on other sites

I have helped where I can but I'm not going to do it all for you. I'm currently working for paying clients.

 

Good luck

That is the problem, they demand everything to be gratis instead of trying things out for themselves.

Link to comment
Share on other sites

That is the problem, they demand everything to be gratis instead of trying things out for themselves.

 

Aint that the truth, Leslie! :rolleyes:

Link to comment
Share on other sites

Someone give me a hint?

 

what file to edit like I did for application_top.php?

 

thanks

 

I tried to paste that script in newsdesk.php, but I got error :D

Link to comment
Share on other sites

This should do it fxtrader777

 

In /includes/application_top.php

 

find ...

 

 

$navigation->add_current_page();

 

 

Add below it ..

 

 

// FWRMedia mod to redirect to login when $_GET['cPath'] or $_GET['newsdesk_id'] is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
$redirect = ( (isset($_GET['cPath']) || isset($_GET['newsdesk_id'])) ? true : false );
( ($logged_in == false && $redirect == true) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod

Link to comment
Share on other sites

This should do it fxtrader777

 

In /includes/application_top.php

 

find ...

$navigation->add_current_page();

Add below it ..

// FWRMedia mod to redirect to login when $_GET['cPath'] or $_GET['newsdesk_id'] is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
$redirect = ( (isset($_GET['cPath']) || isset($_GET['newsdesk_id'])) ? true : false );
( ($logged_in == false && $redirect == true) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod

 

 

Thank you for being so kind

 

Your script really worked out great!

 

;)

Link to comment
Share on other sites

I am very ashamed to ask again a question

 

but if you do not mind I ask one

 

 

Everything worked great

 

but category's box behaves strange,

 

If unregister or register (result is the same for both) user clicks on any link in category box the result is the same: login box appears.

 

I restored default files (application_top.php) but it did not change.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...