Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

customer_id and sessions


nockemout

Recommended Posts

Posted

I would like to pull ie the customer's first name once they are logged in. The code I have @ top of my account.php page is:

 

 

include 'includes/application_top.php';
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 } else {  
 $customer_id = (int)$_SESSION['customer_id'];
 echo $customer_id;  
 }

 

the echo customer_id; is to let me know the customer_id variable is stored. I am thinking to call the user's first name by customer_id but this is not a good way to do it because when i come from checkout it will show the $customer_id but after clicking around the user area pages the value goes back to 0, rendering anything based off that value useless. Any ideas?

 

 

Update: Ive tried using a modified version of tep_customer_greeting() and so far it's working will update.

Posted

maybe i have not included enough information..

 

 

 

 

I'm doing a highly customized checkout process with 2 products. using 2.2 rc2a, with the one page checkout and STS addons installed only. I have the checkout process as follows:

 

product page > shopping cart > checkout.php > checkout_sucess.php > step1.php > step2.php > step3.php > account.php

 

I have inserted new fields in my db by hand, which are filled in by step1-3.php and finally landing in the user account area.

 

pages step1, 2, 3 and account .php contain this code @ top:

 

include 'includes/application_top.php';
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 } else {  
 $customer_id = (int)$_POST['customer_id'];
}

 

SQL queries are handled like so:

$customers_petName = tep_db_prepare_input( $_POST['customers_petName'] );
$customers_petPhoto = tep_db_prepare_input( $_POST['customers_petPhoto'] );

$sql_data_array = array( 'customers_petName' => tep_db_input( $customers_petName ),
       'customers_petPhoto' => tep_db_input( $customers_petPhoto ));           
tep_db_perform( 'customers', $sql_data_array, 'update', 'customers_id = \'' . $customer_id . '\'' );

 

I'm using tep_ functions to draw out form fields:

echo tep_draw_form('form1', tep_href_link(FILENAME_STEP2), 'post');
echo tep_draw_input_field('customers_petName');

 

and hidden fields to pass the customer_id to make sure the data gets to the right place:

echo tep_draw_input_field(customer_id, $customer_id, null, 'hidden');
echo tep_image_submit('nextStep.png', 'Next Step');

 

I understand this method may not be the best way to go about it (passing customer_id post var). I'd rather do it the right way, by verifying the user session/ID and then moving forward with my sql query. I don't get how to do that. I'm hoping someone can break it down to me (inexperienced in php and osCommerce) so I can understand how to accomplish this.

in includes/functions/general.php, I see this:
 if (tep_session_is_registered('customers_petName') && tep_session_is_registered('customer_id')) {
   } 

 

It looks to be the start of a solution. Would I just stick my SQL queries within the brackets ? Your assistance is greatly appreciated.

Archived

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

×
×
  • Create New...