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

201
Visualizações
How to apply woocommerce "place order" limit for a specific product per month

I want to set a limit on the number of orders a customer can send to a specific product per month on WooCommerce. The scenario is: I have a variable product, one feature is free and three features are paid. I want to limit its free feature. So that each user (guest or registered) can not place free orders more than 5 times per month. And when it exceeds the monthly limit, it will show him a message on the checkout page that he can not order the free product and must wait until next month or order the paid product. I found the following code but I think it is incomplete.

add_filter('woocommerce_is_purchasable', 'preventPurchaseIfOrderLimitReached', 10, 2);

function preventPurchaseIfOrderLimitReached($is_purchasable, $product)
{
    $OrderLimit = 5;
    $productId = $product->get_id();
    $quantityOrderedToday = getOrderAmount($productId);

    if ($quantityOrdered >= $OrderLimit) {
        $is_purchasable = false;
    }

    return $is_purchasable;
}

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