Zen Cart Logo

members only area

Locked

Views: 9,153

Results 1 to 20 of 34
This thread is locked. New replies are disabled.
12 Jan 2009, 10:39 AM
#1
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

members only area

HELP!!

We would like to create a members only area as a category on our website.

Using admin tools we intend to remove the option for a new customer accounts to choose newsletter subscription, and use this field as a flag for membership.

There would be a product created on the site whereby the customer can purchase membership, and we would then manually set the newsletter subscription for the relevant account field to YES.

As a members category there would then be a simple HTML subsite for the members.

To view this area a check would be necessary:
If the customer is signed in and the newletter flag is YES then the members site is displayed.
If the customer is not signed in or the customer is signed in and the newsletter flag is NO, then another page is displayed telling the customer to either sign in and/or purchase membership

If anyone can think of a better method please advise.

Can anyone please help with the php coding of the category page to achieve the above functionality?

thanks

Derek

12 Jan 2009, 11:04 AM
#2
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: members only area

Get in touch with Scott Wilson (swguy).

He helped me with a similar challenge and developed a very nice solution to it...

12 Jan 2009, 12:09 PM
#3
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

thanks fairestcape

can I contact him through the forum?

Derek

12 Jan 2009, 12:15 PM
#4
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: members only area

Yes... his forum name is swguy, so find his profile and send him a Private Message (PM)

12 Jan 2009, 2:04 PM
#5
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Swguy makes a charge for this type of mod.

I was hoping someone could point me in the right direction for constructing an IF statement to check:

  1. If a customer has logged on to their account
  2. Whether the newsletter subscibe field is set to YES or NO

I may be able to code the rest myself

thanks

Derek

13 Jan 2009, 12:38 PM
#6
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: members only area

Derek Bryant:

Swguy makes a charge for this type of mod.

... but I believe Scott's prices are very reasonable for the skill he has and the time he puts in.

The code he wrote for me was quite complex, and required a very good knowledge of Zencart's code structures.

At the end of the day... spend 200 (frustrating) hours on it yourself, or hire a professional...

13 Jan 2009, 8:18 PM
#7
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

I am sure SWGUY does an excellent job and is good value for money.

But I was hoping that a simple IF statement on the main page would do the job, as per previous post:

"***I was hoping someone could point me in the right direction for constructing an IF statement to check:

  1. If a customer has logged on to their account
  2. Whether the newsletter subscibe field is set to 1 or 0"***

It seems that category descriptions are stored as text pages and therefore PHP commands will not work.

The Define pages - main page - is a .php file so a link to the members secion could be placed here with the above checks.

I am still trying to find a flag or whatever to 1. above.
Using PHP and given the account reference the condition 2. looks straightforward.

Again, any help, much appreciated

Derek

14 Jan 2009, 10:50 AM
#8
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: members only area

I don't think it's that simple, unfortunately.

To create a member's area, your shop needs to know (and store in the database) not only the details of who those "members" are, how they are given/denied member status, and what features membership is linked to, but when those members are visiting your shop, how the additional resources made available exclusively to them and not to others, are configured, priced, displayed and featured.

If they enjoy benefits such as member products, and/or member prices, then a fair amount of coding is necessary to manage all the processes that govern their exclusive access to such features.

14 Jan 2009, 5:13 PM
#9
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Hi fairestcape

Thanks for your interest and responses – if I may I’d like to expand on the project.

I am doing this job for my son who runs a fishing bait company.
He has been using the Zen Cart shopping cart very successfully for the last year or so.

He wants to create a members area on the site.
The members will have a (group) discount of 10% across all products.
They will also have access to a members area on the site where they will be sections for videos, articles etc.
He has accumulated over 200 customers already – most of which have signed up for the newsletter option.

My thought processes are as follows:
Use the newsletter field as a flag for members.
Make all existing customers who haven’t signed up for the newsletter, members by setting the newsletter option. Thus existing customers become members.
Remove the option when creating an account to sign up for the newsletter using Admin/Configuration/customer details.
Comment out the code where the customer can edit his newsletter option.
Set up a product on the site for purchasing yearly membership.
On purchase of the membership, manually alter the customer details to set the newsletter flag to indicate membership and allow the 10% group discount.
“Normal” customers will not have this newsletter flag set unless they purchase membership.
The membership area will be accessed by the main page which is accessed via Define Pages Editor/define_main_page.php
(I wanted to set up a members category, but as category files are stored as text files, I thought it would be easier to use php commands to communicate with the customer database)
On the define_main_page.php I need to check before allowing access to the members area:

  1. if someone has signed in to an account
  2. if the newsletter flag is set

And give messages to indicate what the customer must do to become a member.

If both of these conditions are true they gain access to the members area which will be a normal hyperlink to a sub-site.

At the moment I am struggling with the php commands for the main page.

I am testing on the main page this coding (with a customer signed in):

