Files
wordpress-theme-aksrt/inc/helpers/user-center-renderers/sidebar-commerce.php
T

44 lines
1.6 KiB
PHP

<?php
/**
* User center sidebar: balance and points pair.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$show_wallet = !empty($balance_enabled);
$show_credits = !empty($credits_enabled) || !empty($show_credit_tabs);
if (!$show_wallet && !$show_credits) {
return;
}
$assets_url = aksrt_get_user_center_tab_url('credits');
try {
$wallet = \AKSRT\Ledger\AssetAmount::balance(is_string($wallet_balance ?? null) ? $wallet_balance : '')->formatted();
} catch (\InvalidArgumentException $e) {
$wallet = '0.00';
}
$points = max(0, (int) ($credit_balance ?? 0));
?>
<div class="uc-sidebar__pair uc-sidebar__pair--assets">
<?php if ($show_wallet) : ?>
<a class="uc-summary-card uc-summary-card--wallet" href="<?php echo esc_url($assets_url); ?>" data-tab="credits">
<span class="uc-summary-card__head"><?php esc_html_e('账户余额', 'aksrt'); ?><i class="fa fas fa-angle-right" aria-hidden="true"></i></span>
<span class="uc-summary-card__body">
<strong><?php echo esc_html($wallet); ?></strong>
<i class="fa fas fa-money-bill" aria-hidden="true"></i>
</span>
</a>
<?php endif; ?>
<?php if ($show_credits) : ?>
<a class="uc-summary-card uc-summary-card--points" href="<?php echo esc_url($assets_url); ?>" data-tab="credits">
<span class="uc-summary-card__head"><?php echo esc_html((string) ($currency_name ?? __('积分', 'aksrt'))); ?><i class="fa fas fa-angle-right" aria-hidden="true"></i></span>
<span class="uc-summary-card__body">
<strong><?php echo esc_html(aksrt_format_points($points)); ?></strong>
<i class="fa fas fa-money-bill" aria-hidden="true"></i>
</span>
</a>
<?php endif; ?>
</div>