Change add to cart text if product already in cart for variables
-
Hi there,
I’d like to let my customer know if he has added a certain product and variable to the cart already.
Therefore I’d like to change the text on the “add to cart” button as soon as the item is already added into the cart.
I have found following snippet for simple products only, but not for variable products:
/** * Change the add to cart text on single product pages */ add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text'); function woo_custom_cart_button_text() { foreach( WC()->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'); }
Is it possible to create the same effect for variable products?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Change add to cart text if product already in cart for variables’ is closed to new replies.