jshap24 Posted June 2, 2017 Share Posted June 2, 2017 Hello, This may be above my pay grade, but I'm trying to figure out how to change the Add to Basket button a bit. Instead of simply popping up the box.basket.content window at the top of the screen and leaving the user on the same page, I would like it to add the item to basket and then return the user to the category or home page that they came from. Doing this will update the static box.basket.content that I put where featured products used to be, sort of a forced refresh. If this is possible, I would then remove the shopping cart from the top of the nav bar, so the only place the basket content would appear is the one spot. Is this overly complicated or possible? Thanks, John Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted June 2, 2017 Share Posted June 2, 2017 Welcome to the forums, @jshap24 I can't tell you how, but someone who could help you with this would want to know what CC version and what skin you are using. Quote Link to comment Share on other sites More sharing options...
jshap24 Posted June 2, 2017 Author Share Posted June 2, 2017 Thanks for the welcome! I am using version 6.1.8 and the default skin. Quote Link to comment Share on other sites More sharing options...
bsandall Posted June 5, 2017 Share Posted June 5, 2017 Create a code snippet using the hook `class.cart.add.preredirect` and add the following code: <?php $category_id = $GLOBALS['db']->select('CubeCart_category_index','cat_id',array('product_id'=>$product_id,'primary'=>1)); if ($category_id) { $redirect_url = $GLOBALS['seo']->buildURL('cat', $category_id[0]); if ($redirect_url) { httpredir($redirect_url); } } ?> This will cause the page to redirect to the main category of the product any time a user adds it to the basket and avoids entirely the JS-powered auto-display of the side basket (though this basket can still be displayed if the user specifically clicks on it). Do note, however, that the script above does not elegantly handle the case where the user adds a product from any page other than the product page, for example if they added a product to their basket from the home page. Should be enough to get you started, though. Quote Link to comment Share on other sites More sharing options...
jshap24 Posted June 14, 2017 Author Share Posted June 14, 2017 On 6/5/2017 at 2:31 PM, bsandall said: Create a code snippet using the hook `class.cart.add.preredirect` and add the following code: <?php $category_id = $GLOBALS['db']->select('CubeCart_category_index','cat_id',array('product_id'=>$product_id,'primary'=>1)); if ($category_id) { $redirect_url = $GLOBALS['seo']->buildURL('cat', $category_id[0]); if ($redirect_url) { httpredir($redirect_url); } } ?> This will cause the page to redirect to the main category of the product any time a user adds it to the basket and avoids entirely the JS-powered auto-display of the side basket (though this basket can still be displayed if the user specifically clicks on it). Do note, however, that the script above does not elegantly handle the case where the user adds a product from any page other than the product page, for example if they added a product to their basket from the home page. Should be enough to get you started, though. Thanks so much! I will give this a try today. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.