• The icon in the quantity background is not removed when the parameters are 0

    My code

    if ( defined( 'YITH_WCWL' ) && ! function_exists( 'yith_wcwl_get_items_count' ) ) {
      function yith_wcwl_get_items_count() {
        ob_start();
        ?>
          <a href="<?php echo esc_url( YITH_WCWL()->get_wishlist_url() ); ?>">
            </span>
            <span class="yith-wcwl-items-count">
              <?php $c = yith_wcwl_count_all_products(); 
              if($c != 0) {echo esc_html($c);} ?>
            </span>
          </a>    <?php
        return ob_get_clean();
      }
    
      add_shortcode( 'yith_wcwl_items_count', 'yith_wcwl_get_items_count' );
    }
    
    if ( defined( 'YITH_WCWL' ) && ! function_exists( 'yith_wcwl_ajax_update_count' ) ) {
      function yith_wcwl_ajax_update_count() {
        wp_send_json( array(
          'count' => yith_wcwl_count_all_products()
        ) );
      }
    
      add_action( 'wp_ajax_yith_wcwl_update_wishlist_count', 'yith_wcwl_ajax_update_count' );
      add_action( 'wp_ajax_nopriv_yith_wcwl_update_wishlist_count', 'yith_wcwl_ajax_update_count' );
    }
    
    if ( defined( 'YITH_WCWL' ) && ! function_exists( 'yith_wcwl_enqueue_custom_script' ) ) {
      function yith_wcwl_enqueue_custom_script() {
        wp_add_inline_script(
          'jquery-yith-wcwl',
          "
            jQuery( function( $ ) {
              $( document ).on( 'added_to_wishlist removed_from_wishlist', function() {
                $.get( yith_wcwl_l10n.ajax_url, {
                  action: 'yith_wcwl_update_wishlist_count'
                }, function( data ) {
                  $('.yith-wcwl-items-count').html(data.count == 0 ? '' : data.count);
                } );
              } );
            } );
          "
        );
      }
    
      add_action( 'wp_enqueue_scripts', 'yith_wcwl_enqueue_custom_script', 20 );
    }

    CSS:

    .yith-wcwl-items-count {
    	position: absolute;
    	top: -8px;
    	right: -10px;
    	font-size: 10px;
    	font-weight: 500;
    	color: white;
    	text-align: center;
    	line-height: 11px;
    	min-width: 18px;
    	height: 18px;
    	border-radius: 30px;
    	padding: 4px;
    	background-color: black;
    	display: inline-block;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Deleded coin’ is closed to new replies.