add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' );
function woo_archive_custom_cart_button_text() {
global $woocommerce;
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if( get_the_ID() == $_product->id ) {
return __('В корзине', 'woocommerce');
}
}
if ( has_term( 'buynow', 'product_tag', $_product->id ) ) :
return __( 'В корзину', 'woocommerce' );
else:
return __( 'В корзину', 'woocommerce' );
endif;
}
add_filter('post_class', function($classes, $class, $product_id) {
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if( get_the_ID() == $_product->id ) {
$classes = array_merge(['added'], $classes);
return $classes;
}
}
return $classes;
},10,3);