G
G
German Zuiakov2020-11-18 22:53:24
WordPress
German Zuiakov, 2020-11-18 22:53:24

Why doesn't the favicon change?

Wrote this code:

add_shortcode ('woo_fav_counter', 'woo_fav_counter' );
function woo_fav_counter() {
  ob_start();
 	global $woocommerce;
  $cart_count = $woocommerce->cart->cart_contents_count; // Set variable for cart item count

  ?>
  
  <?php
    if ( $woocommerce->cart->cart_contents_count <= 0 ) {
  ?>
    <link rel="icon" href="https://docti-posture.com/wp-content/uploads/2020/09/cropped-favicon-32x32.png" type="image/x-icon">
  <?php
  }
  else if  ( $woocommerce->cart->cart_contents_count == 1 ) {
  ?>
    <link rel="icon"  href="https://wmpics.pics/di-A33W.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count == 2 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-4UZ5.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count == 3 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-DGVGA.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count == 4 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-V3ZP.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count == 5 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-KW6U8.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count == 6 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-VL5Q.png" type="image/x-icon">
  <?php
  } 
  else if ( $woocommerce->cart->cart_contents_count == 7 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-PP46.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count == 8 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-SAY9.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count == 9 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-9OXOJ.png" type="image/x-icon">
  <?php
  }
  else if ( $woocommerce->cart->cart_contents_count >= 10 ) {
  ?>
    	<link rel="icon"  href="https://wmpics.pics/di-987A.png" type="image/x-icon">
  <?php
  }
  ?>


  
  <?php
          
    return ob_get_clean();
 
}


to change the favicon, depending on the number of goods in the cart, the link to the favicon changes in the code, but still all the time with one product. What is the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question