feat(forum): plate follow cash coupons + free auto-order
- Meta _aksrt_follow_pay_coupon_s + plate admin toggle (money only) - Plate_Follow_Pay soft/hard coupon apply, free-after-discount, burn via shared helper - Cashier auto-submits free topic/plate orders; topic coupon label no longer "预留"
This commit is contained in:
1 parent
3588ebeb85
commit
cb43412369
6 files changed
+273
-42
No files matched your search
@@ -190,6 +190,13 @@ class AKSRT_Plate_Meta_Box {
|
||||
<input type="number" step="0.01" min="0" class="widefat" name="aksrt_plate_follow_pay_vip2_price" id="aksrt_plate_follow_pay_vip2_price" value="<?php echo esc_attr((string) ($follow_pay['vip2_price'] ?? '')); ?>" placeholder="<?php esc_attr_e('留空=不设 VIP2 价;0=VIP2 免费', 'aksrt'); ?>">
|
||||
<span class="description"><?php esc_html_e('现金模式用元;积分模式填积分数。未填 VIP1 时仍可读旧「VIP 价格」字段。', 'aksrt'); ?></span>
|
||||
</p>
|
||||
<p>
|
||||
<label>
|
||||
<input type="checkbox" name="aksrt_plate_follow_pay_coupon_s" value="1" <?php checked(!empty($follow_pay['coupon_s'])); ?>>
|
||||
<?php esc_html_e('允许优惠码(仅现金关注)', 'aksrt'); ?>
|
||||
</label>
|
||||
<span class="description" style="display:block;"><?php esc_html_e('开启后收银台可输入优惠码;积分关注不吃券。', 'aksrt'); ?></span>
|
||||
</p>
|
||||
<hr>
|
||||
<?php
|
||||
}
|
||||
@@ -398,6 +405,7 @@ class AKSRT_Plate_Meta_Box {
|
||||
delete_post_meta($post_id, '_aksrt_follow_pay_vip_price');
|
||||
delete_post_meta($post_id, '_aksrt_follow_pay_vip1_price');
|
||||
delete_post_meta($post_id, '_aksrt_follow_pay_vip2_price');
|
||||
delete_post_meta($post_id, '_aksrt_follow_pay_coupon_s');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -405,6 +413,7 @@ class AKSRT_Plate_Meta_Box {
|
||||
update_post_meta($post_id, '_aksrt_follow_pay_modo', $modo);
|
||||
update_post_meta($post_id, '_aksrt_follow_pay_price', $price);
|
||||
update_post_meta($post_id, '_aksrt_follow_pay_points', $points);
|
||||
update_post_meta($post_id, '_aksrt_follow_pay_coupon_s', !empty($_POST['aksrt_plate_follow_pay_coupon_s']) ? 1 : 0);
|
||||
|
||||
if (isset($_POST['aksrt_plate_follow_pay_vip1_price']) && (string) wp_unslash($_POST['aksrt_plate_follow_pay_vip1_price']) !== '') {
|
||||
$vip1 = max(0, (float) wp_unslash($_POST['aksrt_plate_follow_pay_vip1_price']));
|
||||
@@ -424,7 +433,7 @@ class AKSRT_Plate_Meta_Box {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{enabled:bool,modo:string,price:float,points:int,vip1_price:string,vip2_price:string}
|
||||
* @return array{enabled:bool,modo:string,price:float,points:int,vip1_price:string,vip2_price:string,coupon_s:bool}
|
||||
*/
|
||||
private function get_follow_pay_meta(int $plate_id): array {
|
||||
$enabled = (int) get_post_meta($plate_id, '_aksrt_follow_pay', true) === 1;
|
||||
@@ -451,6 +460,7 @@ class AKSRT_Plate_Meta_Box {
|
||||
'points' => (int) get_post_meta($plate_id, '_aksrt_follow_pay_points', true),
|
||||
'vip1_price' => $vip1_set ? (string) (float) $vip1_raw : '',
|
||||
'vip2_price' => $vip2_set ? (string) (float) $vip2_raw : '',
|
||||
'coupon_s' => (int) get_post_meta($plate_id, '_aksrt_follow_pay_coupon_s', true) === 1,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user