ValleyRoaster Posted July 3, 2006 Posted July 3, 2006 This is just one of those minor things that I can't quite figure out. I have a heavily modified store, MV shipping included, but that's not the problem. I have around 1500 registered customers and when one of them browses the site, adds an item to their cart, leaves the site and comes back 2-3 weeks later when the item in their cart is no longer in stock, they are allowed to checkout with those items even when my inventory says they are gone. Anyone have any clues where to start? I have the allow check out if out of stock set to false. Am I missing something? Life Is Too Short, Enjoy Your Coffee! Pete
Guest Posted July 3, 2006 Posted July 3, 2006 Open your catalog\includes\classes\shopping_cart.php define a new member function of the cart class: //-MS- Customers Basket Cleanup function cleanup_basket() { global $customer_id; $cart_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where (curdate()+0) > ((date_format(customers_basket_date_added, '%Y%m%d')+0)+10)"); // remove from database while($cart_array = tep_db_fetch_array($cart_query) ) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . (int)$cart_array['products_id'] . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . (int)$cart_array['products_id'] . "'"); } } //-MS- Customers Basket Cleanup EOM then open catalog\login.php locate the following code: // restore cart contents $cart->restore_contents(); just above it add: //-MS- Customers Basket Cleanup $cart->cleanup_basket(); //-MS- Customers Basket Cleanup EOM It will remove products added to the cart if they are 10 days old. It will check for the customers basket during log-in.
ValleyRoaster Posted July 4, 2006 Author Posted July 4, 2006 Open your catalog\includes\classes\shopping_cart.php define a new member function of the cart class: //-MS- Customers Basket Cleanup function cleanup_basket() { global $customer_id; $cart_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where (curdate()+0) > ((date_format(customers_basket_date_added, '%Y%m%d')+0)+10)"); // remove from database while($cart_array = tep_db_fetch_array($cart_query) ) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . (int)$cart_array['products_id'] . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . (int)$cart_array['products_id'] . "'"); } } //-MS- Customers Basket Cleanup EOM then open catalog\login.php locate the following code: // restore cart contents $cart->restore_contents(); just above it add: //-MS- Customers Basket Cleanup $cart->cleanup_basket(); //-MS- Customers Basket Cleanup EOM It will remove products added to the cart if they are 10 days old. It will check for the customers basket during log-in. I tried it but when I tried to log on it came back with an error not able to define function on line 73 in login.php Where do I add //-MS- Customers Basket Cleanup function cleanup_basket() { global $customer_id; $cart_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where (curdate()+0) > ((date_format(customers_basket_date_added, '%Y%m%d')+0)+10)"); // remove from database while($cart_array = tep_db_fetch_array($cart_query) ) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . (int)$cart_array['products_id'] . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . (int)$cart_array['products_id'] . "'"); } } //-MS- Customers Basket Cleanup EOM can I put it at the beginning in the shopping_cart.php? or does it matter. Life Is Too Short, Enjoy Your Coffee! Pete
Guest Posted July 4, 2006 Posted July 4, 2006 yes it matters has to be member of the cart class. Put it just before this line: function count_contents() { // get total number of items in cart
ValleyRoaster Posted July 5, 2006 Author Posted July 5, 2006 yes it matters has to be member of the cart class. Put it just before this line: function count_contents() { // get total number of items in cart Thanks! It seems to work now, time will tell. Life Is Too Short, Enjoy Your Coffee! Pete
Recommended Posts
Archived
This topic is now archived and is closed to further replies.