Page 1 of 1
disabled and enabled checkout button
Posted: Sun Mar 13, 2016 11:24 pm
by heartbreak18
how to disable checkout button when user hasn't choose the item?
but when user has choose an item the checkout button will active again.
thanks

Re: disabled and enabled checkout button
Posted: Mon Mar 14, 2016 12:38 am
by leo
You mean, the checkout button in the menu bar?
Re: disabled and enabled checkout button
Posted: Tue Mar 15, 2016 4:04 am
by heartbreak18
leo wrote:You mean, the checkout button in the menu bar?
yes leo, how can i do that?
Re: disabled and enabled checkout button
Posted: Tue Mar 15, 2016 7:30 am
by leo
Are you sure you want this?
If your customer adds products to the cart, but decides to continue the payment later and logs off, when he comes back, he cannot use the checkout button, although he has already products in his cart. This could be confusing for him.
Re: disabled and enabled checkout button
Posted: Tue Mar 15, 2016 11:28 pm
by heartbreak18
leo wrote:Are you sure you want this?
If your customer adds products to the cart, but decides to continue the payment later and logs off, when he comes back, he cannot use the checkout button, although he has already products in his cart. This could be confusing for him.
yeah i know leo, but i want to give a try
so, when costumer hasn't adds product to the cart they can't use the checkout button, but if costumer has adds product to the cart they can access the checkout button.
please help me

Re: disabled and enabled checkout button
Posted: Wed Mar 16, 2016 1:23 am
by leo
Modify catalog/template/defult/module/navigation.tpl to
Code: Select all
<a href="<?php echo $account; ?>"><?php echo $text_account; ?></a>
<?php if (@$login) { ?>
<a href="<?php echo $login; ?>"><?php echo $text_login; ?></a>
<?php } else { ?>
<a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a>
<?php } ?>
<a href="<?php echo $cart; ?>"><?php echo $text_cart; ?></a>
<a href="<?php echo $checkout; ?>" class="<?php echo ($enable_checkout ? 'enabled' : 'disabled'); ?>"><?php echo $text_checkout; ?></a>
</div>
</div>
<script type="text/javascript"><!--
$(document).ready(function(){
$("#bar a:last").css("border-right","0px");
});
//--></script>
<script type="text/javascript"><!--
$(".b > a").on("click", function(event){
if ($(this).hasClass("disabled")) {
event.preventDefault();
}
});
//--></script>
then add to the end of catalog/template/default/shred/add_to_cart.tpl:
Code: Select all
<script type="text/javascript"><!--
$(".add > .button").on("click", function(event){
$('.b > a').removeClass("disabled");
});
//--></script>
add to catalog/extension/module/navigation.php:
below
Code: Select all
$config =& $this->locator->get('config');
this:
Code: Select all
$cart =& $this->locator->get('cart');
and below
Code: Select all
$view->set('cart', $url->href('cart'));
this line:
Code: Select all
$view->set('enable_checkout', $cart->hasProducts());
This should do the trick.
Re: disabled and enabled checkout button
Posted: Wed Mar 16, 2016 4:48 am
by heartbreak18
thanks leo

Re: disabled and enabled checkout button
Posted: Wed Mar 16, 2016 5:29 am
by leo
You are welcome.
Please use postreply and not quote.
Re: disabled and enabled checkout button
Posted: Thu Dec 06, 2018 7:41 am
by Dubrey
Hi Leo, was this fix added to the default template or does it still have to be applied manually?
Re: disabled and enabled checkout button
Posted: Thu Dec 06, 2018 10:09 am
by leo
Hi, this is not a fix, just a modification.
You have to add it manually.