Created
October 10, 2014 06:48
-
-
Save vishalbasnet23/b8a5ec4ffa3a1a49f26e to your computer and use it in GitHub Desktop.
Custom Add to cart button for woommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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