fix: consolidate backend changes and fix icon imports
- Add standard .gitignore patterns (node_modules, .env, IDE files) - Coupon.php: fix data structure for DataTable, add status filter - Order.php: fix data structure to match OrderListItem expectations - Product.php: add multi-currency prices array, unify nonce to 'formipay-admin' - client.js: fix AJAX action names to match PHP (underscores → hyphens) - OrderList.js: fix icon import (Icons.list), add response handling - OrderListItem.js: fix icon import (Icons.seen)
This commit is contained in:
@@ -612,6 +612,9 @@ class Coupon {
|
||||
$args['s'] = sanitize_text_field( wp_unslash($_REQUEST['search']) );
|
||||
}
|
||||
|
||||
// Handle status filtering (active/inactive)
|
||||
$status_filter = isset($_REQUEST['status']) ? sanitize_text_field($_REQUEST['status']) : 'all';
|
||||
|
||||
$get_coupons = get_posts($args);
|
||||
$global_currencies = get_global_currency_array();
|
||||
|
||||
@@ -619,13 +622,19 @@ class Coupon {
|
||||
if(!empty($get_coupons)){
|
||||
foreach($get_coupons as $key => $coupon){
|
||||
|
||||
$active = true;
|
||||
$is_active = formipay_get_post_meta($coupon->ID, 'active') == 'on';
|
||||
|
||||
// Apply status filter
|
||||
if ($status_filter !== 'all') {
|
||||
if ($status_filter === 'active' && !$is_active) continue;
|
||||
if ($status_filter === 'inactive' && $is_active) continue;
|
||||
}
|
||||
|
||||
$date_limit = formipay_get_post_meta($coupon->ID, 'date_limit');
|
||||
|
||||
$type = formipay_get_post_meta($coupon->ID, 'type');
|
||||
$amount_meta_key = "amount_$type";
|
||||
|
||||
|
||||
if($type == 'fixed'){
|
||||
$amount_value = [];
|
||||
foreach($global_currencies as $currency){
|
||||
@@ -646,23 +655,21 @@ class Coupon {
|
||||
$amount_value = floatval(formipay_get_post_meta($coupon->ID, $amount_meta_key));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($active){
|
||||
$coupons[] = [
|
||||
'ID' => $coupon->ID,
|
||||
'code' => get_the_title($coupon->ID),
|
||||
'value' => $amount_value,
|
||||
'type' => ucfirst(formipay_get_post_meta($coupon->ID, 'type')),
|
||||
'case_sensitive' => formipay_get_post_meta($coupon->ID, 'case_sensitive'),
|
||||
'usages' => [
|
||||
'used' => $this->count_order_by_coupon_code(get_the_title($coupon->ID)),
|
||||
'limit' => (intval(formipay_get_post_meta($coupon->ID, 'use_limit')) > 0) ? formipay_get_post_meta($coupon->ID, 'use_limit') : '∞'
|
||||
],
|
||||
'date_limit' => false !== $date_limit ? formipay_date('Y-m-d', intval(formipay_get_post_meta($coupon->ID, 'date_limit')) / 1000) : 'none',
|
||||
'status' => (formipay_get_post_meta($coupon->ID, 'active') == 'on') ? 'Active' : 'Inactive'
|
||||
];
|
||||
}
|
||||
|
||||
$coupons[] = [
|
||||
'ID' => $coupon->ID,
|
||||
'code' => get_the_title($coupon->ID),
|
||||
'amount' => $amount_value,
|
||||
'type' => ucfirst(formipay_get_post_meta($coupon->ID, 'type')),
|
||||
'case_sensitive' => formipay_get_post_meta($coupon->ID, 'case_sensitive'),
|
||||
'usage_count' => $this->count_order_by_coupon_code(get_the_title($coupon->ID)),
|
||||
'usages' => $this->count_order_by_coupon_code(get_the_title($coupon->ID)),
|
||||
'date_limit' => false !== $date_limit ? formipay_date('Y-m-d', intval(formipay_get_post_meta($coupon->ID, 'date_limit')) / 1000) : 'none',
|
||||
'active' => $is_active ? 'on' : 'off',
|
||||
'post_status' => $is_active ? 'active' : 'inactive',
|
||||
'status' => $is_active ? 'active' : 'inactive'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user