Vee.K727 Posted February 25, 2017 Share Posted February 25, 2017 (edited) I have an ajax add to cart button on my product page but would like to create another one for Buy Now. It'll be same as Add to Cart but after adding the product to the cart, user will be redirected to the cart page. This question has been discussed before but not recently and their solutions didn't work on the latest prestashop installations (I have 1.6.1). Can anyone help me with that? Or explain how this button functions? Edited March 20, 2017 by Vee.K727 (see edit history) Link to comment Share on other sites More sharing options...
Vee.K727 Posted February 27, 2017 Author Share Posted February 27, 2017 Please help a guy out Link to comment Share on other sites More sharing options...
Prestachamps Posted March 4, 2017 Share Posted March 4, 2017 Hi, if you are still interested, you can add this button near your Add to cart button, and this will work out as you wanted. Please add this code to your product.tpl inside the Add to cart Form and test it out. {if isset($static_token)} <a class="button buy_now_button btn btn-default" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product->id|intval}&token={$static_token}", false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Buy Now'}" data-id-product="{$product->id|intval}" onclick="this.href = this.href+ '&qty='+$('.buy_now_button').closest('form').find('#quantity_wanted').val() + '&ipa='+ $('.buy_now_button').closest('form').find('#idCombination').val(); " > <span>{l s='Buy Now1'}</span> </a> {else} <a class="button buy_now_button btn btn-default" href="{$link->getPageLink('cart',false, NULL, 'add=1&id_product={$product->id|intval}', false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Buy Now'}" data-id-product="{$product->id|intval}" onclick="this.href = this.href+ '&qty='+$('.buy_now_button').closest('form').find('#quantity_wanted').val() + '&ipa='+ $('.buy_now_button').closest('form').find('#idCombination').val(); " > <span>{l s='Buy Now'}</span> </a> {/if} Kind regards, Leo Link to comment Share on other sites More sharing options...
Vee.K727 Posted March 6, 2017 Author Share Posted March 6, 2017 Thanks Leo for the code. I am still interested in it. Your first code does work (the one in the "if" part) but the second one (in the "else" part) doesn't. The problem is somewhere in the "onclick" part. The page does break down and says "Localhost is unable to handle the request. Would you know why that may be? is the "if" statement important? Can I use the first version at all times? Link to comment Share on other sites More sharing options...
Prestachamps Posted March 8, 2017 Share Posted March 8, 2017 Hi, you can use only the first part since this call is not an ajax call, the token is not really necessary, just make sure you test it on all kinds of products to be sure that works in every situation. Kind regards, Leo Link to comment Share on other sites More sharing options...
Vee.K727 Posted March 10, 2017 Author Share Posted March 10, 2017 Thanks a lot man. It's working well Link to comment Share on other sites More sharing options...
Prestachamps Posted March 14, 2017 Share Posted March 14, 2017 Hi, please mark the thread as solved. See here: https://www.prestashop.com/forums/topic/123579-solved-how-can-i-mark-a-topic-as-solved/ Kind regards, Leo Link to comment Share on other sites More sharing options...
Rajehs Kumar Posted June 18, 2020 Share Posted June 18, 2020 Hi all Its woks but my quick view modal not working now...help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now