Kristoff Posted October 22, 2013 Share Posted October 22, 2013 Say for example you have the store set up to immediately go to the basket when you click to buy an item, is there a way of adding another button to add the item to the basket? Bypassing the set system for the store thus enabling a "Buy Now" and "Add to Basket" button? Many thanks in advance Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 22, 2013 Share Posted October 22, 2013 I can look to find out how to do that. One button behaves as if the store is set to keep the customer where he is, and the next button behaves as if the store is set to take the customer to the View Basket page? Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 22, 2013 Author Share Posted October 22, 2013 I can look to find out how to do that. One button behaves as if the store is set to keep the customer where he is, and the next button behaves as if the store is set to take the customer to the View Basket page? Spot on. I did ask in a support ticket but didn't even get a reply. Would be great if you can investigate. Cheers! Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted October 22, 2013 Share Posted October 22, 2013 It's beginning to sound like there's some kind of flaw with the Support System - way too many people saying they're not getting replies (really, one is too many)! Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 22, 2013 Share Posted October 22, 2013 There are two places that need editing: /classes/cart.class.php, line 253 (deals with where to go after adding a gift certificate to the basket) and 405 (deals with where to go after adding an inventory item to the basket). Of the two statements, there is a common part, with other stuff before and after it. ($GLOBALS['config']->get('config', 'basket_jump_to')) ? $GLOBALS['rootRel'].'index.php?_a=basket' : currentPage(null) And of that, we will just change this part: ($GLOBALS['config']->get('config', 'basket_jump_to')) to: (!isset($_POST['stay'])) So, instead of using the store setting, we will use a key in the POSTed form array. If the POST array has ['stay'], we know to stay on this page. Using the Kurouto template file content.homepage.php, find: <input type="submit" value="{$LANG.catalogue.add_to_basket}" class="button_white" /> Make it look like: <input onclick="this.name='cart';submit();" value="{$LANG.catalogue.add_to_basket}" class="button_white" /> <input onclick="this.name='stay';submit();" value="Add & Remain" class="button_white" /> jQuery serializes to POST all the form's elements, except the submit-type element. But that's what we need. So we won't type these <input> elements as submit -- we won't type them as anything! (You might be able to use a <button>.) We also won't give them a name as only named elements will be serialized. What we will do is that, when clicked, we give them a name and fire the DOM's form submit function, which jQuery catches. And the name of the element gets serialized. We don't care about the value the <input> sends back - only the name/key - as the value will change when the store's language changes. Now that 'cart' or 'stay' will show up in POST, we can test for 'stay'. Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 22, 2013 Author Share Posted October 22, 2013 That worked perfectly thank you. I had a bit of a shuffle, as I don't use buy buttons on the homepage, but a More Info button, I added the code to the product page itself and as i'm not sure if there would be any issue with it, but I only needed to use the <input onclick="this.name='stay';submit();" value="Add & Remain" class="button_white" /> button, I found it added a load of extra space to the button for some reason, but the original <input type="submit" value="{$LANG.catalogue.buy}"> button works fine for going direct to the basket upon adding. Many thanks again! 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.