如何删除购物车woocommerce中的项目词?

时间:2018-09-24 13:29:23

标签: wordpress function woocommerce

如何删除购物车woocommerce中的商品词?

查看屏幕截图:WooCommerce Mini Cart header.php

在fuctions.php中

购物车片段:

if ( ! function_exists( 'agricola_woocommerce_cart_link_fragment' ) ) {
function agricola_woocommerce_cart_link_fragment( $fragments ) {
    ob_start();
    agricola_woocommerce_cart_link();
    $fragments['a.cart-contents'] = ob_get_clean();

    return $fragments;
}
}
add_filter( 'woocommerce_add_to_cart_fragments', 
'agricola_woocommerce_cart_link_fragment' );

购物车链接

if ( ! function_exists( 'agricola_woocommerce_cart_link' ) ) {
function agricola_woocommerce_cart_link() {
    ?>
    <a class="cart-contents" href="<?php echo esc_url( wc_get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'agricola' ); ?>">
        <?php
        $item_count_text = sprintf(
            /* translators: number of items in the mini cart. */
            _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'agricola' ),
            WC()->cart->get_cart_contents_count()
        );
        ?>
        <span class="amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> <span class="count"><?php echo esc_html( $item_count_text ); ?></span>
    </a>
    <?php
}
}

显示标题购物车。

if ( ! function_exists( 'agricola_woocommerce_header_cart' ) ) {
function agricola_woocommerce_header_cart() {
    if ( is_cart() ) {
        $class = 'current-menu-item';
    } else {
        $class = '';
    }
    ?>
    <ul id="site-header-cart" class="site-header-cart">
        <li class="<?php echo esc_attr( $class ); ?>">
            <?php agricola_woocommerce_cart_link(); ?>
        </li>
        <li>
            <?php
            $instance = array(
                'title' => '',
            );

            the_widget( 'WC_Widget_Cart', $instance );
            ?>
        </li>
    </ul>
    <?php
}
}

我已经删除了<?php $item_count_text = sprintf( /* translators: number of items in the mini cart. */ _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'agricola' ), WC()->cart->get_cart_contents_count()); ?>,但想回来的标题是“ 9个项目”,我想将其隐藏。

我只想要带有价格成本的购物篮图标。

1 个答案:

答案 0 :(得分:0)

您可以使用CSS隐藏该特定部分。如果您可以提供网站链接,我们可以为您提供CSS帮助。 或者,您可以使用String Locator插件来定位代码在文件中的写入位置,然后可以对其进行注释或将其从文件本身中删除。 谢谢