Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

266
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda