tmcca Posted March 2, 2020 Share Posted March 2, 2020 I am trying to add the following hook and not working. Could it be I am missing a global? Instead it's adding to cart and not to wishlist. In application_top.php I added this hook echo $OSCOM_Hooks->call('application_top', 'WishListMod'); I made a directory in hook directory called application_top I added this code into that directory: <?php class hook_shop_application_top_wishlist { function listen_WishListMod() { global $oscTemplate, $languages_id, $currencies, $wishList; if (!tep_session_is_registered('wishList') || !is_object($wishList)) { tep_session_register('wishList'); $wishList = new wishlist; } if (isset($_POST['wishlist'])) { if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) { $attributes = isset($_POST['id']) ? $_POST['id'] : ''; $wishList->add_wishlist($_POST['products_id'], $wishList->get_quantity(tep_get_uprid($_POST['products_id'], $attributes))+1, $attributes); } if (WISHLIST_REDIRECT == 'No') tep_redirect(tep_href_link('product_info.php', 'products_id=' . $_POST['products_id'])); tep_redirect(tep_href_link('wishlist.php')); } Link to comment Share on other sites More sharing options...
♥ecartz Posted March 2, 2020 Share Posted March 2, 2020 You should not echo a hook call in application_top. You shouldn't start echoing until after template_top.php has been included. You don't need the wishlist to be a session variable. Instead, only load what you actually need into the session. On most pages, you wouldn't have to read the wishlist at all. I'm not crazy about using application_top as the group there. It would make more sense to use your own group, like wishlist. But none of that is the question that you were asking. The most likely problem is that you are missing the group register. In this case, $OSCOM_Hooks->register('application_top'); You need to do that before you call. Immediately prior is fine. Always back up before making changes. Link to comment Share on other sites More sharing options...
tmcca Posted March 2, 2020 Author Share Posted March 2, 2020 Well in the wishlist original it says to put code before // Shopping cart actions in application_top wouldn't I have to call a hook in there for this function? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.