**<?php
$querynewsletter = "SELECT customers_newsletter FROM customers";
$resultnewsletter = mysql_query($query)
or die ("couldn't execute query");

echo "<br> customers_newsletter {$resultnewsletter}<br>";
?>**
With this output:

customers_newsletter Resource id #220

I was hoping for “1” !!!

Am also looking at !$_SESSION['customer_id'] along with PHP/MYSQL manuals

I hope all this makes sense!!

Again, any help would be appreciated

Derek

14 Jan 2009, 5:41 PM
#10
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town &amp; London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: members only area

Hi Derek

OK, I see what you are trying to achieve now.

I don't have the level of PHP knowledge to suggest how you tweak the code for your needs (that's why I hired Scott), but the site he helped with is at:

www . commotionstore . co . uk

It's been about 2 years since I was involved in this project, and I handed it over to a very skilled PHP operator, so he has probably improved the CLUB feature.

But take a look there and see if it's kind of what you're looking for.

Perhaps you can contact Scott again, and if he's OK with it, I would be quite happy for you to get the code he developed for us, and you could play around with it to see if it works.

Naturally, this is ENTIRELY at Scott's discretion, and he may elect not to give it to you, or perhaps to charge you a fee for the time and administration this may require. That's up to you and him to negotiate. All I'm saying here is that I have no problem with him releasing the code to you.

15 Jan 2009, 3:29 PM
#12
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Thanks misty - I think all customers have to be members with this mod. I require customers categorised into members and non-members.

thanks fairestcape once again for the offer of releasing some of Scott's work should he be in agreement. I may pursue this route, but I have made some progress with the php coding.

This the code:

<?php $custID = $_SESSION['customer_id']; if ($custID > 0) { $host="localhost"; $user="username"; $password="password"; $database="database name"; $connection = mysql_connect($host, $user, $password) or die ("Could not connect"); $db = mysql_select_db($database, $connection) or die ("Could not connect"); $query = "SELECT customers_firstname, customers_lastname, customers_id, customers_newsletter from customers WHERE customers_id=$custID"; $result = mysql_query($query) or die ("couldn't execute query"); $row = mysql_fetch_array($result,MYSQL_BOTH); $newlettercode = $row[3]; if ($newlettercode == 0) {echo "non member - please purchase membership subscription above";} else {echo "link to members section";} } else { echo "<br>Please log in if you are a member<br> ";} ?>

If it of use to anyone - please copy

Basically it checks the sesion variable $_SESSION['customer_id']; which is null if no-one is signed in - or contains the customer_id if signed in.
The program also checks the newsletter field for that customer and if set to 1 allows entry to the members area, if set to 0 suggests buying a members subscription and disallows access.

I've checked it out a few times with my dummy database and it seems to work ok.

I have used this on the Define Pages Editor/define_main_page.php
file - I now need to look at combining the graphics with the code

thanks again

Derek

15 Jan 2009, 4:13 PM
#13
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: members only area

Tried your code, added to define_main page...works but on logging in as member,
see message but all products disappear from main
page??

15 Jan 2009, 4:35 PM
#14
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Hi Misty

Do you mean the new products banners? Mine does the same

Is this a normal funcion of Zen Cart when you log-in?

I'm trying to find a way of checking it out

I haven't altered any zen code - only added the code on the define_main_page

Derek

15 Jan 2009, 4:37 PM
#15
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: members only area

Yes, removes centre boxes for new,featured,special products
and no, normally this is not supposed to happen..

15 Jan 2009, 4:46 PM
#16
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

thanks

I've really used the main_page to check out the php coding for the members only area. Don't know why it has this effect, but the actual code will be attached as a behaviour to some sort of membership area button, so hopefully, it shouldn't effect things.

Thanks for pointing it out.

Derek

15 Jan 2009, 5:53 PM
#17
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

I think I've cracked it!

If you comment out the lines :

$connection = mysql_connect($host, $user, $password)
or die ("Could not connect");
$db = mysql_select_db($database, $connection)
or die ("Could not connect");

everything seems ok - the database/user connection is probably set up in an .ini file

Derek

15 Jan 2009, 6:00 PM
#18
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: members only area

:clap:
Yes that fixed problem with disappearing centre boxes..am assuming
that you will be placing link in code to replace text
link to members section

15 Jan 2009, 8:03 PM
#19
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

The plan is to have a members section entry button on the front page. This code will be activated upon "depression" of this button.

I really wanted to check out the functionality of the code with Zen, before looking at the graphics and implementation.

Derek

:cool:

19 Feb 2009, 8:33 PM
#20
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

If anyone is interested in this thread, I have made some more progress.
The site in question is https://www.baitworks.co.uk
I had to write some php code to set all customers_newsletter fields = 0 in the database.
Other php code appears at the top of the membership define pages to check membership validity, i.e. whether this field has been (manually) set to 1 on receipt of membership subscription.
Most probably going to use the date of birth field to show membership end.
Hope this is clear - please contact me for and help/clarification