Friday, 18 August 2017

Wordpress Hook Change the add to cart text on product archives

Here is the Wordpress Hook Change the add to cart text on product archives
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');
}

No comments:

Post a Comment

Google Map Filter Api Example

Here is Google Map Filter Api Example: