I'm working on woocommerce project and I want to add a new class on Add to Cart button if product is already added in cart, Can you help me to find out with this.
I'm changing right now using this code
add_filter( 'woocommerce_product_single_add_to_cart_text', 'bbloomer_custom_add_cart_button_single_product' );
function bbloomer_custom_add_cart_button_single_product( $label ) {
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$product = $values['data'];
if( get_the_ID() == $product->get_id() ) {
$label = __('Added', 'woocommerce');
}
}
return $label; }
text is changing but I want add class so I can add my css style
please help Thank You
The add to cart template which is in
woocommerce/templates/loop/add-to-cart.phphas a filter. So we can also over write the class usingadd_filterfunction infunctions.php.