Zen Cart Logo
Forums / General Questions / Duplicate product + attribute prevention

Duplicate product + attribute prevention

Locked

Views: 764

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
6 Feb 2009, 9:28 PM
#1
conboy avatar

conboy

New Zenner

Join Date:
Nov 2008
Posts:
21
Plugin Contributions:
0

Duplicate product + attribute prevention

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

7 Feb 2009, 6:56 PM
#2
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Duplicate product + attribute prevention

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

9 Feb 2009, 6:23 PM
#3
conboy avatar

conboy

New Zenner

Join Date:
Nov 2008
Posts:
21
Plugin Contributions:
0

Re: Duplicate product + attribute prevention

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:

// 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
}
9 Feb 2009, 11:39 PM
#4
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Duplicate product + attribute prevention

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