I am using below custom code to customize the default Woocommerce Alert for variable product (if user not selected any of the available variation). The Alert, that reads as - Please select some product options.. , on Single product page.
Code works fine (in situation)- Say, If I have 2 variation attributes. That is size and color. So, if a user selects any option (attribute term) from size, but forgot to choose the one from the color, then he receives specific custom Alert, for not choosing the Color (as in below code). And vicversa, if he forgot to select option (attribute term) for size (but already selected the option from Color), then he receives a different custom Alert message (again, as in below code - 2nd Alert)
Code Not working (for this below situation)- Say, if user forgot or do Not select ANY of the Variation attribute. That is neither any attribute's term from size nor from a color option, then, how to update the code in a way, so as to Display some totally different Alert message.
Currently, what is happening is - If user do Not selects any of the option, neither from size and nor from color, then the first Alert message (that comes first in order - Top to bottom) shows automatically. Which as per my below code, is set for the Size attribute
This is a custom JS code-
jQuery(document).ready(function($){
$('.single_add_to_cart_button').click(function(e){
if ($('#pa_size').val() == "") {
e.preventDefault();
alert("Oh! You missed the option. Why not choose the one");
return false;
}
if ($('#pa_color').val() == "") {
e.preventDefault();
alert("You missed to choose the Color. Please select any one");
return false;
}
});
});
Question:
Regards