Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Empty Shopping Cart


Collect

Recommended Posts

Posted

I am searching for some days on foruns a way to do this:

 

When a customer add something to a shopping cart, and logoff the products still on shopping cart on next login. Is there a way to empty the shopping cart on exit / logoff, automatic or by option of customer?

 

I have tried a contribution about tracking customer, but the products between session always stay on cart

 

Thank you.

  • 7 months later...
Posted

I too am looking for same feature, tell me did you ever find a way to fix the problem and if so how did you do it

  • 2 years later...
Posted

Hi all,

 

I'm looking for the answer to this question too. Can somebody help us? Thanks in advance.

 

Sincerely,

Posted

you would need to clear the sessions, customers basket and customers basket attributes tables for people not online anymore, the whos on line function which stores the customers id also clears at a determined time interval and could be modified to do the rest.

 

You would then need to extract from the whos on line table the customers id, and then use this to delete the session as well clear the customers basket and customers basket attributes tables usingh the customer id found in the whos on line table.

 

I have not looked into this a lot and it is first thing in the morning, but this should give you an idea anyways....

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Posted
Hi all,

 

I'm looking for the answer to this question too. Can somebody help us? Thanks in advance.

 

Sincerely,

 

simply use a switch to enable/disable the mirroring of the session cart with the database cart for registered customers.

Treasurer MFC

Posted

Hi Cannuck1964 & Boxtel,

 

Thanks for your reply.

 

Your suggestions look clever, but I have to confess that I'm an absolute beginner with osCommerce. I'm not able to put this into practice. :'(

 

Sincerely,

Posted
Hi Cannuck1964 & Boxtel,

 

Thanks for your reply.

 

Your suggestions look clever, but I have to confess that I'm an absolute beginner with osCommerce. I'm not able to put this into practice. :'(

 

Sincerely,

 

in the class shopping_cart.php you have these sql statements:

 

like this example but there are many:

 

if (tep_session_is_registered('customer_id') && ($reset_database == true)) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");

}

 

 

you extend the conditions for those queries like in this example:

 

if (tep_session_is_registered('customer_id') && ($reset_database == true) && (SAVE_CART)) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");

}

 

and put the switch in application_top.php

 

define('SAVE_CART',false);

 

that way no cart contents is maintained in the database for anybody and as such will always be lost as session expire.

that switch you can always turn to true again.

Treasurer MFC

Posted

Hi Amanda,

 

Thanks for your reply.

 

In includes\classes\shopping_cart.php I have modified the line:

if (tep_session_is_registered('customer_id') && ($reset_database == true) && (SAVE_CART))

and in classes\application_top.php added:

define('SAVE_CART',false); but it doesn't work.

 

I have also tried with define('SAVE_CART', 'false'); just in case there were missing quotes, but it doesn't work too.

 

Is there something I have done wrong?

 

Sincerely,

 

Amar

Posted
if (tep_session_is_registered('customer_id') && ($reset_database == true) && (SAVE_CART)) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");

}

Will not work from what I see here. I still think editing the whos_on_line function will work better, have a look at the file:

 

includes/functions/whos_online.php

 

where you see this line,

tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");

 

you want to do a select first to get all of the customers_id's then use these customer ids to delete the customers basket...

 

this will automate the process and is easy to add in....

 

cheers,

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Posted
Will not work from what I see here. I still think editing the whos_on_line function will work better, have a look at the file:

 

includes/functions/whos_online.php

 

where you see this line,

tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");

 

you want to do a select first to get all of the customers_id's then use these customer ids to delete the customers basket...

 

this will automate the process and is easy to add in....

 

cheers,

Peter M.

 

first of all it does work as I use it myself.

 

on the other hand, your suggestion is hacking not a solution.

even more, it adds unnecessary queries to the site instead of removing them.

Treasurer MFC

Posted
Hi Amanda,

 

Thanks for your reply.

 

In includes\classes\shopping_cart.php I have modified the line:

if (tep_session_is_registered('customer_id') && ($reset_database == true) && (SAVE_CART))

and in classes\application_top.php added:

define('SAVE_CART',false); but it doesn't work.

 

I have also tried with define('SAVE_CART', 'false'); just in case there were missing quotes, but it doesn't work too.

 

Is there something I have done wrong?

 

Sincerely,

 

Amar

 

there is no classes/application_top.php

there is an includes/application_top.php

 

 

includes/classes/shopping_cart.php:

 

