Complete coupon system integration with payment processing
Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
291fd81504
commit
7dcecd49ed
3 changed files with 58 additions and 1 deletions
|
|
@ -136,6 +136,17 @@ function process_payment_record(array $record) {
|
|||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
|
||||
// If invoice has a coupon, increment usage count
|
||||
$coupon_id = intval($inv['coupon_id'] ?? 0);
|
||||
if ($coupon_id > 0) {
|
||||
$upd_coupon = "UPDATE `" . $TABLE_PREFIX . "billing_coupons` SET current_uses = current_uses + 1 WHERE coupon_id = ?";
|
||||
if ($stmt = mysqli_prepare($db, $upd_coupon)) {
|
||||
mysqli_stmt_bind_param($stmt, 'i', $coupon_id);
|
||||
mysqli_stmt_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
}
|
||||
|
||||
// If this invoice already has an order -> treat as renewal
|
||||
if ($order_id > 0) {
|
||||
// compute months
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue