function test_coupon_conditions() { $coupon = new WPSC_Coupon(self::PERCENTAGE_COUPON_ID); $this->assertEmpty($coupon->get('condition')); $coupon_cond = new WPSC_Coupon(self::CONDITIONS_COUPON_ID); $this->assertTrue(is_array($coupon_cond->get('condition'))); $this->assertNotEmpty($coupon_cond->get('condition')); }
<script type='text/javascript'> jQuery(".pickdate").datepicker(); /* jQuery datepicker selector */ if (typeof jQuery('.pickdate').datepicker != "undefined") { jQuery('.pickdate').datepicker({ dateFormat: 'yy-mm-dd' }); } </script> <form name='edit_coupon' method="post" action="<?php echo admin_url('edit.php?post_type=wpsc-product&page=wpsc-edit-coupons'); ?> "> <table class="form-table"> <tbody> <?php do_action('wpsc_coupon_edit_top', $coupon->get('id'), $coupon->get_data()); ?> <tr class="form-field"> <th scope="row" valign="top"> <label for="edit_coupon_code"><?php _e('Coupon Code', 'wpsc'); ?> </label> </th> <td> <input name="edit_coupon_code" id="edit_coupon_code" type="text" value="<?php esc_attr_e($coupon->get('coupon_code')); ?> " style="width: 300px;"/> <p class="description"><?php
/** * Retrieve all the data for all the discount codes * * @access private * @since 3.8.10 * @return array */ public function coupons_data() { global $wpdb; $coupons_data = array(); if (isset($_GET['paged'])) { $page = $_GET['paged']; } else { $page = 1; } $per_page = $this->per_page; $offset = ($page - 1) * $this->per_page; $status = isset($_GET['status']) ? absint($_GET['status']) : false; $where = $status !== false ? "WHERE active = {$status}" : ''; $order = isset($_GET['order']) && strtoupper($_GET['order']) === 'ASC' ? 'ASC' : 'DESC'; $limit = " LIMIT {$offset},{$per_page};"; $coupons = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` {$where} ORDER BY id {$order} {$limit} ", ARRAY_A); if ($coupons) { foreach ($coupons as $data) { $coupon = new WPSC_Coupon(array('id' => $data['id'], 'coupon_code' => $data['coupon_code'], 'value' => $data['value'], 'is-percentage' => $data['is-percentage'], 'start' => $data['start'], 'expiry' => $data['expiry'], 'active' => $data['active'])); // Re-map data to array for legacy handling of this method's return data. // (would be nicer to return an object?) $coupons_data[] = array('ID' => $coupon->get('id'), 'coupon' => $coupon->get('coupon_code'), 'discount' => $coupon->get('value'), 'type' => $coupon->get('is-percentage'), 'start' => $coupon->get('start'), 'expiry' => $coupon->get('expiry'), 'status' => $coupon->get('active') == 1 ? 'active' : 'inactive'); } } return $coupons_data; }