I want to be able to prevent the insertion of duplicate entries base on two id's into the shopping cart. I believe I have to correct code, but am unable to figure out where to put it to prevent the insertion.
Any help would be appreciated.
Thanks
I want to be able to prevent the insertion of duplicate entries base on two id's into the shopping cart. I believe I have to correct code, but am unable to figure out where to put it to prevent the insertion.
Any help would be appreciated.
Thanks
You want to be looking at the routine used for adding products to the cart. You can eitehr look in includes/main_cart_actions.php, or the shopping_cart.php class file. Finally, you can also look at the header_php.php files for either the checkout process, or the shopping cart page, and add additional checks here as well.
Absolute
Thanks for the reply! Yep. Tried that. Doesn't seem to work. Even if I put the code in both files, I get nothing. Below is my code:
PHP Code:// Check for duplicates
$check_duplicate = "select * from " . TABLE_CUSTOMERS_BASKET . "
where products_id ='" . (int)$_POST['$products_id'] . "'
and applicants_id = '" . (int)$_POST['$applicants_id'] . "'";
$more_than_one=$db->Execute($check_duplicate);
if ($more_than_one->RecordCount() > 0) {
// Do not add duplicates give a warning
$dup_uniqueFailed = new messageStack("you have more than one!");
return $dup_uniqueFailed;
} else {
//Process normally
}
Both odf your POST variables include $ within the string names, however, they are enclosed in single quotes. If you are actually using variables here, you don't need the '', however, if the post variables are actually called applicants_id and products_id - remove the $.
You may want to test this by inserting an echo directly after the SQL query has been created, and making sure the SQL looks correct, with all the right values.
Absolute
Back, after a 4 year absence! Did you miss me?
Absolute Web Solutions Ltd
Interested in our work? Take a look at one of our sites - The Tech Store