feat(submit): pay_limit, require_login, coupon fields on front submit
Expose VIP purchase gate, login-required purchase, and coupon toggle/desc in the pay sidebar; persist through FrontSubmitPay into DomainModel meta.
This commit is contained in:
@@ -147,6 +147,14 @@ trait FrontSubmitPay {
|
||||
$meta['vip2_points'] = 0;
|
||||
}
|
||||
|
||||
$pay_limit = (int) ($raw['pay_limit'] ?? $data['pay_limit'] ?? 0);
|
||||
$meta['pay_limit'] = in_array($pay_limit, [0, 1, 2], true) ? $pay_limit : 0;
|
||||
$meta['require_login'] = !empty($raw['require_login']) || !empty($data['require_login']);
|
||||
$meta['coupon_s'] = !empty($raw['coupon_s']) || !empty($data['coupon_s']);
|
||||
if (isset($raw['coupon_desc']) || isset($data['coupon_desc'])) {
|
||||
$meta['coupon_desc'] = sanitize_textarea_field((string) ($raw['coupon_desc'] ?? $data['coupon_desc'] ?? ''));
|
||||
}
|
||||
|
||||
$this->write_pay_meta($post_id, $meta);
|
||||
return ['success' => true];
|
||||
}
|
||||
|
||||
@@ -85,6 +85,34 @@ $downloads = is_array($pay['downloads'] ?? null) ? $pay['downloads'] : [];
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-submit-pay__row">
|
||||
<span><?php esc_html_e('购买限制', 'aksrt'); ?></span>
|
||||
<select name="aksrt_pay[pay_limit]" class="form-control">
|
||||
<?php $pl = (int) ($pay['pay_limit'] ?? 0); ?>
|
||||
<option value="0" <?php selected($pl, 0); ?>><?php esc_html_e('所有人可购', 'aksrt'); ?></option>
|
||||
<option value="1" <?php selected($pl, 1); ?>><?php esc_html_e('仅 VIP1 及以上', 'aksrt'); ?></option>
|
||||
<option value="2" <?php selected($pl, 2); ?>><?php esc_html_e('仅 VIP2', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="aksrt-submit-pay__row">
|
||||
<span><?php esc_html_e('登录后可购', 'aksrt'); ?></span>
|
||||
<label class="aksrt-switch">
|
||||
<input type="checkbox" name="aksrt_pay[require_login]" value="1" <?php checked(!empty($pay['require_login'])); ?>>
|
||||
<span class="aksrt-switch__ui"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="aksrt-submit-pay__row">
|
||||
<span><?php esc_html_e('允许优惠码', 'aksrt'); ?></span>
|
||||
<label class="aksrt-switch">
|
||||
<input type="checkbox" name="aksrt_pay[coupon_s]" value="1" <?php checked(!empty($pay['coupon_s'])); ?>>
|
||||
<span class="aksrt-switch__ui"></span>
|
||||
</label>
|
||||
</div>
|
||||
<label class="aksrt-submit-field">
|
||||
<span><?php esc_html_e('优惠说明', 'aksrt'); ?></span>
|
||||
<input type="text" class="aksrt-form-input" name="aksrt_pay[coupon_desc]" value="<?php echo esc_attr((string) ($pay['coupon_desc'] ?? '')); ?>" placeholder="<?php esc_attr_e('收银台展示的优惠提示', 'aksrt'); ?>">
|
||||
</label>
|
||||
|
||||
<?php if (!empty($ctx['can_pay_download'])) : ?>
|
||||
<div class="aksrt-submit-pay-downloads" data-pay-downloads>
|
||||
<div class="aksrt-submit-pay__row">
|
||||
|
||||
Reference in New Issue
Block a user