mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
24 lines
802 B
Text
24 lines
802 B
Text
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );
|
|
function woo_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?', 'woocommerce');
|
|
}
|
|
}
|
|
return __('Add to cart', 'woocommerce');
|
|
}
|
|
|
|
add_filter( '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 __('Already in cart', 'woocommerce');
|
|
}
|
|
}
|
|
return __('Add to cart', 'woocommerce');
|
|
}
|