Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce - Checkout link (when cart is not empty)
global $woocommerce;
if ( sizeof( $woocommerce->cart->cart_contents) > 0 ) :
echo '<a href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __( 'Checkout' ) . '">' . __( 'Checkout' ) . '</a>';
endif;
@henrywright

This comment has been minimized.

Copy link

@henrywright henrywright commented Aug 29, 2012

Add if you want to use in your templates

@yratof

This comment has been minimized.

Copy link

@yratof yratof commented Mar 24, 2015

The closing Anchor is missing a final quote

    <?php global $woocommerce; if ( sizeof( $woocommerce->cart->cart_contents) > 0 ) :
        echo '<a href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __( 'Checkout' ) . '">' . __( 'Checkout' ) . '</a>';
    endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment