feat(pay): VIP renew discount tiers and upgrade package pricing
Apply vip_renew discount/reduce to same-level packages, gate renew/upgrade availability, support dedicated vip_upgrade_product line, and show tags/CTAs.
This commit is contained in:
1 parent
d0b8f7805f
commit
ba6ae854f8
3 files changed
+346
-40
No files matched your search
@@ -39,10 +39,14 @@ if ($vip_level >= 1 && !empty($vip_settings['levels'][$vip_level]['name'])) {
|
||||
}
|
||||
|
||||
$packages = [];
|
||||
$renew_desc = '';
|
||||
$upgrade_desc = '';
|
||||
if (class_exists('AKSRT_Vip_Service')) {
|
||||
$catalog = AKSRT_Vip_Service::get_instance()->get_catalog($user_id);
|
||||
$packages = is_array($catalog['level_packages'] ?? null) ? $catalog['level_packages'] : [];
|
||||
$methods = is_array($catalog['payment_methods'] ?? null) ? $catalog['payment_methods'] : [];
|
||||
$renew_desc = (string) ($catalog['renew_desc'] ?? '');
|
||||
$upgrade_desc = (string) ($catalog['upgrade_desc'] ?? '');
|
||||
} else {
|
||||
$methods = [['id' => 'balance', 'name' => __('站内余额', 'aksrt')]];
|
||||
}
|
||||
@@ -52,6 +56,11 @@ if (class_exists('AKSRT_Settings')) {
|
||||
$paid_display = AKSRT_Settings::get_paid_content_settings();
|
||||
$cash_symbol = (string) ($paid_display['display']['currency_symbol'] ?? '¥');
|
||||
}
|
||||
|
||||
$shop_title = __('开通会员', 'aksrt');
|
||||
if ($vip_level > 0) {
|
||||
$shop_title = __('续费 / 升级会员', 'aksrt');
|
||||
}
|
||||
?>
|
||||
<div class="uc-vip-card<?php echo $is_vip_user ? ' uc-vip-card--active' : ''; ?>" data-aksrt-vip-panel>
|
||||
<div class="uc-vip-card__bg"></div>
|
||||
@@ -84,30 +93,49 @@ if (class_exists('AKSRT_Settings')) {
|
||||
<div class="uc-vip-shop" data-aksrt-vip-shop>
|
||||
<div class="uc-vip-shop__title">
|
||||
<i class="fas fa-gem" aria-hidden="true"></i>
|
||||
<span><?php echo $is_vip_user ? esc_html__('续费 / 升级会员', 'aksrt') : esc_html__('开通会员', 'aksrt'); ?></span>
|
||||
<span><?php echo esc_html($shop_title); ?></span>
|
||||
</div>
|
||||
|
||||
<?php if ($vip_level > 0 && $renew_desc !== '') : ?>
|
||||
<p class="uc-vip-shop__note"><?php echo esc_html($renew_desc); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($vip_level === 1 && $upgrade_desc !== '') : ?>
|
||||
<p class="uc-vip-shop__note"><?php echo esc_html($upgrade_desc); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($packages as $group) :
|
||||
$g_level = (int) ($group['level'] ?? 0);
|
||||
$g_name = (string) ($group['name'] ?? ('VIP' . $g_level));
|
||||
$g_action = (string) ($group['action'] ?? 'pay');
|
||||
$items = is_array($group['items'] ?? null) ? $group['items'] : [];
|
||||
if ($items === []) {
|
||||
continue;
|
||||
}
|
||||
$group_badge = '';
|
||||
if ($g_action === 'renew') {
|
||||
$group_badge = __('续费', 'aksrt');
|
||||
} elseif ($g_action === 'upgrade') {
|
||||
$group_badge = __('升级', 'aksrt');
|
||||
} elseif ($vip_level >= $g_level) {
|
||||
$group_badge = __('当前档', 'aksrt');
|
||||
}
|
||||
?>
|
||||
<div class="uc-vip-shop__group" data-vip-level="<?php echo esc_attr((string) $g_level); ?>">
|
||||
<div class="uc-vip-shop__group" data-vip-level="<?php echo esc_attr((string) $g_level); ?>" data-action="<?php echo esc_attr($g_action); ?>">
|
||||
<div class="uc-vip-shop__group-title">
|
||||
<?php echo esc_html($g_name); ?>
|
||||
<?php if ($vip_level >= $g_level) : ?>
|
||||
<span class="uc-vip-shop__badge"><?php esc_html_e('当前档', 'aksrt'); ?></span>
|
||||
<?php if ($group_badge !== '') : ?>
|
||||
<span class="uc-vip-shop__badge"><?php echo esc_html($group_badge); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-vip-shop__grid">
|
||||
<?php foreach ($items as $item) :
|
||||
$pid = (int) ($item['package_id'] ?? 0);
|
||||
$price_label = (string) ($item['price_label'] ?? ($cash_symbol . ($item['price'] ?? 0)));
|
||||
$show_price_label = (string) ($item['show_price_label'] ?? '');
|
||||
$discount_tag = (string) ($item['discount_tag'] ?? '');
|
||||
$days_label = (string) ($item['days_label'] ?? '');
|
||||
$title = (string) ($item['title'] ?? '');
|
||||
$cta = (string) ($item['cta_label'] ?? __('立即开通', 'aksrt'));
|
||||
?>
|
||||
<button
|
||||
type="button"
|
||||
@@ -116,11 +144,20 @@ if (class_exists('AKSRT_Settings')) {
|
||||
data-package-id="<?php echo esc_attr((string) $pid); ?>"
|
||||
data-price-label="<?php echo esc_attr($price_label); ?>"
|
||||
data-title="<?php echo esc_attr($title); ?>"
|
||||
data-action="<?php echo esc_attr((string) ($item['action'] ?? 'pay')); ?>"
|
||||
>
|
||||
<?php if ($discount_tag !== '') : ?>
|
||||
<span class="uc-vip-shop__item-tag"><?php echo esc_html($discount_tag); ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="uc-vip-shop__item-title"><?php echo esc_html($title); ?></span>
|
||||
<span class="uc-vip-shop__item-days"><?php echo esc_html($days_label); ?></span>
|
||||
<span class="uc-vip-shop__item-price"><?php echo esc_html($price_label); ?></span>
|
||||
<span class="uc-vip-shop__item-cta"><?php esc_html_e('立即开通', 'aksrt'); ?></span>
|
||||
<span class="uc-vip-shop__item-price">
|
||||
<?php echo esc_html($price_label); ?>
|
||||
<?php if ($show_price_label !== '') : ?>
|
||||
<small class="uc-vip-shop__item-show"><?php echo esc_html($show_price_label); ?></small>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<span class="uc-vip-shop__item-cta"><?php echo esc_html($cta); ?></span>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user