Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 隐藏购物车Wordpress上的计数器_Php_Wordpress_Woocommerce_Wordpress Theming_Cart - Fatal编程技术网

Php 隐藏购物车Wordpress上的计数器

Php 隐藏购物车Wordpress上的计数器,php,wordpress,woocommerce,wordpress-theming,cart,Php,Wordpress,Woocommerce,Wordpress Theming,Cart,当购物车为空时,如何隐藏计数器?Wordpress-woocommerce-supro主题 <a href="<?php echo esc_url( wc_get_cart_url() ) ?>" class="cart-contents" id="icon-cart-contents"> <?php echo wp_kses_post( $icon_cart ); ?> <span class="label-item c

当购物车为空时,如何隐藏计数器?Wordpress-woocommerce-supro主题

<a href="<?php echo esc_url( wc_get_cart_url() ) ?>" class="cart-contents" id="icon-cart-contents">
        <?php echo wp_kses_post( $icon_cart ); ?>
        <span class="label-item cart-label"><?php echo wp_kses( $cart_html, wp_kses_allowed_html( 'post' ) ); ?></span>
        <span class="mini-cart-counter"><?php echo intval( $woocommerce->cart->cart_contents_count ); ?></span>
    </a>


Tnx

更新:在子主题的函数中添加此代码。php

add_action( 'wp_head', 'x_hide_cart' );
function x_hide_cart(){
    if ( WC()->cart->get_cart_contents_count() == 0 ) {
        ?>
        <style type="text/css">.x-menu-item-woocommerce{display: none;}</style>
        <?php
    }
}
add_action('wp_head','x_hide_cart');
函数x_hide_cart(){
如果(WC()->cart->get\u cart\u contents\u count()==0){
?>
.x-menu-item-woocommerce{display:none;}

我是否需要更改代码的任何部分,因为不工作…?您是否在子主题中编辑过?并且您没有更改项目的类别?