snitchy Posted March 18, 2009 Share Posted March 18, 2009 Hello there!Was hoping someone would be able to help me with this little problem I'm having.Basically what I'm trying to do is have PrestaShop redirect the customer to a custom page after they click the add to cart button. At the moment it is being redirected to the shopping cart, but I would like to be able to specify a different address if possible, maybe a page created in CMS or a different product in the system.I know it sounds odd but there is a method to my madness, and I'll be sure to show you my reasoning if someone can guide me on how to do it Many thanks,Richard Link to comment Share on other sites More sharing options...
prestabase Posted March 18, 2009 Share Posted March 18, 2009 snitchy,Do you still want that product to be added to their shopping cart? Or simply once they click "Add to cart" it takes them to your custom page? Link to comment Share on other sites More sharing options...
snitchy Posted March 18, 2009 Author Share Posted March 18, 2009 Hello prestabase,Sorry I should have mentioned that, I do still want the product to be added to the shopping cart, as well as the user being redirected to a different page.Regards,Richard Link to comment Share on other sites More sharing options...
npimpfellow Posted March 18, 2009 Share Posted March 18, 2009 To redirect to another page I edited the order.php file to include this code:<?php$ipa = addslashes($_REQUEST['ipa']);if ($ipa == 11) {Header( "HTTP/1.1 301 Moved Permanently" );header("Location: www.site1.com");exit;} else if ($ipa == 12) {Header( "HTTP/1.1 301 Moved Permanently" );header("Location: www.site2.com");exit;}?>IPA is the item number to redirect and then the page is the site to redirect. This method WILL add the item to the cart but redirects the person to an external page, 1 problem I noticed is when you remove the item from the cart you are also redirected.WHAT I WANT TO DO IS:I would like to have it redirect to the external site and NOT add the item to the shopping cart, any idea on how to do this?I would also like to change the wording of the "add to cart" button also. Link to comment Share on other sites More sharing options...
prestabase Posted March 18, 2009 Share Posted March 18, 2009 npimpfellow,You can change the wording of "add to cart" to something else by setting a translation within Backoffice. - Back Office >> Tools >> Translations Link to comment Share on other sites More sharing options...
npimpfellow Posted March 19, 2009 Share Posted March 19, 2009 What about removing the quantity option for the item? I only want people to buy one item at a time so I want to hide the quantity box. Any idea how to do that? Link to comment Share on other sites More sharing options...
shall-ee Posted April 28, 2009 Share Posted April 28, 2009 Hello,I want to redirect to the product_list page after adding the product to cart. Has anyone an idea how to do this?Thx in advance. Link to comment Share on other sites More sharing options...
gregbull Posted May 9, 2009 Share Posted May 9, 2009 HiDoes anybody know how / where to do this, as I wish to do a similar thing of when a user adds an item to the cart from the product.php page, they get redirected back to the product-list page (or category.php), and don't stay on the product page.I have been playing with the product.tpl file adding a href to this line: quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block"><input type="submit" name="Submit" value="{l s='Add to order'}" class="exclusive" /></p> But doesnt seem to work.Any advice would be appreciated.Thanks Link to comment Share on other sites More sharing options...
pneeds Posted July 8, 2009 Share Posted July 8, 2009 ^^^^I would also love to know this.Thanks in advance. Link to comment Share on other sites More sharing options...
snitchy Posted July 10, 2009 Author Share Posted July 10, 2009 Ok so better late than never, I have the solution.. sort of. I have it working on our Custom PC Builder on our website, basically every time you click the big green "Continue" button it is adding the product to the cart but redirecting the user to a different page instead of the cart.The way we have it set up is a bit more complicated than the solution I'm about to give, but this will allow you to redirect users to a custom page once the customer hits the "Add to cart" button, whilst still having the product added to their cart.Known Issues:First of all this wont work if you have the Ajax cart enabled, so disable it in the module settings first. I don't see it as a big problem as the customer probably wont get to see all of the pretty animation if the page redirects quick enough.Second issue is that when the customer clicks the + and - button on the cart page, it will still redirect the user to the custom page you specify. Hopefully there are some clever people on here that can help you with that because I don't know how to do it.InstructionsFirst open up "cart.php" in your favourite text/PHP editor.Find the following code at line 138: Tools::redirect('order.php?'.(isset($idProduct) ? 'ipa='.intval($idProduct) : '')); REPLACE that line with the following: { if ($delete) { Tools::redirect('order.php?'.(isset($idProduct) ? 'ipa='.intval($idProduct) : '')); } else { Tools::redirect('any-page-you-like.php'); } } Obviously, you will need to replace "any-page-you-like.php" with the URL that you want the user to be redirected to once they add the product to their cart.Good luck! Link to comment Share on other sites More sharing options...
Recommended Posts