Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

When a customer buys how do I update a new row in the database


koollayed

Recommended Posts

Posted

I have a question I know you guys can help.

 

I added a new rows (member_flag1) (member_flag2) to "customers" in my database because I want to restrict accesses to a page. By default when they create an account the row is 0.

 

What I want to do is when they buy a specific product change this row from 0 to blank. For example John buys a brush after he buys member_flag1 is changed to blank. He comes back and buys a hat after he buys member_flag2 is changed.

 

Can anyone help with this.

 

Thanks

Posted

It is along the lines of

 

If product_id = '12345' {

Update customer set member_flag2 = ' ' where customer_id = '123'

}

 

Probably needs to go in the loop where the check for notifications is done, which is probably in checkout_sucess.php.

 

For more info on mysql & php syntax have a look at www.w3schools.com

 

HTH

 

G

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Posted

It is along the lines of

 

If product_id = '12345' {

Update customer set member_flag2 = ' ' where customer_id = '123'

}

 

Probably needs to go in the loop where the check for notifications is done, which is probably in checkout_sucess.php.

 

For more info on mysql & php syntax have a look at www.w3schools.com

 

HTH

 

G

 

Thanks

 

I'm new to coding from the database. Does this go in to the this code in checkout_success.php

 


$global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
 $global = tep_db_fetch_array($global_query);


 

or

 


   $products_array = array();
   $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
   while ($products = tep_db_fetch_array($products_query)) {
     $products_array[] = array('id' => $products['products_id'],
                               'text' => $products['products_name']);

 

And how do I code it in?

 

Thanks

  • 2 weeks later...
Posted

Thanks

 

I'm new to coding from the database. Does this go in to the this code in checkout_success.php

 


$global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
 $global = tep_db_fetch_array($global_query);


 

or

 


   $products_array = array();
   $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
   while ($products = tep_db_fetch_array($products_query)) {
     $products_array[] = array('id' => $products['products_id'],
                               'text' => $products['products_name']);

 

And how do I code it in?

 

Thanks

 

Insert the code after it..

if($products['products_id'] == '12345') {

tep_db_query("update customer set member_flag2 = ' ' where customer_id = '123'");

}

 

Hope that helps.

 

PS:PHP is not hard to learn. there are 100s of tutorials online to get started :)

Our truest life is when we are in dreams awake.

-- Henry David Thoreau --

Posted

Insert the code after it..

if($products['products_id'] == '12345') {

tep_db_query("update customer set member_flag2 = ' ' where customer_id = '123'");

}

 

Hope that helps.

 

PS:PHP is not hard to learn. there are 100s of tutorials online to get started :)

 

 

Thanks for your help.

 

The code I used for this is

 

below

 


$products_array = array();
   $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
   while ($products = tep_db_fetch_array($products_query)) {
     $products_array[] = array('id' => $products['products_id'],
                               'text' => $products['products_name']);

 

Add

 


if($products['products_id'] == '36') {
tep_db_query("update customers set member_flag2 = ''  where customers_id = '" . (int)$customer_id ."'");

 

For any newbies at php :)

 

 

What I wonder is if I can pull the product (int) so I don't have to add a product id for every product any ideas?

Archived

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

×
×
  • Create New...