Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I know a visitor is signed in?


MrPhil

Recommended Posts

I want to integrate my osC shopping cart into the rest of my hand-coded site (PHP). What I'd like is to have a reminder on non-osC pages (elsewhere on my site) that a visitor is still signed into the store, so I can put up a button reminding them (and one click back to the store). If they are not signed in (they signed out, or haven't visited the store pages yet), I could put up a grayed-out, inactive button. What's the best way to do this? A quick search didn't show anything promising, but I'd like to avoid re-inventing the wheel. Ideally, outside of the osC pages, I could detect three states and put up the appropriate graphic or link:

 

* non-empty shopping cart (that I don't want them to abandon): "filled" cart button back to store

 

* empty shopping cart (but are logged in to store): "empty" shopping cart button back to store

 

* nothing in cart and not logged in: "grayed out" empty shopping cart as an inactive link, or maybe "empty" cart button to store (I haven't decided which)

 

If you could tell me where to find the appropriate information (or suggest a mod that I could cannibalize), I can take it from there. I don't know what osC information will be available if they don't have a session of some kind (and how do I relate a visitor on a random page to any existing osC session?). Thanks for any suggestions!

Link to comment
Share on other sites

is osC in a subdirectory of from these pages or are they mixed together?

 

just including application_top.php works for me. so just try this on a static page:

 

 chdir('catalog_directory');
require('includes/application_top.php');
print_r($cart);

 

you need the chdir() if the store is in a subdirectory so that application_top.php can find all the files it includes - database, functions, classes.

 

if all goes well the print_r() should output something like

shoppingCart Object ( [contents] => Array ( ) [total] => 0 [weight] => 0 [content_type] => )

 

meaning you now have access to the cart and pretty much everything else.

 

so you can do stuff like

 if ($cart->count_contents() > 0){
  print "You got stuff in your cart!";
}

and

 if (tep_session_is_registered('customer_id')) {
 print "Logged in";
} else {
 print "Not logged in";
}

Link to comment
Share on other sites

is osC in a subdirectory of from these pages or are they mixed together?

 

/home/ACCOUNT/public_html/ top level stuff, site Home Page

/home/ACCOUNT/public_html/home/ my "hand coded" site, need osC status here

/home/ACCOUNT/public_html/store/ osCommerce 2.2 RC2a installation

/home/ACCOUNT/public_html/forums/ discussion boards, need osC status here

 

I guess you'd call that "mixed together"?

 

I will play with including application_top.php on all pages (I have a standard header) and trying out your suggested code. It doesn't look half bad from here... I'll let you know how it turns out. Thanks!

Link to comment
Share on other sites

MrPhil,

Their is a contribution called visitors web stats that may give you what you want...or you can mod it to give you what you want...

Do a scan in the contri section for visitors and you will find it listed...

I hope this helps

dittones

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...