Forums / General Questions / using a forum with zen cart?

using a forum with zen cart?

Locked

Views: 3,768

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
27 Jun 2006, 4:10 AM
#1
magicfun avatar

magicfun

New Zenner

Join Date:
Mar 2006
Posts:
44
Plugin Contributions:
0

using a forum with zen cart?

I am looking for some information on how the phpBB forum stuff works with the zen-cart. I can't find any documentation on it.

Does it allow members of a phpBB forum that already exsist, login to the zen-cart without having to register again? What are the specific features that the forum linking does??

I know you can create a user to go with the forum when you checkout, but can it grab users that already exist in the forum to use to login to the zen cart as well?

If anyone has any documentation on this or what exactly happens, that would be great. You could direct me. Thanks!

7 Jul 2006, 6:51 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: using a forum with zen cart?

magicfun:

I know you can create a user to go with the forum when you checkout, but can it grab users that already exist in the forum to use to login to the zen cart as well?
No, it doesn't have any linkage to retrieve existing users.

It CAN:

  • allow new signups to choose a nickname
  • keep passwords in sync when pwd is changed from Zen Cart
  • keep email address in sync when email address is changed from Zen Cart

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Jul 2006, 5:23 PM
#3
peterbkk avatar

peterbkk

Zen Follower

Join Date:
Jun 2006
Posts:
178
Plugin Contributions:
0

Re: using a forum with zen cart?

Ok, but how to do that? I have the shop already and have now installed phpBB2. How can i make so only my registered customer can use the forum???

21 Feb 2007, 10:14 PM
#4
magicfun avatar

magicfun

New Zenner

Join Date:
Mar 2006
Posts:
44
Plugin Contributions:
0

Re: using a forum with zen cart?

I am wondering how to do this as well...I want so if my customers buy something from the store, it automatically lets them use the username and pass they created for the store, to let them login to the forum as well. This goes vice versa as well. Somehow the zen-cart needs to be connected and share users with the phpbb.

Anyone know how to do this?

21 Mar 2007, 4:13 PM
#5
billy_bob avatar

billy_bob

New Zenner

Join Date:
Feb 2007
Posts:
14
Plugin Contributions:
0

Re: using a forum with zen cart?

:bored: Same here.....

On installation of zen it asked if I had a forum... well I didnt!

I have now installed one and then went to Config>mystore>enable phpbb.... true

ok.....

Then I went and created an account on zen and its not showing on the phpbb.

Also.... no where one the zen cart can I see a link to the phpbb or in admin a way to create a link to it..

I'm perplexed and cant find the solution by searching in here :schmoll:

Using zencart 1.3.7
Image Litebox

25 Apr 2007, 4:54 PM
#6
dmcalister avatar

dmcalister

New Zenner

Join Date:
Apr 2007
Posts:
11
Plugin Contributions:
0

Re: using a forum with zen cart?

I have done this with osCommerce and will probably be modifying the login module of Zen Cart to do the same thing. If anyone has any ideas, suggestions, or experience with this please let me know. Also, if anyone knows just how different the login modules are from osCommerce, that would be great as well...

25 Apr 2007, 6:42 PM
#7
dmcalister avatar

dmcalister

New Zenner

Join Date:
Apr 2007
Posts:
11
Plugin Contributions:
0

Re: using a forum with zen cart?

Here's my first-blush look at the code and approach:

Here is the file in zen cart that makes the magic happen:

...\includes\modules\pages\header_php.php

The specific code snippet is:

