Jump to content

How to add checkout button under Add to Cart Button?


bacardi-rum

Recommended Posts

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

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 by defuzed (see edit history)
Link to comment
Share on other sites

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

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 by defuzed (see edit history)
Link to comment
Share on other sites

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

well, i think that you've got right. it's usually related to the cache -

in this case clear directories:

  1. cache/smarty/cache/
  2. 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

  • 1 month later...

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 by rekram (see edit history)
Link to comment
Share on other sites

  • 2 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...