vertmonkee Posted November 1, 2007 Posted November 1, 2007 I need to be able to check a products category id when a user has it placed in their shopping cart and if they have an item from an appropriate category I can then display a free item for them. I thought I had it cracked but turns out I'm not quite getting it right. In includes/classes/shopping_cart.php I changed the $products_query to this $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, pc.categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " pc, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pc.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); I then added in a line to the $products_array to collect the category id 'category' => $products['categories_id'], When I then use print_r($products) to view the contents of the array in the root/shopping_cart.php all the other details are correct apart from all the products have the same category. Can anyone see what I am doing wrong? If need be I can post all of my includes/classes/shopping_cart.php file incase that will help. Thanks.
vertmonkee Posted November 12, 2007 Author Posted November 12, 2007 Well I tried that code again and it is now working, which is good as theoretically it should have so it really bugged me when it didn't. I'v enow added it to my live Skateboard Shop and created a function to check if the user has a certain combination of products in their shopping cart. If you want to have a look to see what happens the following will work If a user adds a deck to he shopping cart two free items come up. If a user adds a combination of a deck, a set of wheels and a set of trucks to their shopping cart a third free item will be added. Please remember this is a live store so if you do place an order (which will be gratefully received) it will be charged for. Thanks
Recommended Posts
Archived
This topic is now archived and is closed to further replies.