if (isset($_GET['action']) && ($_GET['action'] == 'process')) {
  $email_address = zen_db_prepare_input($_POST['email_address']);
  $password = zen_db_prepare_input($_POST['password']);

  /* Privacy-policy-read does not need to be checked during "login"
  if (DISPLAY_PRIVACY_CONDITIONS == 'true') {
  if (!isset($_POST['privacy_conditions']) || ($_POST['privacy_conditions'] != '1')) {
  $error = true;
  $messageStack->add('create_account', ERROR_PRIVACY_STATEMENT_NOT_ACCEPTED, 'error');
  }
  }
  */


  // Check if email exists
  $check_customer_query = "SELECT customers_id, customers_firstname, customers_password,
                                    customers_email_address, customers_default_address_id,
                                    customers_authorization, customers_referral
                           FROM " . TABLE_CUSTOMERS . "
                           WHERE customers_email_address = :email";

  $check_customer_query  =$db->bindVars($check_customer_query, ':email', $email_address, 'string');
  $check_customer = $db->Execute($check_customer_query);

  if (!$check_customer->RecordCount()) {
    $error = true;
  } else {
    // Check that password is good
    if (!zen_validate_password($password, $check_customer->fields['customers_password'])) {
      $error = true;
    } else {
      if (SESSION_RECREATE == 'True') {
        zen_session_recreate();
      }

      $check_country_query = "SELECT entry_country_id, entry_zone_id
                              FROM " . TABLE_ADDRESS_BOOK . "
                              WHERE customers_id = :customersID
                              AND address_book_id = :adressBookID";

      $check_country_query = $db->bindVars($check_country_query, ':customersID', $check_customer->fields['customers_id'], 'integer');
      $check_country_query = $db->bindVars($check_country_query, ':adressBookID', $check_customer->fields['customers_default_address_id'], 'integer');
      $check_country = $db->Execute($check_country_query);

      $_SESSION['customer_id'] = $check_customer->fields['customers_id'];
      $_SESSION['customer_default_address_id'] = $check_customer->fields['customers_default_address_id'];
      $_SESSION['customers_authorization'] = $check_customer->fields['customers_authorization'];
      $_SESSION['customer_first_name'] = $check_customer->fields['customers_firstname'];
      $_SESSION['customer_country_id'] = $check_country->fields['entry_country_id'];
      $_SESSION['customer_zone_id'] = $check_country->fields['entry_zone_id'];

      $sql = "UPDATE " . TABLE_CUSTOMERS_INFO . "
              SET customers_info_date_of_last_logon = now(),
                  customers_info_number_of_logons = customers_info_number_of_logons+1
              WHERE customers_info_id = :customersID";

      $sql = $db->bindVars($sql, ':customersID',  $_SESSION['customer_id'], 'integer');
      $db->Execute($sql);
      $zco_notifier->notify('NOTIFY_LOGIN_SUCCESS');

      // restore cart contents
      $_SESSION['cart']->restore_contents();
      /*
      if ($_SESSION['cart']->count_contents() > 0) {
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING));
      }
      */
      if (sizeof($_SESSION['navigation']->snapshot) > 0) {
        //    $back = sizeof($_SESSION['navigation']->path)-2;
        //if (isset($_SESSION['navigation']->path[$back]['page'])) {
        //    if (sizeof($_SESSION['navigation']->path)-2 > 0) {
        $origin_href = zen_href_link($_SESSION['navigation']->snapshot['page'], zen_array_to_string($_SESSION['navigation']->snapshot['get'], array(zen_session_name())), $_SESSION['navigation']->snapshot['mode']);
        //            $origin_href = zen_back_link_only(true);
        $_SESSION['navigation']->clear_snapshot();
        zen_redirect($origin_href);
      } else {
        zen_redirect(zen_href_link(FILENAME_DEFAULT));
      }
    }
  }
}
```previously I made the following tweak to osCommerce in the login.php file:

// Check if email exists
$check_customer_query = tep_db_query("select user_id, user_password from phpbb_users where username = '" . $phpbb_username . "'");
if (!tep_db_num_rows($check_customer_query)) {
$error = true;
} else {
$phpbb_check_customer = tep_db_fetch_array($check_customer_query);

// Check that password is good
if (! md5($password) == $phpbb_check_customer['user_password']) {
$error = true;
} else {

Check to see if customer has logged in to osCommerce before

  $Qcheck = tep_db_query("select customers_info_number_of_logons from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $phpbb_check_customer['user_id'] . "'");

  if (tep_db_num_rows($Qcheck) > 0) {
    tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = now(), customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . (int)$phpbb_check_customer['user_id'] . "'");

update query needs to be written to freshen the osc_customer table each time a user logs in.

    $Qphpbb_users = tep_db_query("select user_firstname, user_lastname, user_email, user_address1, user_address2, user_city, user_state, user_zip, user_homephone, user_chronicleemail from phpbb_users where user_id = '" . $phpbb_check_customer['user_id'] . "'");
    $phpbb_users_array = tep_db_fetch_array($Qphpbb_users);

$Qdefault_address = tep_db_query("select customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $phpbb_check_customer['user_id'] . "'");
$default_address = tep_db_fetch_array($Qdefault_address);

    $sql_data_array = array('customers_firstname' => $phpbb_users_array['user_firstname'],
                            'customers_lastname' => $phpbb_users_array['user_lastname'],
                            'customers_email_address' => $phpbb_users_array['user_email'],
                            'customers_telephone' => $phpbb_users_array['user_homephone'],
                            'customers_newsletter' => $phpbb_users_array['user_chronicleemail'],
                            );
    tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id ='" . $phpbb_check_customer['user_id'] . "'");
    

$sql_data_array = array('entry_firstname' => $phpbb_users_array['user_firstname'],
                            'entry_lastname' => $phpbb_users_array['user_lastname'],
                            'entry_street_address' => $phpbb_users_array['user_address1'] . " " .  $phpbb_users_array['user_address2'],
                            'entry_postcode' => $phpbb_users_array['user_zip'],
                            'entry_city' => $phpbb_users_array['user_city'],
            'entry_state' => $phpbb_users_array['user_state'],
               );
    tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "address_book_id = '" . $default_address['customers_default_address_id'] . "' and customers_id ='" . $phpbb_check_customer['user_id'] . "'");
           
  } else {
    
    tep_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_date_of_last_logon, customers_info_number_of_logons, customers_info_date_account_created) values (" . $phpbb_check_customer['user_id'] . " , now(), 1, now())");

Query phpBB database to get info and populate osc_customers table.

    $Qphpbb_users = tep_db_query("select user_firstname, user_lastname, user_email, user_address1, user_address2, user_city, user_state, user_zip, user_homephone, user_chronicleemail from phpbb_users where user_id = '" . $phpbb_check_customer['user_id'] . "'");
    $phpbb_users_array = tep_db_fetch_array($Qphpbb_users);

    $sql_data_array = array('customers_id' => $phpbb_check_customer['user_id'],
                        'customers_firstname' => $phpbb_users_array['user_firstname'],
                            'customers_lastname' => $phpbb_users_array['user_lastname'],
                            'customers_email_address' => $phpbb_users_array['user_email'],
                            'customers_telephone' => $phpbb_users_array['user_homephone'],
                            'customers_newsletter' => $phpbb_users_array['user_chronicleemail'],
                            );
tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);

    $sql_data_array = array('customers_id' => $phpbb_check_customer['user_id'],
                            'entry_firstname' => $phpbb_users_array['user_firstname'],
                            'entry_lastname' => $phpbb_users_array['user_lastname'],
                            'entry_street_address' => $phpbb_users_array['user_address1'] . " " .  $phpbb_users_array['user_address2'],
                            'entry_postcode' => $phpbb_users_array['user_zip'],
                            'entry_city' => $phpbb_users_array['user_city'],
            'entry_state' => $phpbb_users_array['user_state'],
                            'entry_country_id' => STORE_COUNTRY,
               );
tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);

$address_id = tep_db_insert_id();

tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . $phpbb_check_customer['user_id'] . "'");    

    if (SESSION_RECREATE == 'True') {
      tep_session_recreate();
      }
    }

Now begin normal login and session stuff

$check_customer_query = tep_db_query("select customers_firstname, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $phpbb_check_customer['user_id'] . "'");
if (!tep_db_num_rows($check_customer_query)) {
  $error = true;
} else {
  $check_customer = tep_db_fetch_array($check_customer_query);
}   

$check_country_query = tep_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $phpbb_check_customer['user_id'] . "' and address_book_id = '" . (int)$check_customer['customers_default_address_id'] . "'");
    $check_country = tep_db_fetch_array($check_country_query);

    $customer_id = $phpbb_check_customer['user_id'];
    $customer_default_address_id = $check_customer['customers_default_address_id'];
    $customer_first_name = $check_customer['customers_firstname'];
    $customer_country_id = $check_country['entry_country_id'];
    $customer_zone_id = $check_country['entry_zone_id'];
    tep_session_register('customer_id');
    tep_session_register('customer_default_address_id');
    tep_session_register('customer_first_name');
    tep_session_register('customer_country_id');
    tep_session_register('customer_zone_id');
27 Apr 2007, 4:39 PM
#8
dmcalister avatar

dmcalister

New Zenner

Join Date:
Apr 2007
Posts:
11
Plugin Contributions:
0

Re: using a forum with zen cart?

bump

Hello?

5 Jun 2007, 4:36 PM
#9
dmcalister avatar

dmcalister

New Zenner

Join Date:
Apr 2007
Posts:
11
Plugin Contributions:
0

Re: using a forum with zen cart?

No interest then eh? Is there somewhere else I should look for help?

6 Jun 2007, 6:59 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: using a forum with zen cart?

If someone is logging in via a "Login" link (ie: URL contains main_page=login ) then the /includes/modules/pages/login/header_php.php file handles the login logic of validating the email address and password and logging the customer in.

If they are using "create_account" (ie: URL contains main_page=create_account or if they've filled in the new-account fields on the bottom half of the login page), then there is a handling stub in /includes/modules/pages/create_account/header_php.php and a processing module in /includes/modules/create_account.php

Your custom code appears to assume that a lot of customer data is collected in the phpbb database. My recollection is that phpbb only asks for username and password ... which really isn't adequate for the information required by the shopping cart system. However, if you've modified your phpbb setup to collect that information, then I suppose you've already considered that. Otherwise, you'll have to work a way to collect any missing information -- perhaps redirecting them to My Account if their data has just been transfered might be one approach?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Jun 2007, 7:32 PM
#11
dmcalister avatar

dmcalister

New Zenner

Join Date:
Apr 2007
Posts:
11
Plugin Contributions:
0

Re: using a forum with zen cart?

Dr. Byte,

I have phpBB managing all the user data that includes address, phone number, and various other things.

I had found the code I posted in the header.php file. I believe I have a good handle on the way that zen cart handles the user data now.

There are two additional things I need to do that will allow a user to change their information and that change will affect the phpBB user database and the newly populated zen cart database tables. I believe that change would take place in this file: /includes/templates/YOUR_TEMPLATE/templates/tpl_account_edit_default.php and the associated header_php.php file which I believe is:
/includes/modules/pages/account_edit/header_php.php

Finally, I would like to have people register using the phpBB database, so I need to replace the new-account fields on the bottom half of the login page with a link back to the phpBB registration page. I'm assuming that would be located here:
/includes/templates/YOUR_TEMPLATE/templates/tpl_login_default.php

Specifically, here:

<fieldset>
<legend><?php echo HEADING_RETURNING_CUSTOMER; ?></legend>

<label class="inputLabel" for="login-email-address"><?php echo ENTRY_EMAIL_ADDRESS; ?></label>
<?php echo zen_draw_input_field('email_address', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_email_address', '40') . ' id="login-email-address"'); ?>
<br class="clearBoth" />

<label class="inputLabel" for="login-password"><?php echo ENTRY_PASSWORD; ?></label>
<?php echo zen_draw_password_field('password', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_password') . ' id="login-password"'); ?>
<br class="clearBoth" />
</fieldset>

<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_LOGIN, BUTTON_LOGIN_ALT); ?></div>
<div class="buttonRow back important"><?php echo '<a href="' . zen_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL') . '">' . TEXT_PASSWORD_FORGOTTEN . '</a>'; ?></div>
</form>
<br class="clearBoth" />
```and 

