Tagged: x
-
AuthorPosts
-
July 26, 2016 at 2:46 pm #1104050
AndreiParticipantHi,
I would like to remove the ‘ITEMS’ text from the cart menu in the top menu.
I would like it to look like in the attached image.
My website is //sinestezic.com.
Thank you.
July 26, 2016 at 10:05 pm #1104541
Prasant RaiModeratorHello There,
Thanks for writing in!
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.
Then add following code in child theme function.php file:
/** * Filter to remove the word 'item'/'items' from WP Menu Cart */ add_filter( 'wpmenucart_menu_item_a_content', 'wpmenucart_remove_items_caption', 10, 1 ); function wpmenucart_remove_items_caption($menu_item_a_content) { global $wpMenuCart; $item_data = $wpMenuCart->shop->menu_item(); $item_text = sprintf(_n('%d item', '%d items', $item_data['cart_contents_count'], 'wpmenucart'), $item_data['cart_contents_count']); $menu_item_a_content = str_replace( $item_text, $item_data['cart_contents_count'], $menu_item_a_content); return $menu_item_a_content; }Thanks.
July 28, 2016 at 3:00 am #1106695
AndreiParticipantThank you for your reply. I added it in the child theme’s functions.php and it doesn’t work.
July 28, 2016 at 3:15 am #1106714
RadModeratorHi there,
Would you mind providing your admin and FTP login credentials in private reply? I like to conduct some test.
For the meantime, please try this
/** * Filter to remove the word 'item'/'items' from WP Menu Cart */ add_filter( 'wpmenucart_menu_item_a_content', 'wpmenucart_remove_items_caption', 10, 1 ); function wpmenucart_remove_items_caption($menu_item_a_content) { global $wpMenuCart; $item_data = $wpMenuCart->shop->menu_item(); $item_text = sprintf(_n('%d', '%d', $item_data['cart_contents_count'], 'wpmenucart'), $item_data['cart_contents_count']); $menu_item_a_content = str_replace( $item_text, $item_data['cart_contents_count'], $menu_item_a_content); return $menu_item_a_content; }Thanks!
July 28, 2016 at 3:33 am #1106738
AndreiParticipantThis reply has been marked as private.July 28, 2016 at 5:42 am #1106900
Rue NelModeratorHello There,
Thanks for providing the information. Please use this code instead:
// Remove "item" text in the cart menu // ============================================================================= function x_woocommerce_navbar_cart() { $cart_info = x_get_option( 'x_woocommerce_header_cart_info' ); $cart_layout = x_get_option( 'x_woocommerce_header_cart_layout' ); $cart_style = x_get_option( 'x_woocommerce_header_cart_style' ); $cart_outer = x_get_option( 'x_woocommerce_header_cart_content_outer' ); $cart_inner = x_get_option( 'x_woocommerce_header_cart_content_inner' ); $data = array( 'icon' => '<i class="x-icon-shopping-cart" data-x-icon="" aria-hidden="true"></i>', 'total' => WC()->cart->get_cart_total(), 'count' => sprintf( _n( '%d', '%d', WC()->cart->cart_contents_count, '__x__' ), WC()->cart->cart_contents_count ) ); $modifiers = array( $cart_info, strpos( $cart_info, '-' ) === false ? 'inline' : $cart_layout, $cart_style ); $cart_output = '<div class="x-cart ' . implode( ' ', $modifiers ) . '">'; foreach ( explode( '-', $cart_info ) as $info ) { $key = ( $info == 'outer' ) ? $cart_outer : $cart_inner; $cart_output .= '<span class="' . $info . '">' . $data[$key] . '</span>'; } $cart_output .= '</div>'; return $cart_output; } // =============================================================================And before testing your site, you must clear your browser’s cache. It is best that you use Chrome’s incognito mode or private browsing mode in other browser when testing your site.
Hope this helps.
July 28, 2016 at 6:54 am #1106957
AndreiParticipantIt worked! Thank you very much! You are the best!
July 28, 2016 at 8:30 am #1107061
JoaoModeratorGlad to hear it,
Let us know if you need further help.
Joao
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1104050 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
