Site logo

Archived topic

EDD Shop Icon

5 replies · Started by Halil on June 22, 2022

Viewing posts 1–6 of 6

Hi,
I've taken this PHP code below from one of the posts in the GP forum, it works perfectly: if cart is empty it doesnt show up, as soon as one item is added to chart, it shows up with the number of items in cart.

I'd like to modify it so that it does show up all the time, even with an empty chart. However I want it show only icon if there is no item in cart. I tried removing the if ( quantity ...) part, but it returns 0 next to icon (which is normal)


add_action( 'generate_menu_bar_items', function() {
	$cart_quantity = edd_get_cart_quantity();

	if ( ! $cart_quantity ) {
		return;
	}

	?>
	<a class="gp-cart-menu-item" title="Eğitimi Al" href="<?php echo edd_get_checkout_uri(); ?>"><?php generate_do_svg_icon( 'shopping-bag' ); ?> <span class="gp-cart-quantity edd-cart-quantity"><?php echo $cart_quantity; ?></span></a>
	<?php
} );

is it possible to get some help for this?

thanks

Hi there,

Can you give this a shot?

add_action( 'generate_menu_bar_items', function() {
    $cart_quantity = edd_get_cart_quantity();

    if ( ! $cart_quantity ) {
        ?>
	<a class="gp-cart-menu-item" title="Eğitimi Al" href="<?php echo edd_get_checkout_uri(); ?>"><?php generate_do_svg_icon( 'shopping-bag' ); ?></a>
	<?php
        return;
    }

    ?>
    <a class="gp-cart-menu-item" title="Eğitimi Al" href="<?php echo edd_get_checkout_uri(); ?>"><?php generate_do_svg_icon( 'shopping-bag' ); ?> <span class="gp-cart-quantity edd-cart-quantity"><?php echo $cart_quantity; ?></span></a>
    <?php
} );

hi Leo,
it shows double shopping bag icon with 0 next to icons when the cart is empty.

perfect! huge thanks Leo.

No problem :)

This archived topic is closed to new replies.