Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
Created October 10, 2014 06:48
Show Gist options
  • Save vishalbasnet23/b8a5ec4ffa3a1a49f26e to your computer and use it in GitHub Desktop.
Save vishalbasnet23/b8a5ec4ffa3a1a49f26e to your computer and use it in GitHub Desktop.
Custom Add to cart button for woommerce
/**
* Change the add to cart text on product archives
*/
add_filter( 'add_to_cart_text', 'woo_archive_custom_cart_button_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' );
function woo_archive_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 ('<span class="is-in-cart">Added</span>');
}
}
return __('Add to cart', 'woocommerce');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment