</th> <th><?php _e("Applied Product", ET_DOMAIN); ?> </th> <th><?php _e("Used Count", ET_DOMAIN); ?> </th> <th><?php _e("Actions", ET_DOMAIN); ?> </th> </tr> <?php $plans = et_get_payment_plans(); while ($coupon_list->have_posts()) { $coupon_list->the_post(); global $post; $coupon_data = $this->generate_coupon_response(get_the_title()); $date_limit = $coupon_data['date_limit']; $added_product = $coupon_data['added_product']; ?> <tr id="coupon-<?php echo $post->ID; ?> " data-coupon="<?php echo $post->ID; ?> " > <!-- coupon data -->
/** * ajax return coupon list page */ function load_page() { header('HTTP/1.0 200 OK'); header('Content-type: application/json'); $paged = $_GET['paged']; $args = array('post_type' => 'ce_coupon', 'post_status' => 'publish', 'paged' => $paged); $coupon_list = new WP_Query($args); $plans = et_get_payment_plans(); $currency = ET_Payment::get_currency(); $tr = ''; while ($coupon_list->have_posts()) { $coupon_list->the_post(); global $post; $coupon_data = $this->generate_coupon_response(get_the_title()); $date_limit = $coupon_data['date_limit']; $added_product = $coupon_data['added_product']; if ($date_limit == 'on') { $start_date = $coupon_data['start_date']; $expired_date = $coupon_data['expired_date']; } else { $start_date = __("Lifetime", ET_DOMAIN); $expired_date = __("Lifetime", ET_DOMAIN); } if ($coupon_data['discount_type'] == 'percent') { $type = ' (%)'; } else { $type = $currency['code']; } $products = ''; if (empty($added_product)) { $products = __("All ad packages", ET_DOMAIN); } else { $num = count($added_product); $i = 0; foreach ($added_product as $key => $value) { $i++; $products .= $value; if ($i < $num) { $products .= ', '; } } } $tr .= '<tr id="coupon-' . $post->ID . '" data-coupon="' . $post->ID . '" >' . '<script id="coupon_' . $post->ID . '" type="text/data">' . json_encode($coupon_data) . '</script>' . '<td>' . $coupon_data['coupon_code'] . '</td>' . '<td align="center">' . $start_date . '</td>' . '<td align="center">' . $expired_date . '</td>' . '<td>' . $coupon_data['discount_rate'] . ' ' . $type . '</td>' . '<td>' . $products . '</td>' . '<td>' . intval($coupon_data['have_been_used']) . '<span class="count">/' . $coupon_data['usage_count'] . '</span></td>' . '<td align="center">' . '<a href="#" class="delete" title="' . __("Delete", ET_DOMAIN) . '"><span class="icon" data-icon="-"></span></a>' . '<a href="#" class="edit" title="' . __("Edit", ET_DOMAIN) . '"><span class="icon" data-icon="p"></span></a>' . '</td>' . '</tr>'; } $paginate = ''; if ($coupon_list->max_num_pages > 1) { for ($i = 1; $i <= $coupon_list->max_num_pages; $i++) { if ($i != $paged) { $paginate .= '<li data-page="' . $i . '" ><a href="#" class="pi">' . $i . '</a></li>'; } else { $paginate .= '<li data-page="' . $i . '" ><span class="current">' . $i . '</span></li>'; } } } $response = array('success' => true, 'data' => $tr, 'paginate' => $paginate); echo json_encode($response); exit; }