Skip to content

Instantly share code, notes, and snippets.

@amielucha
Created May 2, 2018 15:39
Show Gist options
  • Select an option

  • Save amielucha/bc4099f78aa588b028ffdd4af90a43dd to your computer and use it in GitHub Desktop.

Select an option

Save amielucha/bc4099f78aa588b028ffdd4af90a43dd to your computer and use it in GitHub Desktop.
WooCommerce Login link action
<?php
function cs_login_link() {
// Bail early if we don't have WC.
if ( !function_exists('wc_get_cart_url') ) return;
$myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' );
$myaccount_page_url = $myaccount_page_id ? get_permalink( $myaccount_page_id ) : NULL;
if ( !$myaccount_page_url ) return;
echo '<a href="' . $myaccount_page_url . '">' . ( is_user_logged_in() ? 'Account' : 'Login' ) . '</a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment