I'd like to relabel my add to cart button after click on it and add one item to cart into add one more to cart.
Is this possible?
I have Child-Theme function.php with a second go to cart button and this is working.
But I don't know how to solve this re-label after one item has been added to cart (shop only sells one item with different sizes). I hope that I am clear.
Here is my code:
add_filter( 'woocommerce_product_add_to_cart_text',
'customizing_add_to_cart_button_text', 10, 2 );
add_filter( 'woocommerce_product_single_add_to_cart_text',
'customizing_add_to_cart_button_text', 10, 2 );
function customizing_add_to_cart_button_text( $button_text, $product )
{
if ( WC()->cart->get_cart_contents_count() )
return __( 'Add one more to cart', 'woocommerce' );
} else {
return __( 'Add to cart ', 'woocommerce' );
}
See Question&Answers more detail:os