Site logo

Archived topic

Insert cart icon EDD top menu theme generatepress

4 replies · Started by Gerva on September 24, 2021

Viewing posts 1–5 of 5

Good morning,
I have used the hook proposed by Tom Hook Tom and it works ok.

add_action( 'generate_inside_navigation', 'tu_add_edd_cart_to_nav' );
function tu_add_edd_cart_to_nav() {
	if ( ! function_exists( 'edd_get_checkout_uri' ) ) {
		return;
	}
	?>
	<a class="edd-cart" href="<?php echo edd_get_checkout_uri(); ?>">
		Cassa (<span class="header-cart edd-cart-quantity"><?php echo edd_get_cart_quantity(); ?></span>)
	</a>

The problem is that the label appears at the before menu primary ... I would like to place it at the end menu (see images).
menu cart

I partially solved the problem by using elements/hooks -> generate_after_navigation
But I still have problems
- it doesn't refresh on the checkout page
- the php code doesn't work

<?php
add_action( 'generate_inside_navigation', 'tu_add_edd_cart_to_nav' );
function tu_add_edd_cart_to_nav() {
	if ( ! function_exists( 'edd_get_checkout_uri' ) ) {
		return;
	}
	?>
	<a id="cart-menu-item" class="dashicons-before dashicons-cart" href="<?php echo edd_get_checkout_uri(); ?>">
		<span id="header-cart" class="edd-cart-quantity"><?php echo edd_get_cart_quantity(); ?></span>
	</a>
	<?php
}
?>

I've put the two versions together, Tom's "simple" version works, but mine does! I'm not Tom ;-)

I'm sorry but I'm not a php expert. Sorry.
Thanks for your help

Hi Gerva,

Can you keep Tom's code only and add this CSS:

div#primary-menu {
    order: 2;
}
a#cart-menu-item {
    order: 3;
}

Let me know :)

fantastic
thank you very much

You are welcome :)

This archived topic is closed to new replies.