Site logo

Archived topic

Shopping Cart Icon in Secondary Menu

9 replies · Started by antware on August 2, 2017

Viewing posts 1–10 of 10

Is it possible to place the Shopping Cart Icon in Secondary Menu instead of the Primary menu. Thanks guys.

Hi there,

Are you using either navigation search or sticky navigation in the primary menu?

If not it's probably either to just switch the primary and secondary as they have basically the same options.

If not we might have to use the generate_inside_secondary_navigation hook: https://docs.generatepress.com/article/generate_inside_secondary_navigation/

Will ask Tom to confirm :)

Hi, did anyone resolve the issue of moving/adding the Cart icon to the secondary menu? I've tried swapping the primary and secondary menus but the automated 'Display cart in menu' remains in the primary (lower) bar.
I can use a Font Awesome icon. However, you don't get the benefit of seeing the running total beside the icon?

I've just added a filter to the location for the next GPP version.

For now, you could do this:

add_filter( 'wp_nav_menu_items', 'tu_secondary_wc_menu_cart', 10, 2 );
function tu_secondary_wc_menu_cart( $nav, $args ) {
	// If our primary menu is set, add the search icon
	if ( $args->theme_location == 'secondary' && function_exists( 'generatepress_wc_cart_link' ) ) {
		return sprintf( 
			'%1$s 
			<li class="wc-menu-item %4$s" title="%2$s">
				%3$s
			</li>',
			$nav,
			esc_attr__( 'View your shopping cart','generate-woocommerce' ),
			generatepress_wc_cart_link(),
			is_cart() ? 'current-menu-item' : ''
		);
	}
	
	// Our primary menu isn't set, return the regular nav
    return $nav;
}

Brilliant as always Tom.

Many thanks.

J

You're welcome :)

Hi.

Is this post still up to date or is there a "better" solution for this inquiry?

Best regards.

Hi David.

Thank you very much. :)

Best regards.

You're welcome

This archived topic is closed to new replies.