is it possible change "add to cart" to "added"

  • Posts: 201
  • Thank you received: 7
2 years 8 months ago #339788

hi
I want to change "add to cart" text after user click on that button , means after added to cart. is it possible?
"add to cart" => "added"
how to do it? i can write some code and please advise me if this is higher than normal user support.
thank's alot
(excuse me i send this post to incorrect topic and can not edit)

Last edit: 2 years 8 months ago by sadaf3d.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #339790

Hi,

I think (not tested) you can do that with such javascript:

window.Oby.registerAjax(["cart.updated"],function(params){
if(params.el) {
 params.el.innerHTML = 'added';
}
});

Last edit: 2 years 8 months ago by nicolas.
The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

  • Posts: 201
  • Thank you received: 7
2 years 7 months ago #340801

Is it possible when the page loaded and user has that product in his card from previous then show added label?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 7 months ago #340808

Hi,

It's possible but more complex.
You need to customize the file product / listing_add_to_cart_ajax and the file product / quantity.php which display the add to cart button on the listings and on the product page.
There, you have this code for the text of the add to cart button:

$content = JText::_('ADD_TO_CART');
So just after that line, you can add something like that:
$cartClass = hikashop_get('class.cart');
$cart = $cartClass->getFullCart();
if(!empty($cart->products)) {
 foreach($cart->products as $p) {
  if($p->product_code == $this->row->product_code) {
   $content .= ' added';
  }
 }
}

The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum