Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Deleting Products: Impact on Customers Basket & Customers Basket Attributes Tables


PassionSeed

Recommended Posts

osCommerce 2.3.1

 

I have a problem with disappearing items in customers baskets. Here's what I found that may be causing this.

 

In the admin/includes/functions/general.php file it shows

 

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . (int)$product_id . "' or products_id like '" . (int)$product_id . "{%'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . (int)$product_id . "' or products_id like '" . (int)$product_id . "{%'");

 

The above query will remove all of the following from the customers_basket and customers_basket_attributes tables when you only want to remove rows referencing product id 2.

 

2{2}122{1}1

233{2}122{1}1

732{2}62{1}1

 

I updated the database query to:

 

$product_id_string_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET);

while($product_id_string = tep_db_fetch_array($product_id_string_query)) {

$pid_string = $product_id_string['products_id'];

$pid_string_parts = explode("{", $pid_string);

 

if ($pid_string_parts[0] == $product_id) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . $pid_string . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . $pid_string . "'");

}

}

 

I hope this works for you! :shifty:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...