1 | initial version |
To modify the notification text when clicking on the add to cart button before selecting a variation in Woocommerce, you can use the following code snippet in your functions.php file:
add_filter( 'woocommerce_variation_is_active', 'custom_variation_is_active', 10, 2 );
function custom_variation_is_active( $active, $variation ) {
if ( ! $variation->is_in_stock() ) {
$active = false;
wc_add_notice( __( 'Please select a different variation.' ), 'error' );
}
return $active;
}
This code will display the "Please select a different variation" message when the user clicks the add to cart button before selecting a variation. You can modify the message to suit your needs by changing the text inside the __('...') function.