Mini Wallet Shortcode?
-
Hi,
Is there a shortcode for the mini wallet widget that we can opt to add to our menus?
-
I am afraid we don’t have any shortcode for mini wallet. But you can add mini wallet to your themes menu we have already have that feature. Please select menu location from WooWallet > settings > general.
Yes I know I can add it in theme menus
What I wished to do is add it in right corner of the Header of my website like this:
Woo Cart (BAL) | Account (Menu) | Wishlist | Cart
However being unable to add it to a custom menu is preventing me from doing this and all my menus are already being utilized.
I hope you understand.
Please use below code to get 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 .= 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');Thanks and Regards,
Subrata MalThanks, it works
How about the wallet icon?
Hello,
How exactly do you use this code for the mini-wallet?
Copy and paste the above code to activate themes function.php file. And use
[woo-mini-wallet]shortcode to any post or page content.Thank you for your answer, man. It works nicely.
However, same as @nostile’s question above, how about the mini wallet icon? Because the mini wallet shortcode only displays the amount of the current wallet balance, without the icon.
How do I add the wallet icon?
I wanted to add an icon to the shortcode. But doesn’t work. Please help me.
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 = ‘<i class=”fa fa-wallet”></i> ‘;
$mini_wallet .= ‘‘;
$mini_wallet .= woo_wallet()->wallet->get_wallet_balance(get_current_user_id());
$mini_wallet .= ‘‘;
echo $mini_wallet;
return ob_get_clean();
}Thanks bro working fine,
But the problem is its not showing icon of the mini wallet.
@bilal266,
Please use this updated code.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 .= '<img style="width:16px;height:16px;float:left;margin:4px;" src="' . WOO_WALLET_ICON . '" /> '; $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');Hi bro,
Thanks for replying, its working finw now.-
This reply was modified 7 years, 10 months ago by
bilal266.
Hi,
Which file do you edit to put this code? To have wallet close to Account-Shopping Cart?
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 = ‘‘;
$mini_wallet .= woo_wallet()->wallet->get_wallet_balance(get_current_user_id());
$mini_wallet .= ‘‘;
echo $mini_wallet;
return ob_get_clean();
}
add_shortcode(‘woo-mini-wallet’, ‘woo_mini_wallet_callback’);Thank you.
-
This reply was modified 7 years, 10 months ago by
The topic ‘Mini Wallet Shortcode?’ is closed to new replies.