• Below is the code in woocommerce functions.php
    I want to remove the text “item” without modify the origin file.

    if ( ! function_exists( 'woocommerce_header_add_to_cart_fragment' ) ) {
    	function woocommerce_header_add_to_cart_fragment( $fragments ) {
    		global $woocommerce;
    		$settings = array( 'header_cart_link' => 'false', 'nav_rss' => 'false', 'header_cart_total' => 'false' );
    		$settings = woo_get_dynamic_values( $settings );
    		ob_start();
    	?>
    		<a class="cart-contents" href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>">
    			<?php if ( $settings['header_cart_total'] == 'true' ) { echo sprintf(_n('<span class="count">%d</span> item', '<span class="count">%d</span> items', $woocommerce->cart->get_cart_contents_count(), 'woothemes'), $woocommerce->cart->get_cart_contents_count() );?> - <?php echo $woocommerce->cart->get_cart_subtotal(); } ?>
    		</a>
    	<?php
    
    		$fragments['a.cart-contents'] = ob_get_clean();
    
    		return $fragments;
    	} // End woocommerce_header_add_to_cart_fragment()
    }
Viewing 1 replies (of 1 total)
  • Thread Starter lukelee

    (@lukelee)

    I have tried add_filter, but it didn’t work, maybe my code wasn’t correct.
    Many thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘How to remove the text "item" in woocommerce mini cart?’ is closed to new replies.