0100
  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Agotado</span>';
      echo $showText;
    }
    
    if ($product->is_on_sale()){
    
      if ( $product->get_type() == 'variable' ) {
        $vars = $product->get_available_variations();
    
        $var_cero = $vars[0]['variation_id'];
        $variable_product = wc_get_product($var_cero);
        $regular_price = $variable_product->get_regular_price();
        $sale_price = $variable_product->get_sale_price();
        if($sale_price){
          $percent_max=round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
        }else{
          $percent_max=0;
        }
    
        $cont_percent=0;
        foreach ($vars as $varID) {
          $variable_product = wc_get_product($varID['variation_id']);
          $regular_price = $variable_product->get_regular_price();
          $sale_price = $variable_product->get_sale_price();
          if($sale_price){
            $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
          }else{
            $percent=0;
          }
    
          if($percent_max!=$percent){
            if($percent_max>$percent){
              $percent_max=$percent_max;
            }else{
              $percent_max=$percent;
            }			 
          }else{
            $cont_percent++;
          }
    
          #echo $regular_price." - ".$sale_price."%".$percent_max."<br>";
    
        }
    
        if($cont_percent==count($vars)){
          $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent_max. '%</span>';
        }else{
          $showText = '<span class="onsale">'. __('Hasta -', 'woocommerce' ). $percent_max. '%</span>';
        }
    
      }
      else{
        $regular_price = $product->regular_price;
        $sale_price = $product->sale_price;
        $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
        $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent . '%</span>';
      }
    
      echo $showText;
    }
    
    ?>
  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Agotado</span>';
      echo $showText;
    }
    
    if ($product->is_on_sale()){
    
      if ( $product->get_type() == 'variable' ) {
        $vars = $product->get_available_variations();
    
        $var_cero = $vars[0]['variation_id'];
        $variable_product = wc_get_product($var_cero);
        $regular_price = $variable_product->get_regular_price();
        $sale_price = $variable_product->get_sale_price();
        if($sale_price){
          $percent_max=round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
        }else{
          $percent_max=0;
        }
    
        $cont_percent=0;
        foreach ($vars as $varID) {
          $variable_product = wc_get_product($varID['variation_id']);
          $regular_price = $variable_product->get_regular_price();
          $sale_price = $variable_product->get_sale_price();
          if($sale_price){
            $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
          }else{
            $percent=0;
          }
    
          if($percent_max!=$percent){
            if($percent_max>$percent){
              $percent_max=$percent_max;
            }else{
              $percent_max=$percent;
            }			 
          }else{
            $cont_percent++;
          }
    
          #echo $regular_price." - ".$sale_price."%".$percent_max."<br>";
    
        }
    
        if($cont_percent==count($vars)){
          $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent_max. '%</span>';
        }else{
          $showText = '<span class="onsale">'. __('Hasta -', 'woocommerce' ). $percent_max. '%</span>';
        }
    
      }
      else{
        $regular_price = $product->regular_price;
        $sale_price = $product->sale_price;
        $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
        $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent . '%</span>';
      }
    
      echo $showText;
    }
    
    ?>
  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Agotado</span>';
      echo $showText;
    }
    
    if ($product->is_on_sale()){
    
      if ( $product->get_type() == 'variable' ) {
        $vars = $product->get_available_variations();
    
        $var_cero = $vars[0]['variation_id'];
        $variable_product = wc_get_product($var_cero);
        $regular_price = $variable_product->get_regular_price();
        $sale_price = $variable_product->get_sale_price();
        if($sale_price){
          $percent_max=round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
        }else{
          $percent_max=0;
        }
    
        $cont_percent=0;
        foreach ($vars as $varID) {
          $variable_product = wc_get_product($varID['variation_id']);
          $regular_price = $variable_product->get_regular_price();
          $sale_price = $variable_product->get_sale_price();
          if($sale_price){
            $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
          }else{
            $percent=0;
          }
    
          if($percent_max!=$percent){
            if($percent_max>$percent){
              $percent_max=$percent_max;
            }else{
              $percent_max=$percent;
            }			 
          }else{
            $cont_percent++;
          }
    
          #echo $regular_price." - ".$sale_price."%".$percent_max."<br>";
    
        }
    
        if($cont_percent==count($vars)){
          $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent_max. '%</span>';
        }else{
          $showText = '<span class="onsale">'. __('Hasta -', 'woocommerce' ). $percent_max. '%</span>';
        }
    
      }
      else{
        $regular_price = $product->regular_price;
        $sale_price = $product->sale_price;
        $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
        $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent . '%</span>';
      }
    
      echo $showText;
    }
    
    ?>
  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Agotado</span>';
      echo $showText;
    }
    
    if ($product->is_on_sale()){
    
      if ( $product->get_type() == 'variable' ) {
        $vars = $product->get_available_variations();
    
        $var_cero = $vars[0]['variation_id'];
        $variable_product = wc_get_product($var_cero);
        $regular_price = $variable_product->get_regular_price();
        $sale_price = $variable_product->get_sale_price();
        if($sale_price){
          $percent_max=round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
        }else{
          $percent_max=0;
        }
    
        $cont_percent=0;
        foreach ($vars as $varID) {
          $variable_product = wc_get_product($varID['variation_id']);
          $regular_price = $variable_product->get_regular_price();
          $sale_price = $variable_product->get_sale_price();
          if($sale_price){
            $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
          }else{
            $percent=0;
          }
    
          if($percent_max!=$percent){
            if($percent_max>$percent){
              $percent_max=$percent_max;
            }else{
              $percent_max=$percent;
            }			 
          }else{
            $cont_percent++;
          }
    
          #echo $regular_price." - ".$sale_price."%".$percent_max."<br>";
    
        }
    
        if($cont_percent==count($vars)){
          $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent_max. '%</span>';
        }else{
          $showText = '<span class="onsale">'. __('Hasta -', 'woocommerce' ). $percent_max. '%</span>';
        }
    
      }
      else{
        $regular_price = $product->regular_price;
        $sale_price = $product->sale_price;
        $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
        $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent . '%</span>';
      }
    
      echo $showText;
    }
    
    ?>

    The Dailt Dose

  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Agotado</span>';
      echo $showText;
    }
    
    if ($product->is_on_sale()){
    
      if ( $product->get_type() == 'variable' ) {
        $vars = $product->get_available_variations();
    
        $var_cero = $vars[0]['variation_id'];
        $variable_product = wc_get_product($var_cero);
        $regular_price = $variable_product->get_regular_price();
        $sale_price = $variable_product->get_sale_price();
        if($sale_price){
          $percent_max=round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
        }else{
          $percent_max=0;
        }
    
        $cont_percent=0;
        foreach ($vars as $varID) {
          $variable_product = wc_get_product($varID['variation_id']);
          $regular_price = $variable_product->get_regular_price();
          $sale_price = $variable_product->get_sale_price();
          if($sale_price){
            $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
          }else{
            $percent=0;
          }
    
          if($percent_max!=$percent){
            if($percent_max>$percent){
              $percent_max=$percent_max;
            }else{
              $percent_max=$percent;
            }			 
          }else{
            $cont_percent++;
          }
    
          #echo $regular_price." - ".$sale_price."%".$percent_max."<br>";
    
        }
    
        if($cont_percent==count($vars)){
          $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent_max. '%</span>';
        }else{
          $showText = '<span class="onsale">'. __('Hasta -', 'woocommerce' ). $percent_max. '%</span>';
        }
    
      }
      else{
        $regular_price = $product->regular_price;
        $sale_price = $product->sale_price;
        $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
        $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent . '%</span>';
      }
    
      echo $showText;
    }
    
    ?>

    The Vital Buzz

  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Agotado</span>';
      echo $showText;
    }
    
    if ($product->is_on_sale()){
    
      if ( $product->get_type() == 'variable' ) {
        $vars = $product->get_available_variations();
    
        $var_cero = $vars[0]['variation_id'];
        $variable_product = wc_get_product($var_cero);
        $regular_price = $variable_product->get_regular_price();
        $sale_price = $variable_product->get_sale_price();
        if($sale_price){
          $percent_max=round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
        }else{
          $percent_max=0;
        }
    
        $cont_percent=0;
        foreach ($vars as $varID) {
          $variable_product = wc_get_product($varID['variation_id']);
          $regular_price = $variable_product->get_regular_price();
          $sale_price = $variable_product->get_sale_price();
          if($sale_price){
            $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
          }else{
            $percent=0;
          }
    
          if($percent_max!=$percent){
            if($percent_max>$percent){
              $percent_max=$percent_max;
            }else{
              $percent_max=$percent;
            }			 
          }else{
            $cont_percent++;
          }
    
          #echo $regular_price." - ".$sale_price."%".$percent_max."<br>";
    
        }
    
        if($cont_percent==count($vars)){
          $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent_max. '%</span>';
        }else{
          $showText = '<span class="onsale">'. __('Hasta -', 'woocommerce' ). $percent_max. '%</span>';
        }
    
      }
      else{
        $regular_price = $product->regular_price;
        $sale_price = $product->sale_price;
        $percent = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
        $showText = '<span class="onsale">'. __('-', 'woocommerce' ). $percent . '%</span>';
      }
    
      echo $showText;
    }
    
    ?>

    Golden Pulse

  •     <script type="text/javascript">
            function initializeQuantityInputs() {
                var quantityInputs = document.querySelectorAll('input.qty');
    
                quantityInputs.forEach(function(input) {
                    input.removeEventListener('input', handleInput);
                    removeError(input);
                });
    
                quantityInputs.forEach(function(input) {
                    var maxStock = parseFloat(input.getAttribute('data-max-stock'));
                    var addToCartButton = input.closest('.product').querySelector('.add_to_cart_button');
    
                    function handleInput() {
                        var currentQuantity = parseFloat(input.value);
    
                        if (currentQuantity > maxStock) {
                            showError(input, 'Stock up to ' + maxStock);
                            input.value = maxStock;
                            addToCartButton.dataset.quantity = maxStock;
    
                            // Ocultar el mensaje de error después de 3 segundos
                            setTimeout(function() {
                                removeError(input);
                            }, 3000);
                        } else {
                            removeError(input);
                            addToCartButton.dataset.quantity = currentQuantity;
                        }
                    }
    
                    input.addEventListener('input', handleInput);
                });
            }
    
            function showError(input, message) {
                var errorElement = document.createElement('span');
                errorElement.className = 'error-message';
                errorElement.textContent = message;
    
                var container = input.closest('.quantity');
                container.appendChild(errorElement);
            }
    
            function removeError(input) {
                var container = input.closest('.quantity');
                var errorElement = container.querySelector('.error-message');
                if (errorElement) {
                    container.removeChild(errorElement);
                }
            }
    
            function initializeQuantityButtons() {
                var plusButtons = document.querySelectorAll('.plus');
                var minusButtons = document.querySelectorAll('.minus');
                var quantityInputs = document.querySelectorAll('.quantity input.qty');
    
                plusButtons.forEach(function(plusButton) {
                    plusButton.removeEventListener('click', handleQuantityChange);
                    plusButton.addEventListener('click', handleQuantityChange);
                });
    
                minusButtons.forEach(function(minusButton) {
                    minusButton.removeEventListener('click', handleQuantityChange);
                    minusButton.addEventListener('click', handleQuantityChange);
                });
    
                quantityInputs.forEach(function(quantityInput) {
                    quantityInput.removeEventListener('input', handleInput);
                    quantityInput.addEventListener('input', handleInput);
                });
            }
    
            function handleQuantityChange(event) {
                var button = event.target;
                var isIncrease = button.classList.contains('plus');
    
                var quantityInput = button.closest('.quantity').querySelector('input.qty');
                var currentVal = parseFloat(quantityInput.value);
                var maxVal = parseFloat(quantityInput.getAttribute('max'));
                var minVal = parseFloat(quantityInput.getAttribute('min'));
                var step = parseFloat(quantityInput.getAttribute('step'));
    
                var newVal = currentVal;
                if (isIncrease) {
                    if (maxVal && currentVal >= maxVal) {
                        newVal = maxVal;
                    } else {
                        newVal = currentVal + step;
                    }
                } else {
                    if (minVal && currentVal <= minVal) {
                        newVal = minVal;
                    } else if (currentVal > 0) {
                        newVal = currentVal - step;
                    }
                }
    
                quantityInput.value = newVal;
                quantityInput.dispatchEvent(new Event('change'));
    
                var addToCartButton = button.closest('.product').querySelector('.add_to_cart_button');
                addToCartButton.dataset.quantity = newVal;
            }
    
            function handleInput(event) {
                var quantityInput = event.target;
                var addToCartButton = quantityInput.closest('.product').querySelector('.add_to_cart_button');
                var inputValue = quantityInput.value.trim();
    
                if (inputValue === '') {
                    quantityInput.value = '1';
                    inputValue = '1';
                }
    
                addToCartButton.dataset.quantity = inputValue;
            }
    
            document.addEventListener('DOMContentLoaded', function() {
                initializeQuantityInputs();
                initializeQuantityButtons();
            });
    
            var parentElement = document.querySelector('.fb-woo-archive-two__grid');
            var observer = new MutationObserver(function(mutationsList) {
                for (var i = 0; i < mutationsList.length; i++) {
                    var mutation = mutationsList[i];
                    if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                        initializeQuantityInputs();
                        initializeQuantityButtons();
                        break;
                    }
                }
            });
    
            observer.observe(parentElement, { childList: true });
        </script>