Created
October 2, 2018 07:33
-
-
Save malsubrata/2f857d4b8b04542f490162c54948f7b9 to your computer and use it in GitHub Desktop.
Mini wallet shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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