ken0306 Posted April 6, 2015 Share Posted April 6, 2015 Hi, I am trying to insert the top category id into my wishlist table. here is what I did to find the top category ID $cPath = implode('_', $cPath_array); $top_category_id = strtok($cPath, '_'); echo $top_category_id; from above script, the $top_category_id only shows the top level category id under the product info page. Now I want to insert the id number into my sql table, can somebody get me a direction how to do that? thank you. ken Link to comment Share on other sites More sharing options...
Jack_mcs Posted April 7, 2015 Share Posted April 7, 2015 Instead of writing new code to get the ID, just use the in-built tep_parse_category_path function. For adding to the table, you would use the insert command, if this is a new entry, or update command, for existing entries. This assumes a field for the ID already exists. There should be commands like those in the addon code already but you can get examples in the admin/categories.php file. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
ken0306 Posted April 8, 2015 Author Share Posted April 8, 2015 Instead of writing new code to get the ID, just use the in-built tep_parse_category_path function. For adding to the table, you would use the insert command, if this is a new entry, or update command, for existing entries. This assumes a field for the ID already exists. There should be commands like those in the addon code already but you can get examples in the admin/categories.php file. Hi Jack, Thank you for your reply. what I trying to do is adding extra information to wishlist function. I have wishlist 3.0 install and add extra field call categories_id in my customer_wishlist table. I modified the insert query from tep_db_query("insert into " . TABLE_WISHLIST . " (customers_id, products_id) values ('" . $customer_id . "', '" . $wishlist_id . "')"); to tep_db_query("insert into " . TABLE_WISHLIST . " (customers_id, products_id, categories_id) values ('" . $customer_id . "', '" . $wishlist_id . "', '" . $_POST ['top_category_id'] . "')"); I also add the input name call top_category_id in my product_info.php. But I can't get it work, the $_POST['top_category_id'] doesn't post the top category data to the query. However, I change $_POST['top_category_id'] to a number in the query, it will insert the correct information to the database. So how can I get that piece data post to the wishlist query ? thank you ken Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.