Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

delete customers cart when payment is received


Guest

Recommended Posts

i use several different methods of payment.. many of which do not require the customer to return to my website after paying (for example: paypal)

 

 

how can i clear the customer's cart when I mark their order a certain status (such as "shipped")?

 

i tried:

if (isset($_GET['status']) && $_GET['status'] =='4'){
tep_db_query("delete from customers_basket and customers_basket_attributes where customers_id = '" . (int)$cID . "'");
}

no luck!

Link to comment
Share on other sites

this assumes you are on a page that has the variable cID submitted ... if not, fill it properly (I think you do not have cID)

 

in any case, you need two statements:

 

if (isset($_GET['status']) && $_GET['status'] =='4'){

tep_db_query("delete from customers_basket where customers_id = '" . (int)$cID . "'");

tep_db_query("delete from customers_basket_attributes where customers_id = '" . (int)$cID . "'");

}

 

like I said, double check the variable part, or this may not work

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

this is strange...

 

i am using this on admin/orders.php

i pulled the $status and status id right off the source code, so i am not sure why this isn't working with your fix.

 

i echoed:

echo (int)$cID;

 

and it posted "2640" on the orders page (which is my customer id)

 

so this should work, no?

am i approaching this incorrectly?

 

this should execute (empty the customer's cart) when I change their status via the default osc pull-down menu, to status 4

Link to comment
Share on other sites

the echo is for the orders page right? is it still a known variable during the processing section? probably not. Add a hidden field to the form and grab that during processing

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

is it still a known variable during the processing section?

not entirely sure... but the code was placed right beneath the echo

 

does this code maybe have to be near the pull down menu that changes the status? i've been moving it around all day and have not found much success.

 

i am not sure how to add a hidden field to this code?

Link to comment
Share on other sites

you could try and post your file... I know it's long, ut should be possible

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

my php files always seem to get cut when i post them here for character limitations, so i sent you a message over the forum with the file. i hope that's ok?

Link to comment
Share on other sites

change this

$status = tep_db_prepare_input($HTTP_POST_VARS['status']);
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
#if (isset($_GET['status']) && $_GET['status'] =='4'){
#tep_db_query("delete from customers_basket where customers_id = '" . $cust_id . "'");
#tep_db_query("delete from customers_basket_attributes where customers_id = '" . $cust_id . "'");
#}
$order_updated = false;

//fast easy checkout start
$check_status_query = tep_db_query("select customers_name, customers_company, customers_email_address, customers_id, orders_status, date_purchased, ipaddy, ipisp, customers_referer_url from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$check_status = tep_db_fetch_array($check_status_query);
$cust_id = $check_status['customers_id'];

 

to this and retry please

//fast easy checkout start
$check_status_query = tep_db_query("select customers_name, customers_company, customers_email_address, customers_id, orders_status, date_purchased, ipaddy, ipisp, customers_referer_url from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$check_status = tep_db_fetch_array($check_status_query);
$cust_id = $check_status['customers_id'];

$status = tep_db_prepare_input($HTTP_POST_VARS['status']);
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
if (isset($status) && $status =='4'){
tep_db_query("delete from customers_basket where customers_id = '" . $cust_id . "'");
tep_db_query("delete from customers_basket_attributes where customers_id = '" . $cust_id . "'");
}
$order_updated = false;

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

may be a silly question, but is 4 correct?

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

yes, it exists and i confirmed on my admin/index.php it's number by hovering the status name

 

not silly, i wondered myself if maybe i skipped something along the way. :) i've got to be missing this somewhere.

 

you are much more advanced than i, do you have the ability to test this bit of code to see if my logic is wrong?

Link to comment
Share on other sites

oddly enough

 

later in the day, i returned and logged into my customer account, the cart was empty.

 

 

does this only dump the customer account once the session has died?

or does it show the cart as active (once it's purged) only because i'm still on clicking around.

 

i use chemo's page cache - not sure if the carts are cached or not?

Link to comment
Share on other sites

When you are logged in, and the session still holds the cart data, in fact, the tables will refill again and again if at the same time you deletethem from admin side.

 

Normally though, your customer has long left the site when you are performing that update, right?

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

oh man :blush: i was up all night last night wondering why i couldn't get this to work. i tried probably a hundred different code variations and placements

 

i just tested it again and it did indeed work exactly as you explain.

thank you for your time monika, it has again proven invaluable :)

 

 

 

if i cannot figure out my url page problem i will be back in touch with you over pm ;)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...