function restore_contents() {

 

-> if ((!tep_session_is_registered('customer_id')) or (!SAVE_CART))return false;

 

 

function reset($reset_database = false) {

 

-> if (tep_session_is_registered('customer_id') && ($reset_database == true) && (SAVE_CART)) {

 

 

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {

 

-> if ((tep_session_is_registered('customer_id')) and (SAVE_CART)) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

 

 

-> if ((tep_session_is_registered('customer_id')) and (SAVE_CART)) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");

 

 

function update_quantity($products_id, $quantity = '', $attributes = '') {

 

-> if ((tep_session_is_registered('customer_id')) and (SAVE_CART)) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

 

 

-> if ((tep_session_is_registered('customer_id')) and (SAVE_CART)) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");

 

 

function cleanup() {

 

-> if ((tep_session_is_registered('customer_id')) and (SAVE_CART)) {

 

 

function remove($products_id) {

 

-> if ((tep_session_is_registered('customer_id')) and (SAVE_CART)) {

Treasurer MFC

Posted
on the other hand, your suggestion is hacking not a solution.
Just what do you define hacking as? All changes to the system is hacking. Do you not think your solution is hacking too?

 

even more, it adds unnecessary queries to the site instead of removing them.
Your solution does the exact same, as mine as you are doing DB hits everytime the shopping_cart class is accessed as well. So yours does not save anything in terms of DB deletes etc, A more formal solution would be to not even store the product info into the DB at any point in time, rather the to store it then delete it every load ;)

 

You should maybe refrain from calling on solution a hack and more DB intensive until you look at yours in the same light

 

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Posted
Just what do you define hacking as? All changes to the system is hacking. Do you not think your solution is hacking too?

 

Your solution does the exact same, as mine as you are doing DB hits everytime the shopping_cart class is accessed as well. So yours does not save anything in terms of DB deletes etc, A more formal solution would be to not even store the product info into the DB at any point in time, rather the to store it then delete it every load ;)

 

You should maybe refrain from calling on solution a hack and more DB intensive until you look at yours in the same light

 

Peter M.

 

You should read more carefully first.

 

your suggestion is a hack as it removes a symptom of a problem, not the problem itself.

 

my solution eliminates all unnecessary db calls but you would know that if you read more carefully.

Treasurer MFC

Posted
your suggestion is a hack as it removes a symptom of a problem, not the problem itself.

 

Your solution does not remove anything other then do deletes every page load, it does not save any DB query hits, and does not solve the symptom either, it just hacks the shopping cart to delete is all, which is what the whos_online one does as well, only mine would do this only when they leave the site and not everytime they load the page. Yours does not do more then mine nor it it more effecient then mine.

 

my solution eliminates all unnecessary db calls but you would know that if you read more carefully.

 

LOL....now that is funny as you posted one spot to add in the new define, which just deletes things and does not stop the loading of the product info into the tables then removed, simple, do not presume to tell me that your solution is so eligant that others are all hacks, I think you shoulf evalute your solution fully before stating incorrect information, simple.

 

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Posted
Your solution does not remove anything other then do deletes every page load, it does not save any DB query hits, and does not solve the symptom either, it just hacks the shopping cart to delete is all, which is what the whos_online one does as well, only mine would do this only when they leave the site and not everytime they load the page. Yours does not do more then mine nor it it more effecient then mine.

LOL....now that is funny as you posted one spot to add in the new define, which just deletes things and does not stop the loading of the product info into the tables then removed, simple, do not presume to tell me that your solution is so eligant that others are all hacks, I think you shoulf evalute your solution fully before stating incorrect information, simple.

 

Peter M.

 

Still not read a thing...

Treasurer MFC

  • 1 year later...
Posted

hi boxtel,

 

i think i understand from what you're saying that once the session expires the cart would be emptied. how long does the session last for? is it based on exiting the site or a session time-out?

 

could you tell me (forgiving my newbie ignorance) if i can use this to have the cart expire after say, 24 or 48 hours?

 

we will be selling mostly one-of-a-kind art items and i do not want customers to have items in their carts for lengthy periods and then abandon them at a later date. our inventory is limited.

 

any thoughts on this would be greatly appreciated.

 

thanks!

  • 5 months later...
Posted
i think i understand from what you're saying that once the session expires the cart would be emptied. how long does the session last for? is it based on exiting the site or a session time-out?

 

could you tell me (forgiving my newbie ignorance) if i can use this to have the cart expire after say, 24 or 48 hours?

 

I am going to try to put together a PHP template that runs something like the following:

 

delete from customers_basket_attributes

where products_id in

(select products_id from customers_basket

where customers_basket_date_added < '20080103') ;

 

delete from customers_basket

where customers_basket_date_added < '20080103') ;

 

These two statement delete the records from the two basket tables in the database that are older than a given date. I could have the date be a variable. I could have the number of days as a constant in the administration configure file so that an administrator could easily select the number of days after which the outdated basket records would be deleted.

 

How could I get this to run automatically? Would we want to have a different number of days, depending on the customer? Would we want to give the customer a warning?

 

I am open to input on this.

 

... Andy

  • 2 years later...
Posted

I am going to try to put together a PHP template that runs something like the following:

 

delete from customers_basket_attributes

where products_id in

(select products_id from customers_basket

where customers_basket_date_added < '20080103') ;

 

delete from customers_basket

where customers_basket_date_added < '20080103') ;

 

... Andy

 

I run those SQL commands to clear the customer baskets:

 

1.

DELETE FROM `customers_basket_attributes`

WHERE (`products_id`, `customers_id`) in

(select `products_id`, `customers_id` from `customers_basket`

where `customers_basket_date_added` < '20100215');

 

2.

DELETE FROM `customers_basket` WHERE `customers_basket_date_added` < '20100215' ;

 

3., 4.

OPTIMIZE TABLE `customers_basket_attributes`;

OPTIMIZE TABLE `customers_basket`;

 

The date (here '20100215') must be the same in both commands 1. and 2.

 

It seems to work fine. Cheers

Archived

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

×
×
  • Create New...