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
@@ -48,10 +48,14 @@ if (function_exists('get_the_subtitle')) {
|
||||
$has_access = function_exists('aksrt_has_paid_access') ? aksrt_has_paid_access($post) : false;
|
||||
$gate = function_exists('aksrt_can_download') ? aksrt_can_download($post) : true;
|
||||
$can_dl = $gate === true;
|
||||
$need_login = is_wp_error($gate) && $gate->get_error_code() === 'aksrt_need_login';
|
||||
$gate_code = is_wp_error($gate) ? $gate->get_error_code() : '';
|
||||
$need_login = $gate_code === 'aksrt_need_login';
|
||||
$need_purchase = $gate_code === 'aksrt_need_purchase';
|
||||
$need_vip = $gate_code === 'aksrt_need_vip';
|
||||
|
||||
// Free download + login required (Zibll pay_free_logged_show).
|
||||
$price = (float) ($pay_meta['price'] ?? 0);
|
||||
$priced = function_exists('aksrt_get_user_pay_price') ? aksrt_get_user_pay_price($post) : null;
|
||||
$price = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($pay_meta['price'] ?? 0);
|
||||
$pay_modo = is_array($priced) ? ((($priced['modo'] ?? '0') === 'points') ? 'points' : '0') : ((($pay_meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
|
||||
$order_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_order_settings() : [];
|
||||
$free_logged_show = !empty($order_settings['free_logged_show']);
|
||||
if ($price <= 0 && $free_logged_show && !is_user_logged_in()) {
|
||||
@@ -60,6 +64,20 @@ if ($price <= 0 && $free_logged_show && !is_user_logged_in()) {
|
||||
$has_access = true; // free "access" but must login to download
|
||||
}
|
||||
|
||||
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
|
||||
$cash_symbol = '¥';
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
$paid_display = AKSRT_Settings::get_paid_content_settings();
|
||||
$cash_symbol = (string) ($paid_display['display']['currency_symbol'] ?? '¥');
|
||||
}
|
||||
$price_text = $price <= 0
|
||||
? __('免费', 'aksrt')
|
||||
: ($pay_modo === 'points'
|
||||
? (function_exists('aksrt_format_price') ? aksrt_format_price($price) : (string) $price) . ' ' . $currency
|
||||
: $cash_symbol . (function_exists('aksrt_format_price') ? aksrt_format_price($price) : (string) $price));
|
||||
$login_url = wp_login_url(add_query_arg('post', $post_id, get_permalink()));
|
||||
$vip_url = function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/');
|
||||
|
||||
$paid_name = '';
|
||||
if ($has_access || $can_dl) {
|
||||
if ($price <= 0) {
|
||||
@@ -120,11 +138,10 @@ get_header();
|
||||
</div>
|
||||
<?php elseif ($need_login) : ?>
|
||||
<div class="alert jb-yellow em12" style="margin:2em;">
|
||||
<b><?php esc_html_e('免费资源,请登录后下载', 'aksrt'); ?></b>
|
||||
<b><?php echo ($price <= 0) ? esc_html__('免费资源,请登录后下载', 'aksrt') : esc_html__('请先登录后再下载', 'aksrt'); ?></b>
|
||||
</div>
|
||||
<div class="pay-extra-hide">
|
||||
<?php
|
||||
$login_url = wp_login_url(add_query_arg('post', $post_id, get_permalink()));
|
||||
printf(
|
||||
/* translators: %s: login url */
|
||||
wp_kses_post(__('Hi!请先 <a href="%s">登录</a> 后再下载。', 'aksrt')),
|
||||
@@ -132,13 +149,44 @@ get_header();
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<a style="margin-bottom:2em;" href="<?php echo esc_url($login_url); ?>" class="but jb-red padding-lg">
|
||||
<i class="fa fa-sign-in" aria-hidden="true"></i>
|
||||
<span class="ml10"><?php esc_html_e('前往登录', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php elseif ($need_vip) : ?>
|
||||
<div class="alert jb-yellow em12" style="margin:2em;">
|
||||
<b><?php echo esc_html(is_wp_error($gate) ? $gate->get_error_message() : __('该资源仅限会员购买/下载。', 'aksrt')); ?></b>
|
||||
</div>
|
||||
<a style="margin-bottom:1em;" href="<?php echo esc_url($vip_url); ?>" class="but jb-vip padding-lg">
|
||||
<i class="fa fa-crown" aria-hidden="true"></i>
|
||||
<span class="ml10"><?php esc_html_e('开通会员', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<a style="margin-bottom:2em;" href="<?php echo esc_url($article_url); ?>" class="but jb-yellow padding-lg">
|
||||
<i class="fa fa-long-arrow-left" aria-hidden="true"></i>
|
||||
<span class="ml10"><?php esc_html_e('返回文章', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php elseif ($need_purchase) : ?>
|
||||
<div class="alert jb-red em12" style="margin:2em;">
|
||||
<b><?php esc_html_e('请先购买后再下载', 'aksrt'); ?></b>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="but <?php echo $pay_modo === 'points' ? 'jb-yellow' : 'jb-red'; ?> padding-lg cashier-link"
|
||||
data-action="aksrt-need-purchase"
|
||||
data-aksrt-pay-content="<?php echo esc_attr((string) $post_id); ?>"
|
||||
data-post-id="<?php echo esc_attr((string) $post_id); ?>"
|
||||
style="margin-bottom:1em;"
|
||||
>
|
||||
<i class="fa fa-shopping-cart" aria-hidden="true"></i>
|
||||
<span class="ml10"><?php printf(esc_html__('立即购买(%s)', 'aksrt'), $price_text); ?></span>
|
||||
</button>
|
||||
<a style="margin-bottom:2em;" href="<?php echo esc_url($article_url); ?>" class="but jb-yellow padding-lg">
|
||||
<i class="fa fa-long-arrow-left" aria-hidden="true"></i>
|
||||
<span class="ml10"><?php esc_html_e('返回文章', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<div class="alert jb-red em12" style="margin:2em;">
|
||||
<b><?php esc_html_e('暂无下载权限', 'aksrt'); ?></b>
|
||||
<b><?php echo esc_html(is_wp_error($gate) ? $gate->get_error_message() : __('暂无下载权限', 'aksrt')); ?></b>
|
||||
</div>
|
||||
<a style="margin-bottom:2em;" href="<?php echo esc_url($article_url); ?>" class="but jb-yellow padding-lg">
|
||||
<i class="fa fa-long-arrow-left" aria-hidden="true"></i>
|
||||
|
||||
Reference in new issue
Block a user