Special Size

<?php
function count_term_use () {
 $term_id = BricksQuery::get_loop_object_id();
$my_posts = get_posts(array(
  'post_type' => 'product', //post type
  'numberposts' => -1,
  'tax_query' => array(
    array(
      'taxonomy' => 'product_cat', //taxonomy name
      'field' => 'id', //field to get
      'terms' => $term_id, //term id
    )
  )
));
   return $count = count($my_posts);
}


function type_post(){
	if(is_front_page() || !is_singular()){
		return "true";
	}
}

?>

Special Size

  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Out of stock</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">'. __('Up to -', '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;
    }
    
    ?>
    Every Day Pack Boxer Special size 4 pieces
  • <?php
    
    global $product;
    
    if (!$product->is_in_stock()) {
      $showText = '<span class="out">Out of stock</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">'. __('Up to -', '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;
    }
    
    ?>
    Boxer Special size 2 pieces
    <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>
<script>
  /*Source: https://github.com/Krzysztof-Antosik/Two-direction-Sticky-Sidebar*/
  
  // Verificar el ancho de pantalla al cargar y redimensionar
  function checkScreenWidth() {
    if (window.innerWidth <= 767) {
      // Si la pantalla es menor o igual a 676px, no ejecutar el código
      return;
    }

    const stickyElement = document.querySelector('.fb-sidebar__aside');
    const startPosition = stickyElement.getBoundingClientRect().top;

    let endScroll = window.innerHeight - stickyElement.offsetHeight - 500;
    let currPos = window.scrollY;
    let screenHeight = window.innerHeight;
    let stickyElementHeight = stickyElement.offsetHeight;
    let topGap = 40;
    let bottomGap = 40;

    setTimeout(() => {
      if (stickyElement.hasAttribute('data-top-gap')) {
        const dataTopGap = stickyElement.getAttribute('data-top-gap');
        topGap = dataTopGap === 'auto' ? startPosition : parseInt(dataTopGap);
      }

      if (stickyElement.hasAttribute('data-bottom-gap')) {
        bottomGap = parseInt(stickyElement.getAttribute('data-bottom-gap'));
      }
    }, 100);

    stickyElement.style.position = 'sticky';
    stickyElement.style.top = `${topGap}px`;
    stickyElement.style.height = 'fit-content';

    function positionStickySidebar() {
      endScroll = window.innerHeight - stickyElement.offsetHeight - bottomGap;
      const stickyElementTop = parseInt(stickyElement.style.top.replace('px', ''));

      if (stickyElementHeight + topGap + bottomGap > screenHeight) {
        if (window.scrollY < currPos) {
          if (stickyElementTop < topGap) {
            stickyElement.style.top = `${stickyElementTop + currPos - window.scrollY}px`;
          } else if (stickyElementTop >= topGap && stickyElementTop !== topGap) {
            stickyElement.style.top = `${topGap}px`;
          }
        } else {
          if (stickyElementTop > endScroll) {
            stickyElement.style.top = `${stickyElementTop + currPos - window.scrollY}px`;
          } else if (stickyElementTop < endScroll && stickyElementTop !== endScroll) {
            stickyElement.style.top = `${endScroll}px`;
          }
        }
      } else {
        stickyElement.style.top = `${topGap}px`;
      }
      currPos = window.scrollY;
    }

    function stickyElementToMe() {
      stickyElement.style.top = `${topGap}px`;
    }

    function updateSticky() {
      screenHeight = window.innerHeight;
      stickyElementHeight = stickyElement.offsetHeight;
      positionStickySidebar();
    }

    setTimeout(() => {
      window.addEventListener('resize', () => {
        currPos = window.scrollY;
        updateSticky();
      });

      document.addEventListener('scroll', updateSticky, {
        capture: true,
        passive: true
      });
    }, 1000);
  }

  // Verificar el ancho de pantalla al cargar y redimensionar
  window.addEventListener('load', checkScreenWidth);
  window.addEventListener('resize', checkScreenWidth);
</script>