Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
Customized Woocommerce Alert for Multiple Variations: Please select some product options... Working Partially except 1 situation

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:

  1. Can you please suggest what is additionally required in order to show some other message (totally different), if user do NOT selects any of the available options from any of the attributes. That is, neither size nor color.
  2. Also, can someone please provide the similar Custom PHP snippet instead of JS code. That works for above requirement. As I prefer to use the PHP snippet

Regards

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!