Skip to content

Instantly share code, notes, and snippets.

@malsubrata
Created October 2, 2018 07:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save malsubrata/2f857d4b8b04542f490162c54948f7b9 to your computer and use it in GitHub Desktop.
Save malsubrata/2f857d4b8b04542f490162c54948f7b9 to your computer and use it in GitHub Desktop.
Mini wallet shortcode
function woo_mini_wallet_callback() {
if (!function_exists('woo_wallet') || !is_user_logged_in()) {
return '';
}
ob_start();
$title = __('Current wallet balance', 'woo-wallet');
$mini_wallet = '<a class="woo-wallet-menu-contents" href="' . esc_url(wc_get_account_endpoint_url(get_option('woocommerce_woo_wallet_endpoint', 'woo-wallet'))) . '" title="' . $title . '">';
$mini_wallet .= '<span class="woo-wallet-icon-wallet"></span>';
$mini_wallet .= woo_wallet()->wallet->get_wallet_balance(get_current_user_id());
$mini_wallet .= '</a>';
echo $mini_wallet;
return ob_get_clean();
}
add_shortcode('woo-mini-wallet', 'woo_mini_wallet_callback');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment