bacardi-rum Posted June 6, 2013 Share Posted June 6, 2013 How do I add Checkout button under add to cart button ? or make checkout button appear after they add the product to the cart? Link to comment Share on other sites More sharing options...
defuzed Posted June 6, 2013 Share Posted June 6, 2013 I added a checkout button to my modified cart module if a product is in the cart. I guess this could also work in the blockuserinfo module. <a href="{$link->getPageLink($order_process, true)}" title="{l s='Checkout' mod='[YOURCARTNAME]'}" rel="nofollow" class="checkout"><img src="{$img_dir}icons/cart-icon.png"> {l s='Checkout' mod='[YOURCARTNAME]'}</a> at the end of the {if $products} block or the {if $cart_qties > 0} block if you want to use the blockuserinfo module for it. I don't know if you could use something like {if $cart_qties > 0} in the product.tpl, would probably require you to add the function to ProductController. I believe having the checkout button in the cart is the best way to go anyway usability wise. Link to comment Share on other sites More sharing options...
vekia Posted June 6, 2013 Share Posted June 6, 2013 @bacardi-rum let us know if the solution mentioned above works for you regards Link to comment Share on other sites More sharing options...
bacardi-rum Posted June 6, 2013 Author Share Posted June 6, 2013 In what file should I place this code and what line? Link to comment Share on other sites More sharing options...
bacardi-rum Posted June 6, 2013 Author Share Posted June 6, 2013 And were do I find my cart name? Link to comment Share on other sites More sharing options...
vekia Posted June 6, 2013 Share Posted June 6, 2013 modules/blockuserinfo/blockuserinfo.tpl or themes/modules/blockuserinfo/blockuserinfo.tpl Link to comment Share on other sites More sharing options...
bacardi-rum Posted June 6, 2013 Author Share Posted June 6, 2013 vekia, I am really not sure what line to add this to. I found the file and cart>0 line. Do i add the code under that or where? Link to comment Share on other sites More sharing options...
defuzed Posted June 7, 2013 Share Posted June 7, 2013 (edited) the {if $cart_qties > 0} loop defines what is displayed in the userinfo module when something is in the cart. I placed my checkout button at the end of that loop. edit to further clarify: {if $cart_qties > 0} {if $priceDisplay == 1} {assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant} {convertPrice price=$cart->getOrderTotal(false, $blockuser_cart_flag)} {else} {assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant} {convertPrice price=$cart->getOrderTotal(true, $blockuser_cart_flag)} {/if} // *** PLACE YOUR CHECKOUT BUTTON HERE *** {/if} Edited June 7, 2013 by defuzed (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 7, 2013 Share Posted June 7, 2013 but for the first, you want to add this "checkout" to the cart exactly as defuzed mentioned, or you want to add "checkout" button under each add to cart button? Link to comment Share on other sites More sharing options...
bacardi-rum Posted June 7, 2013 Author Share Posted June 7, 2013 I want to add the checkout button under each add to cart button. and if possible make it so that once the product is added they can just click checkout right there below. Or another solution coulb to to make chekout always visible like on amazon. As it is right now by default you have to hover the mouse over the cart to see the checkout button. Link to comment Share on other sites More sharing options...
defuzed Posted June 7, 2013 Share Posted June 7, 2013 (edited) i just realized $cart_qties is actually a global smarty variable so i guess you could just put {if $cart_qties > 0} <a href="{$link->getPageLink($order_process, true)}" class="checkout-button">Checkout</a> {/if} anywhere you want (like below every add-to-cart button) and it would display this checkout button anytime you have 1 or more products in your cart Edit: Thanks Vekia, changed the code part to close the link tag Edited June 7, 2013 by defuzed (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 7, 2013 Share Posted June 7, 2013 so if you want to add add to cart button on each product listing, you have to edit: product-list.tpl file located in your theme directory use code that defuzed pasted above (don't forget to close </a> because defuzet forgot to close it Link to comment Share on other sites More sharing options...
bacardi-rum Posted June 7, 2013 Author Share Posted June 7, 2013 what is the correct class for checkout in prestashop? class=? Link to comment Share on other sites More sharing options...
defuzed Posted June 10, 2013 Share Posted June 10, 2013 The class is only important for styling / css purposes. You could use the default template "button" or "button_large" or just create your own if you want your own look. Link to comment Share on other sites More sharing options...
vekia Posted June 10, 2013 Share Posted June 10, 2013 i totally agree with defuzed, you can use default button styles and if you want - you can use own style. Link to comment Share on other sites More sharing options...
bacardi-rum Posted June 13, 2013 Author Share Posted June 13, 2013 Ok thanks guys! Link to comment Share on other sites More sharing options...
bacardi-rum Posted June 13, 2013 Author Share Posted June 13, 2013 I ended up editing the blockuserinfo code as you suggested and adding a checkout button. Once a user clicks Add to cart it becomes visible. But sometimes i think due to cache it doesnt appear all the time. Link to comment Share on other sites More sharing options...
vekia Posted June 13, 2013 Share Posted June 13, 2013 well, i think that you've got right. it's usually related to the cache - in this case clear directories: cache/smarty/cache/ cache/smarty/compile/ But sometimes it also depends on tpl file, where you exactly put code with new button? maybe in some {if} condition? Link to comment Share on other sites More sharing options...
rekram Posted August 11, 2013 Share Posted August 11, 2013 (edited) It doesn't work with AJAX cart, because the button checkout is visible only after you reload the page. How to make visible at the same time as clicking? EDIT: ok, I've made something like this, but itsn't working with jquerry and doesn't check if products are in cart, just show button checkout under add_to_cart button when clicked. in product.tpl I added <script type="text/javascript"> function showDiv() { document.getElementById('checkout').style.display = ""; } </script> <div id="checkout" style="display:none"> <a href="{$link->getPageLink('order.php', true)}" id="button_large"rel="nofollow">CHECKOUT</a><!-- this button moving to checkout page --> </div> and in the same template I added onclick="showDiv()" attribute to <p id="add_to_cart" class="buttons_bottom_block"> <input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" onclick="showDiv()" /> </p> Edited August 11, 2013 by rekram (see edit history) Link to comment Share on other sites More sharing options...
ajensen27 Posted August 12, 2013 Share Posted August 12, 2013 Would be really cool if someone could get this to work with the Ajax cart. 1 Link to comment Share on other sites More sharing options...
julesfromparis Posted August 28, 2015 Share Posted August 28, 2015 Up ! Would be really cool if someone could get this to work with the Ajax cart. Link to comment Share on other sites More sharing options...
vekia Posted August 30, 2015 Share Posted August 30, 2015 why not to add it to block cart module .tpl file and display it there automatically with page generation ? 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