Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda