feat(pay): content cashier, resource orders at VIP price, purchase/download JS loop
Wire zibll-style one-shot points/cash cashier for post+_aksrt_pay downloads: server amount from aksrt_get_user_pay_price, ORDER_PRODUCT_RESOURCE unlock, frontend need-purchase opens modal, download box purchased/VIP/purchase CTAs.
This commit is contained in:
1 parent
abe2f57417
commit
770205623d
11 files changed
+1142
-170
No files matched your search
@@ -481,6 +481,7 @@ if (!function_exists('aksrt_get_pay_price_label')) {
|
||||
$pay_limit = is_array($priced)
|
||||
? (int) ($priced['pay_limit'] ?? 0)
|
||||
: (int) ($meta['pay_limit'] ?? 0);
|
||||
$vip_level = is_array($priced) ? (int) ($priced['vip_level'] ?? 0) : 0;
|
||||
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
|
||||
$cash_symbol = '¥';
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
@@ -488,7 +489,10 @@ if (!function_exists('aksrt_get_pay_price_label')) {
|
||||
$cash_symbol = (string) ($paid['display']['currency_symbol'] ?? '¥');
|
||||
}
|
||||
|
||||
if ($meta['pay_type'] === AKSRT_PAY_TYPE_VIP || $pay_limit > 0) {
|
||||
// pay_type VIP-only or pay_limit not met → member-exclusive badge.
|
||||
$member_blocked = ($meta['pay_type'] === AKSRT_PAY_TYPE_VIP)
|
||||
|| ($pay_limit > 0 && $vip_level < $pay_limit);
|
||||
if ($member_blocked) {
|
||||
return [
|
||||
'text' => __('会员专属', 'aksrt'),
|
||||
'free' => false,
|
||||
@@ -511,7 +515,7 @@ if (!function_exists('aksrt_get_pay_price_label')) {
|
||||
'amount' => 0,
|
||||
'base' => $base,
|
||||
'modo' => $pay_modo,
|
||||
'pay_limit' => 0,
|
||||
'pay_limit' => $pay_limit,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -522,7 +526,7 @@ if (!function_exists('aksrt_get_pay_price_label')) {
|
||||
'amount' => $price,
|
||||
'base' => $base,
|
||||
'modo' => 'points',
|
||||
'pay_limit' => 0,
|
||||
'pay_limit' => $pay_limit,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -532,7 +536,7 @@ if (!function_exists('aksrt_get_pay_price_label')) {
|
||||
'amount' => $price,
|
||||
'base' => $base,
|
||||
'modo' => '0',
|
||||
'pay_limit' => 0,
|
||||
'pay_limit' => $pay_limit,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -646,6 +650,57 @@ if (!function_exists('aksrt_get_demo_link_html')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Product attributes row (Zibll zibpay_get_product_attributes).
|
||||
*/
|
||||
if (!function_exists('aksrt_get_pay_attributes_html')) {
|
||||
function aksrt_get_pay_attributes_html($post = null, string $class = 'resource-download-box__attrs'): string {
|
||||
$p = get_post($post);
|
||||
if (!($p instanceof WP_Post)) {
|
||||
return '';
|
||||
}
|
||||
$meta = aksrt_get_pay_meta($p);
|
||||
$attrs = is_array($meta['attributes'] ?? null) ? $meta['attributes'] : [];
|
||||
// Built-in version/size/license/compat as attributes when set.
|
||||
$builtin = [
|
||||
'version' => __('版本', 'aksrt'),
|
||||
'size' => __('大小', 'aksrt'),
|
||||
'license' => __('授权', 'aksrt'),
|
||||
'compat' => __('兼容', 'aksrt'),
|
||||
];
|
||||
$rows = [];
|
||||
foreach ($builtin as $key => $label) {
|
||||
$val = trim((string) ($meta[$key] ?? ''));
|
||||
if ($val !== '') {
|
||||
$rows[] = ['name' => $label, 'value' => $val];
|
||||
}
|
||||
}
|
||||
foreach ($attrs as $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
$name = trim((string) ($row['name'] ?? $row['key'] ?? $row['label'] ?? ''));
|
||||
$value = trim((string) ($row['value'] ?? $row['val'] ?? ''));
|
||||
if ($name === '' || $value === '') {
|
||||
continue;
|
||||
}
|
||||
$rows[] = ['name' => $name, 'value' => $value];
|
||||
}
|
||||
if ($rows === []) {
|
||||
return '';
|
||||
}
|
||||
$html = '<ul class="' . esc_attr($class) . '">';
|
||||
foreach ($rows as $row) {
|
||||
$html .= '<li class="' . esc_attr($class) . '-item">';
|
||||
$html .= '<span class="' . esc_attr($class) . '-name">' . esc_html($row['name']) . '</span>';
|
||||
$html .= '<span class="' . esc_attr($class) . '-value">' . esc_html($row['value']) . '</span>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
$html .= '</ul>';
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 付费墙 HTML
|
||||
// ============================================================
|
||||
@@ -657,6 +712,7 @@ if (!function_exists('aksrt_get_paywall_html')) {
|
||||
$priced = function_exists('aksrt_get_user_pay_price') ? aksrt_get_user_pay_price($post) : null;
|
||||
$pay_modo = is_array($priced) ? ((($priced['modo'] ?? '0') === 'points') ? 'points' : '0') : ((($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
|
||||
$price = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
|
||||
$vip_level = is_array($priced) ? (int) ($priced['vip_level'] ?? 0) : 0;
|
||||
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
|
||||
$cash_symbol = '¥';
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
@@ -679,6 +735,8 @@ if (!function_exists('aksrt_get_paywall_html')) {
|
||||
$original_price = (float) ($meta['original_price'] ?? 0);
|
||||
$has_original = $original_price > 0 && $original_price > $price;
|
||||
$pay_limit = (int) ($meta['pay_limit'] ?? 0);
|
||||
$member_blocked = $pay_limit > 0 && $vip_level < $pay_limit;
|
||||
$vip_url = function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/');
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
@@ -692,7 +750,7 @@ if (!function_exists('aksrt_get_paywall_html')) {
|
||||
<h3 class="aksrt-paywall__title"><?php echo esc_html($type_info['label']); ?></h3>
|
||||
<p class="aksrt-paywall__desc"><?php echo esc_html($type_info['desc']); ?></p>
|
||||
<div class="aksrt-paywall__price">
|
||||
<?php if ($pay_limit > 0) : ?>
|
||||
<?php if ($member_blocked) : ?>
|
||||
<span class="aksrt-paywall__price-member"><?php esc_html_e('会员专属', 'aksrt'); ?></span>
|
||||
<?php elseif ($price > 0) : ?>
|
||||
<span class="aksrt-paywall__price-amount"><?php echo esc_html($price_text); ?></span>
|
||||
@@ -704,13 +762,13 @@ if (!function_exists('aksrt_get_paywall_html')) {
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (!$is_logged_in) : ?>
|
||||
<a href="<?php echo esc_url($login_url); ?>" class="but jb-red padding-lg cashier-link aksrt-paywall__btn">
|
||||
<a href="<?php echo esc_url($login_url); ?>" class="but jb-red padding-lg aksrt-paywall__btn">
|
||||
<i class="fa fa-sign-in" aria-hidden="true"></i> <?php esc_html_e('登录后购买', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php elseif ($pay_limit > 0) : ?>
|
||||
<span class="but jb-vip padding-lg aksrt-paywall__btn is-disabled">
|
||||
<?php elseif ($member_blocked) : ?>
|
||||
<a href="<?php echo esc_url($vip_url); ?>" class="but jb-vip padding-lg aksrt-paywall__btn">
|
||||
<i class="fas fa-crown" aria-hidden="true"></i> <?php esc_html_e('开通会员后可查看', 'aksrt'); ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php elseif ($price > 0) : ?>
|
||||
<button type="button" class="but <?php echo $pay_modo === 'points' ? 'jb-yellow' : 'jb-red'; ?> padding-lg cashier-link aksrt-paywall__btn" data-aksrt-pay-content="<?php echo esc_attr((string) $post->ID); ?>">
|
||||
<i class="fa fa-shopping-cart" aria-hidden="true"></i> <?php printf(esc_html__('立即购买(%s)', 'aksrt'), $price_text); ?>
|
||||
|
||||
Reference in new issue
Block a user