Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Urgent code help needed


kenny44

Recommended Posts

Hi Guys - I need some help really quickly to meet a deadline.

 

I have installed the "Control Login" contribution. That all works fine. What I need to happen is when the admin clicks on the green light beside the users account to activate it, the user gets sent an email letting them know its been activated.

 

I have in admin/includes/functions/general.php :

 

// Customers Status - fixed version
 function tep_set_customers_status($customers_id, $customers_status) { 
   if ($customers_status == '1') {

tep_mail('', ***HELP*** , 'Account Activated', 'Your account has been activated', STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');

     return tep_db_query("update " . TABLE_CUSTOMERS . " set customers_status = '1' WHERE customers_id = '" . $customers_id . "'"); 

   } elseif ($customers_status == '0') { 
     return tep_db_query("update " . TABLE_CUSTOMERS . " set customers_status = '0' WHERE customers_id = '" . $customers_id . "'"); 
   } else { 
     return -1; 
   } 
 }

 

Obviously, where I have ***HELP*** - is where i'm stuck. The customers email address needs to go in there, but im not sure how to retrieve it.

 

Any help greatly appreciated.

 

Cheers,

Ken

Link to comment
Share on other sites

This is one of two things you could do.

 

1. Create a new function in admin/includes/functions/general.php file that will return a customers email address based on customer_id

 

function tep_customers_email($customers_id) {
 $customers = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
 $customers_values = tep_db_fetch_array($customers);
   
 return $customers_values['customers_email_address'];
 }

 

2. Just use the sql query above in your function

 

 

So your function could resemble

function tep_set_customers_status($customers_id, $customers_status) {
  if ($customers_status == '1') {

tep_mail(tep_customers_name($customers_id), tep_customers_email($customers_id), 'Account Activated', 'Your account has been activated', STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');

    return tep_db_query("update " . TABLE_CUSTOMERS . " set customers_status = '1' WHERE customers_id = '" . $customers_id . "'");

  } elseif ($customers_status == '0') {
    return tep_db_query("update " . TABLE_CUSTOMERS . " set customers_status = '0' WHERE customers_id = '" . $customers_id . "'");
  } else {
    return -1;
  }
}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...