A simple, powerful and independent e-commerce platform.
Sell anything with ease.

Change ‘Add to cart’ text when product added to cart

This code changes the “add to cart” text on the button when a product has been added to the cart.

		/**
 * Change the add to cart text on single product pages when product added
 */
 
add_filter('woocommerce_product_single_add_to_cart_text', 'cc_custom_cart_button_text');

function cc_custom_cart_button_text() {

  global $woocommerce;

  foreach($woocommerce->cart->get_cart() as $cart_item_key => $values ) {
    $_product = $values['data'];
    if( get_the_ID() == $_product->id ) {
      return __('Already in cart - add again?', 'classic-commerce');
    }

  }

  return __('Add to cart', 'classic-commerce');

}
	
View Raw Code ID: 9946