Private site / shop contribution for osCommerce (2.3.1)

Although there are many online shopping cart system available and many of them are open source, but you can not find any system that can support a private site. Why do we need private site? Well for wholesale and distribution companies, franchise businesses, many of them do not want the site to be accessible by the public, the shopping cart system only open to their registered customers or member businesses. Here I will show you how to turn osCommerce (V2.3.1) shopping cart system into a private one.

Step 1: Database change

Options add to osCommerce configuration table to provide the switch to turn on/off the private site options. You will need to log in to your site’s phpAdmin page to add there two lines into database

INSERT INTO `configuration`(`configuration_id`,`configuration_title`,`configuration_key`,`configuration_value`,
`configuration_description`,`configuration_group_id`,`sort_order`,`last_modified`,`date_added`,
`use_function`,`set_function`)
VALUES (272,’Must login to access the store’,’CUSTOMER_MUST_LOGIN’,’false’,
‘Whether or not customer must login in order to access the webstore’,1,26,NULL,
‘0000-00-00 00:00:00′,NULL,’tep_cfg_select_option(array(\’true\’, \’false\’), ‘);

INSERT INTO `configuration`(`configuration_id`,`configuration_title`,`configuration_key`,`configuration_value`,
`configuration_description`,`configuration_group_id`,`sort_order`,`last_modified`,`date_added`,
`use_function`,`set_function`)
VALUES (273,’Do not allow customer self-registration’,’NO_CUSTOMER_SELF_CREATION’,’false’,
‘Whether or not allow customers to register in the website by themselves’,1,27,NULL,
‘0000-00-00 00:00:00′,NULL,’tep_cfg_select_option(array(\’true\’, \’false\’),’);

After the modification, in osCommerce administration panel (configuration->My Store), you will be able to see following lines and you can them turn on/off for your needs:

Step 2: Modify file includes/application_top.php

Add following lines after line 300, this will force the customer to login first in order to use the site, if the “Must login to access the store” switch is turned on:
if (defined('CUSTOMER_MUST_LOGIN') &&
CUSTOMER_MUST_LOGIN=='true' &&
!tep_session_is_registered('customer_id') &&
(basename($PHP_SELF)!=FILENAME_LOGIN) &&
(basename($PHP_SELF)!=FILENAME_ABOUT_US) &&
(basename($PHP_SELF)!=FILENAME_CONTACT_US) &&
(basename($PHP_SELF)!=FILENAME_CONDITIONS) &&
(basename($PHP_SELF)!=FILENAME_PRIVACY) &&
(basename($PHP_SELF)!=FILENAME_CREATE_ACCOUNT) &&
(basename($PHP_SELF)!=FILENAME_CREATE_ACCOUNT_SUCCESS) &&
(basename($PHP_SELF)!=FILENAME_PASSWORD_FORGOTTEN) &&
(basename($PHP_SELF)!=FILENAME_LOGOFF) &&
(basename($PHP_SELF)!=FILENAME_PASSWORD_FORGOTTEN) &&
(basename($PHP_SELF)!=FILENAME_SHIPPING))
{
tep_redirect(tep_href_link(FILENAME_LOGIN));
}

Step 3: Remove the customer self-registration to completely make the site private

modify file login.php, add following lines after line 105:

 <?php
   }
 ?>

modify file login.php, add following lines after line 93:
if(!defined('NO_CUSTOMER_SELF_CREATION') || NO_CUSTOMER_SELF_CREATION !='true')
{

Step 4: After removing the customer self-registration, in the administration panel we need function to add new customer.

modify file admin/customers.php, add following lines after line 789:
if(defined('NO_CUSTOMER_SELF_CREATION') && NO_CUSTOMER_SELF_CREATION =='true')
{
echo tep_draw_button(TEXT_INFO_NEW_CUSTOMER, 'plusthick', tep_href_link(FILENAME_CUSTOMERS, 'cID=-1&action=edit'));
}

Step 5: Modify file admin/customers.php to allow adding new customer

Find line 224 to line 228, and change to following:

default:
if (((int)$HTTP_GET_VARS['cID'])'-1',
'customers_gender'=>'',
'customers_firstname'=>'',
'customers_lastname'=>'',
'customers_dob'=>'',
'customers_email_address'=>'',
'customers_pricelist_id'=>'',
'entry_company'=>'',
'entry_street_address'=>'',
'entry_suburb'=>'',
'entry_postcode'=>'',
'entry_city'=>'',
'entry_state'=>'',
'entry_zone_id'=>'',
'entry_country_id'=>'',
'customers_telephone'=>'',
'customers_fax'=>'',
'customers_newsletter'=>'',
'customers_password'=>'',
'customers_default_address_id'=>'');
} else {
$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, c.customers_pricelist_id, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
$customers = tep_db_fetch_array($customers_query);
}
$cInfo = new objectInfo($customers);

Now we have finished everything, the site can be switched into a private site. If you turned the switches on, the customer will have to login first in order to access the site.

If anyone need the source code, please contact me and I can send the modifications.

13 thoughts on “Private site / shop contribution for osCommerce (2.3.1)

  1. Thank you sir,

    This solves my problem to make our web store private. I will find my way in php and make the necessary adjustments , msql is different.
    I found,
    configuration
    add ( see kolom only )
    and got lost.

    I really have no idea how to add this, can you point my in the correct direction ?

    kind regards,
    wim

    • Hi win,
      Insert record into your MySql database normally done via the phpAdmin from your hosting provider’s administration control panel. You could contact the tech support from your hosting service provider and they should be able to give the direction

      Sean

  2. Reading helps ;)) Found how to add it, now need to solve this error

    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘login to access the store’,’CUSTOMER_MUST_LOGIN’,’false’, ‘Whether or no’ at line 4

  3. i keep getting a error, typed it in manually

    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘`set_function“use_function“date_added“last_modified“sort_order“configuratio’ at line 1

  4. Sorry new problem cant add new customers in the admin page get a message on the top of the page

    Warning: reset() [function.reset]: Passed variable is not an array or object in /home/aslee/public_html/shop1/admin/includes/classes/object_info.php on line 17

    Warning: Variable passed to each() is not an array or object in /home/aslee/public_html/shop1/admin/includes/classes/object_info.php on line 18

    last stage really need this working asap thanks

  5. Hi Sean,

    Not sure if you received my email (see my email address above) via the contact form. If not, please reply with your email here so I can send it to you :>

Leave a reply to wim Cancel reply