<?php echo zen_draw_form('create_account', zen_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'), 'post', 'onsubmit="return check_form(create_account);"') . zen_draw_hidden_field('action', 'process') . zen_draw_hidden_field('email_pref_html', 'email_format'); ?> <fieldset> <legend><?php echo HEADING_NEW_CUSTOMER; ?></legend> <div class="information"><?php echo TEXT_NEW_CUSTOMER_INTRODUCTION; ?></div> <?php require($template->get_template_dir('tpl_modules_create_account.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_create_account.php'); ?> </fieldset> ```

Thoughts?

11 Jun 2007, 5:59 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: using a forum with zen cart?

Yes, those template-file snippets are where you could replace Zen Cart code with a link to your phpBB login page.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 May 2008, 7:56 PM
#13
icemint avatar

icemint

New Zenner

Join Date:
Jan 2008
Posts:
32
Plugin Contributions:
0

Re: using a forum with zen cart?

Dr. Byte,

Would it be possible to make phpBB also logged in when they sign in ZenCart?

22 May 2008, 10:14 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: using a forum with zen cart?

I haven't seen anyone do that yet, no.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

9 Jun 2008, 3:51 AM
#15
sunzhoujian avatar

sunzhoujian

Zen Follower

Join Date:
Jan 2008
Location:
China
Posts:
154
Plugin Contributions:
0

Re: using a forum with zen cart?

Dear Drbyte, You have posted so many here and you didn't see anyone do that! Can anyone fix this problem and post the solution here for everyone to share? A good linkage with smf or phpbb would make it hugely popular for people to use!