Skip to content

Instantly share code, notes, and snippets.

@jameskoster
Last active January 19, 2017 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jameskoster/1730006 to your computer and use it in GitHub Desktop.
Save jameskoster/1730006 to your computer and use it in GitHub Desktop.
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
Copy link

Add if you want to use in your templates

@yratof
Copy link

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