Answer the question
In order to leave comments, you need to log in
How to change text on button after click?
In an online store on Opencart, the product is not clearly added to the cart. In order for the user to better understand that the product has been added to the cart, we want to make sure that after clicking on the "Buy" button, the text changes to "In the cart".
I understand that this can be done using js.
To do this, I gave the button in the span id = "buy-button"
<div class="cart">
<button onclick="cart.addcart('<?php echo $product['product_id']; ?>');" class="btn btn-shopping-cart" value="<?php echo $button_cart; ?>">
<i class="fa fa-shopping-cart"></i>
<span id="buy-button"><?php echo $button_cart; ?></span>
</button>
</div>
if (json['success']) {
$('#notification').html('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
$('#cart-total').html(json['total']);
//$('html, body').animate({ scrollTop: 0 }, 'slow');
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question