@@ -12,202 +12,202 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class WPInv_Notes { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class constructor. |
|
| 17 | - */ |
|
| 18 | - public function __construct() { |
|
| 19 | - |
|
| 20 | - // Filter inovice notes. |
|
| 21 | - add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 ); |
|
| 22 | - add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 ); |
|
| 23 | - |
|
| 24 | - // Delete comments count cache whenever there is a new comment or a comment status changes. |
|
| 25 | - add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) ); |
|
| 26 | - add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) ); |
|
| 27 | - |
|
| 28 | - // Count comments. |
|
| 29 | - add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 ); |
|
| 30 | - |
|
| 31 | - // Fires after notes are loaded. |
|
| 32 | - do_action( 'wpinv_notes_init', $this ); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Filters invoice notes query to only include our notes. |
|
| 37 | - * |
|
| 38 | - * @param WP_Comment_Query $query |
|
| 39 | - */ |
|
| 40 | - public function set_invoice_note_type( $query ) { |
|
| 41 | - $post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
| 42 | - |
|
| 43 | - if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) { |
|
| 44 | - $query->query_vars['type'] = 'wpinv_note'; |
|
| 45 | - } else { |
|
| 46 | - |
|
| 47 | - if ( empty( $query->query_vars['type__not_in'] ) ) { |
|
| 48 | - $query->query_vars['type__not_in'] = array(); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - $query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] ); |
|
| 52 | - $query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] ); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - return $query; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Exclude notes from the comments feed. |
|
| 60 | - */ |
|
| 61 | - function wpinv_comment_feed_where( $where ){ |
|
| 62 | - return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' "; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Delete comments count cache whenever there is |
|
| 67 | - * new comment or the status of a comment changes. Cache |
|
| 68 | - * will be regenerated next time WPInv_Notes::wp_count_comments() |
|
| 69 | - * is called. |
|
| 70 | - */ |
|
| 71 | - public function delete_comments_count_cache() { |
|
| 72 | - delete_transient( 'getpaid_count_comments' ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Remove invoice notes from wp_count_comments(). |
|
| 77 | - * |
|
| 78 | - * @since 2.2 |
|
| 79 | - * @param object $stats Comment stats. |
|
| 80 | - * @param int $post_id Post ID. |
|
| 81 | - * @return object |
|
| 82 | - */ |
|
| 83 | - public function wp_count_comments( $stats, $post_id ) { |
|
| 84 | - global $wpdb; |
|
| 85 | - |
|
| 86 | - if ( empty( $post_id ) ) { |
|
| 87 | - $stats = get_transient( 'getpaid_count_comments' ); |
|
| 88 | - |
|
| 89 | - if ( ! $stats ) { |
|
| 90 | - $stats = array( |
|
| 91 | - 'total_comments' => 0, |
|
| 92 | - 'all' => 0, |
|
| 93 | - ); |
|
| 94 | - |
|
| 95 | - $count = $wpdb->get_results( |
|
| 96 | - " |
|
| 15 | + /** |
|
| 16 | + * Class constructor. |
|
| 17 | + */ |
|
| 18 | + public function __construct() { |
|
| 19 | + |
|
| 20 | + // Filter inovice notes. |
|
| 21 | + add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 ); |
|
| 22 | + add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 ); |
|
| 23 | + |
|
| 24 | + // Delete comments count cache whenever there is a new comment or a comment status changes. |
|
| 25 | + add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) ); |
|
| 26 | + add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) ); |
|
| 27 | + |
|
| 28 | + // Count comments. |
|
| 29 | + add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 ); |
|
| 30 | + |
|
| 31 | + // Fires after notes are loaded. |
|
| 32 | + do_action( 'wpinv_notes_init', $this ); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Filters invoice notes query to only include our notes. |
|
| 37 | + * |
|
| 38 | + * @param WP_Comment_Query $query |
|
| 39 | + */ |
|
| 40 | + public function set_invoice_note_type( $query ) { |
|
| 41 | + $post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
| 42 | + |
|
| 43 | + if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) { |
|
| 44 | + $query->query_vars['type'] = 'wpinv_note'; |
|
| 45 | + } else { |
|
| 46 | + |
|
| 47 | + if ( empty( $query->query_vars['type__not_in'] ) ) { |
|
| 48 | + $query->query_vars['type__not_in'] = array(); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + $query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] ); |
|
| 52 | + $query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] ); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + return $query; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Exclude notes from the comments feed. |
|
| 60 | + */ |
|
| 61 | + function wpinv_comment_feed_where( $where ){ |
|
| 62 | + return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' "; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Delete comments count cache whenever there is |
|
| 67 | + * new comment or the status of a comment changes. Cache |
|
| 68 | + * will be regenerated next time WPInv_Notes::wp_count_comments() |
|
| 69 | + * is called. |
|
| 70 | + */ |
|
| 71 | + public function delete_comments_count_cache() { |
|
| 72 | + delete_transient( 'getpaid_count_comments' ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Remove invoice notes from wp_count_comments(). |
|
| 77 | + * |
|
| 78 | + * @since 2.2 |
|
| 79 | + * @param object $stats Comment stats. |
|
| 80 | + * @param int $post_id Post ID. |
|
| 81 | + * @return object |
|
| 82 | + */ |
|
| 83 | + public function wp_count_comments( $stats, $post_id ) { |
|
| 84 | + global $wpdb; |
|
| 85 | + |
|
| 86 | + if ( empty( $post_id ) ) { |
|
| 87 | + $stats = get_transient( 'getpaid_count_comments' ); |
|
| 88 | + |
|
| 89 | + if ( ! $stats ) { |
|
| 90 | + $stats = array( |
|
| 91 | + 'total_comments' => 0, |
|
| 92 | + 'all' => 0, |
|
| 93 | + ); |
|
| 94 | + |
|
| 95 | + $count = $wpdb->get_results( |
|
| 96 | + " |
|
| 97 | 97 | SELECT comment_approved, COUNT(*) AS num_comments |
| 98 | 98 | FROM {$wpdb->comments} |
| 99 | 99 | WHERE comment_type NOT IN ('action_log', 'order_note', 'webhook_delivery', 'wpinv_note') |
| 100 | 100 | GROUP BY comment_approved |
| 101 | 101 | ", |
| 102 | - ARRAY_A |
|
| 103 | - ); |
|
| 104 | - |
|
| 105 | - $approved = array( |
|
| 106 | - '0' => 'moderated', |
|
| 107 | - '1' => 'approved', |
|
| 108 | - 'spam' => 'spam', |
|
| 109 | - 'trash' => 'trash', |
|
| 110 | - 'post-trashed' => 'post-trashed', |
|
| 111 | - ); |
|
| 112 | - |
|
| 113 | - foreach ( (array) $count as $row ) { |
|
| 114 | - // Don't count post-trashed toward totals. |
|
| 115 | - if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) { |
|
| 116 | - $stats['all'] += $row['num_comments']; |
|
| 117 | - $stats['total_comments'] += $row['num_comments']; |
|
| 118 | - } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) { |
|
| 119 | - $stats['total_comments'] += $row['num_comments']; |
|
| 120 | - } |
|
| 121 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
| 122 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - foreach ( $approved as $key ) { |
|
| 127 | - if ( empty( $stats[ $key ] ) ) { |
|
| 128 | - $stats[ $key ] = 0; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - $stats = (object) $stats; |
|
| 133 | - set_transient( 'getpaid_count_comments', $stats ); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $stats; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Returns an array of invoice notes. |
|
| 143 | - * |
|
| 144 | - * @param int $invoice_id The invoice ID whose notes to retrieve. |
|
| 145 | - * @param string $type Optional. Pass in customer to only return customer notes. |
|
| 146 | - * @return WP_Comment[] |
|
| 147 | - */ |
|
| 148 | - public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) { |
|
| 149 | - |
|
| 150 | - // Default comment args. |
|
| 151 | - $args = array( |
|
| 152 | - 'post_id' => $invoice_id, |
|
| 153 | - 'orderby' => 'comment_ID', |
|
| 154 | - 'order' => 'ASC', |
|
| 155 | - ); |
|
| 156 | - |
|
| 157 | - // Maybe only show customer comments. |
|
| 158 | - if ( $type == 'customer' ) { |
|
| 159 | - $args['meta_key'] = '_wpi_customer_note'; |
|
| 160 | - $args['meta_value'] = 1; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type ); |
|
| 164 | - |
|
| 165 | - return get_comments( $args ); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Saves an invoice comment. |
|
| 170 | - * |
|
| 171 | - * @param WPInv_Invoice $invoice The invoice to add the comment to. |
|
| 172 | - * @param string $note The note content. |
|
| 173 | - * @param string $note_author The name of the author of the note. |
|
| 174 | - * @param bool $for_customer Whether or not this comment is meant to be sent to the customer. |
|
| 175 | - * @return int|false The new note's ID on success, false on failure. |
|
| 176 | - */ |
|
| 177 | - function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){ |
|
| 178 | - |
|
| 179 | - do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer ); |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Insert the comment. |
|
| 183 | - */ |
|
| 184 | - $note_id = wp_insert_comment( |
|
| 185 | - wp_filter_comment( |
|
| 186 | - array( |
|
| 187 | - 'comment_post_ID' => $invoice->get_id(), |
|
| 188 | - 'comment_content' => $note, |
|
| 189 | - 'comment_agent' => 'Invoicing', |
|
| 190 | - 'user_id' => get_current_user_id(), |
|
| 191 | - 'comment_author' => $note_author, |
|
| 192 | - 'comment_author_IP' => wpinv_get_ip(), |
|
| 193 | - 'comment_author_email' => $author_email, |
|
| 194 | - 'comment_author_url' => $invoice->get_view_url(), |
|
| 195 | - 'comment_type' => 'wpinv_note', |
|
| 196 | - ) |
|
| 197 | - ) |
|
| 198 | - ); |
|
| 199 | - |
|
| 200 | - do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer ); |
|
| 201 | - |
|
| 202 | - // Are we notifying the customer? |
|
| 203 | - if ( empty( $note_id ) || empty( $for_customer ) ) { |
|
| 204 | - return $note_id; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 208 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) ); |
|
| 209 | - do_action( 'getpaid_new_customer_note', $invoice, $note ); |
|
| 210 | - return $note_id; |
|
| 211 | - } |
|
| 102 | + ARRAY_A |
|
| 103 | + ); |
|
| 104 | + |
|
| 105 | + $approved = array( |
|
| 106 | + '0' => 'moderated', |
|
| 107 | + '1' => 'approved', |
|
| 108 | + 'spam' => 'spam', |
|
| 109 | + 'trash' => 'trash', |
|
| 110 | + 'post-trashed' => 'post-trashed', |
|
| 111 | + ); |
|
| 112 | + |
|
| 113 | + foreach ( (array) $count as $row ) { |
|
| 114 | + // Don't count post-trashed toward totals. |
|
| 115 | + if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) { |
|
| 116 | + $stats['all'] += $row['num_comments']; |
|
| 117 | + $stats['total_comments'] += $row['num_comments']; |
|
| 118 | + } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) { |
|
| 119 | + $stats['total_comments'] += $row['num_comments']; |
|
| 120 | + } |
|
| 121 | + if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
| 122 | + $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + foreach ( $approved as $key ) { |
|
| 127 | + if ( empty( $stats[ $key ] ) ) { |
|
| 128 | + $stats[ $key ] = 0; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + $stats = (object) $stats; |
|
| 133 | + set_transient( 'getpaid_count_comments', $stats ); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $stats; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Returns an array of invoice notes. |
|
| 143 | + * |
|
| 144 | + * @param int $invoice_id The invoice ID whose notes to retrieve. |
|
| 145 | + * @param string $type Optional. Pass in customer to only return customer notes. |
|
| 146 | + * @return WP_Comment[] |
|
| 147 | + */ |
|
| 148 | + public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) { |
|
| 149 | + |
|
| 150 | + // Default comment args. |
|
| 151 | + $args = array( |
|
| 152 | + 'post_id' => $invoice_id, |
|
| 153 | + 'orderby' => 'comment_ID', |
|
| 154 | + 'order' => 'ASC', |
|
| 155 | + ); |
|
| 156 | + |
|
| 157 | + // Maybe only show customer comments. |
|
| 158 | + if ( $type == 'customer' ) { |
|
| 159 | + $args['meta_key'] = '_wpi_customer_note'; |
|
| 160 | + $args['meta_value'] = 1; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type ); |
|
| 164 | + |
|
| 165 | + return get_comments( $args ); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Saves an invoice comment. |
|
| 170 | + * |
|
| 171 | + * @param WPInv_Invoice $invoice The invoice to add the comment to. |
|
| 172 | + * @param string $note The note content. |
|
| 173 | + * @param string $note_author The name of the author of the note. |
|
| 174 | + * @param bool $for_customer Whether or not this comment is meant to be sent to the customer. |
|
| 175 | + * @return int|false The new note's ID on success, false on failure. |
|
| 176 | + */ |
|
| 177 | + function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){ |
|
| 178 | + |
|
| 179 | + do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer ); |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Insert the comment. |
|
| 183 | + */ |
|
| 184 | + $note_id = wp_insert_comment( |
|
| 185 | + wp_filter_comment( |
|
| 186 | + array( |
|
| 187 | + 'comment_post_ID' => $invoice->get_id(), |
|
| 188 | + 'comment_content' => $note, |
|
| 189 | + 'comment_agent' => 'Invoicing', |
|
| 190 | + 'user_id' => get_current_user_id(), |
|
| 191 | + 'comment_author' => $note_author, |
|
| 192 | + 'comment_author_IP' => wpinv_get_ip(), |
|
| 193 | + 'comment_author_email' => $author_email, |
|
| 194 | + 'comment_author_url' => $invoice->get_view_url(), |
|
| 195 | + 'comment_type' => 'wpinv_note', |
|
| 196 | + ) |
|
| 197 | + ) |
|
| 198 | + ); |
|
| 199 | + |
|
| 200 | + do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer ); |
|
| 201 | + |
|
| 202 | + // Are we notifying the customer? |
|
| 203 | + if ( empty( $note_id ) || empty( $for_customer ) ) { |
|
| 204 | + return $note_id; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 208 | + do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) ); |
|
| 209 | + do_action( 'getpaid_new_customer_note', $invoice, $note ); |
|
| 210 | + return $note_id; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | 213 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Handles invoice notes. |
@@ -18,18 +18,18 @@ discard block |
||
| 18 | 18 | public function __construct() { |
| 19 | 19 | |
| 20 | 20 | // Filter inovice notes. |
| 21 | - add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 ); |
|
| 22 | - add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 ); |
|
| 21 | + add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1); |
|
| 22 | + add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1); |
|
| 23 | 23 | |
| 24 | 24 | // Delete comments count cache whenever there is a new comment or a comment status changes. |
| 25 | - add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) ); |
|
| 26 | - add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) ); |
|
| 25 | + add_action('wp_insert_comment', array($this, 'delete_comments_count_cache')); |
|
| 26 | + add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache')); |
|
| 27 | 27 | |
| 28 | 28 | // Count comments. |
| 29 | - add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 ); |
|
| 29 | + add_filter('wp_count_comments', array($this, 'wp_count_comments'), 100, 2); |
|
| 30 | 30 | |
| 31 | 31 | // Fires after notes are loaded. |
| 32 | - do_action( 'wpinv_notes_init', $this ); |
|
| 32 | + do_action('wpinv_notes_init', $this); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -37,19 +37,19 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @param WP_Comment_Query $query |
| 39 | 39 | */ |
| 40 | - public function set_invoice_note_type( $query ) { |
|
| 41 | - $post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
| 40 | + public function set_invoice_note_type($query) { |
|
| 41 | + $post_id = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
| 42 | 42 | |
| 43 | - if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) { |
|
| 43 | + if ($post_id && getpaid_is_invoice_post_type(get_post_type($post_id))) { |
|
| 44 | 44 | $query->query_vars['type'] = 'wpinv_note'; |
| 45 | 45 | } else { |
| 46 | 46 | |
| 47 | - if ( empty( $query->query_vars['type__not_in'] ) ) { |
|
| 47 | + if (empty($query->query_vars['type__not_in'])) { |
|
| 48 | 48 | $query->query_vars['type__not_in'] = array(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] ); |
|
| 52 | - $query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] ); |
|
| 51 | + $query->query_vars['type__not_in'] = wpinv_parse_list($query->query_vars['type__not_in']); |
|
| 52 | + $query->query_vars['type__not_in'] = array_merge(array('wpinv_note'), $query->query_vars['type__not_in']); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return $query; |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | /** |
| 59 | 59 | * Exclude notes from the comments feed. |
| 60 | 60 | */ |
| 61 | - function wpinv_comment_feed_where( $where ){ |
|
| 62 | - return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' "; |
|
| 61 | + function wpinv_comment_feed_where($where) { |
|
| 62 | + return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' "; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * is called. |
| 70 | 70 | */ |
| 71 | 71 | public function delete_comments_count_cache() { |
| 72 | - delete_transient( 'getpaid_count_comments' ); |
|
| 72 | + delete_transient('getpaid_count_comments'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | * @param int $post_id Post ID. |
| 81 | 81 | * @return object |
| 82 | 82 | */ |
| 83 | - public function wp_count_comments( $stats, $post_id ) { |
|
| 83 | + public function wp_count_comments($stats, $post_id) { |
|
| 84 | 84 | global $wpdb; |
| 85 | 85 | |
| 86 | - if ( empty( $post_id ) ) { |
|
| 87 | - $stats = get_transient( 'getpaid_count_comments' ); |
|
| 86 | + if (empty($post_id)) { |
|
| 87 | + $stats = get_transient('getpaid_count_comments'); |
|
| 88 | 88 | |
| 89 | - if ( ! $stats ) { |
|
| 89 | + if (!$stats) { |
|
| 90 | 90 | $stats = array( |
| 91 | 91 | 'total_comments' => 0, |
| 92 | 92 | 'all' => 0, |
@@ -110,27 +110,27 @@ discard block |
||
| 110 | 110 | 'post-trashed' => 'post-trashed', |
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | - foreach ( (array) $count as $row ) { |
|
| 113 | + foreach ((array) $count as $row) { |
|
| 114 | 114 | // Don't count post-trashed toward totals. |
| 115 | - if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) { |
|
| 115 | + if (!in_array($row['comment_approved'], array('post-trashed', 'trash', 'spam'), true)) { |
|
| 116 | 116 | $stats['all'] += $row['num_comments']; |
| 117 | 117 | $stats['total_comments'] += $row['num_comments']; |
| 118 | - } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) { |
|
| 118 | + } elseif (!in_array($row['comment_approved'], array('post-trashed', 'trash'), true)) { |
|
| 119 | 119 | $stats['total_comments'] += $row['num_comments']; |
| 120 | 120 | } |
| 121 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
| 122 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
| 121 | + if (isset($approved[$row['comment_approved']])) { |
|
| 122 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - foreach ( $approved as $key ) { |
|
| 127 | - if ( empty( $stats[ $key ] ) ) { |
|
| 128 | - $stats[ $key ] = 0; |
|
| 126 | + foreach ($approved as $key) { |
|
| 127 | + if (empty($stats[$key])) { |
|
| 128 | + $stats[$key] = 0; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $stats = (object) $stats; |
| 133 | - set_transient( 'getpaid_count_comments', $stats ); |
|
| 133 | + set_transient('getpaid_count_comments', $stats); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $type Optional. Pass in customer to only return customer notes. |
| 146 | 146 | * @return WP_Comment[] |
| 147 | 147 | */ |
| 148 | - public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) { |
|
| 148 | + public function get_invoice_notes($invoice_id = 0, $type = 'all') { |
|
| 149 | 149 | |
| 150 | 150 | // Default comment args. |
| 151 | 151 | $args = array( |
@@ -155,14 +155,14 @@ discard block |
||
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | 157 | // Maybe only show customer comments. |
| 158 | - if ( $type == 'customer' ) { |
|
| 158 | + if ($type == 'customer') { |
|
| 159 | 159 | $args['meta_key'] = '_wpi_customer_note'; |
| 160 | 160 | $args['meta_value'] = 1; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type ); |
|
| 163 | + $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type); |
|
| 164 | 164 | |
| 165 | - return get_comments( $args ); |
|
| 165 | + return get_comments($args); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | * @param bool $for_customer Whether or not this comment is meant to be sent to the customer. |
| 175 | 175 | * @return int|false The new note's ID on success, false on failure. |
| 176 | 176 | */ |
| 177 | - function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){ |
|
| 177 | + function add_invoice_note($invoice, $note, $note_author, $author_email, $for_customer = false) { |
|
| 178 | 178 | |
| 179 | - do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer ); |
|
| 179 | + do_action('wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer); |
|
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | 182 | * Insert the comment. |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | ) |
| 198 | 198 | ); |
| 199 | 199 | |
| 200 | - do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer ); |
|
| 200 | + do_action('wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer); |
|
| 201 | 201 | |
| 202 | 202 | // Are we notifying the customer? |
| 203 | - if ( empty( $note_id ) || empty( $for_customer ) ) { |
|
| 203 | + if (empty($note_id) || empty($for_customer)) { |
|
| 204 | 204 | return $note_id; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 208 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) ); |
|
| 209 | - do_action( 'getpaid_new_customer_note', $invoice, $note ); |
|
| 207 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
| 208 | + do_action('wpinv_new_customer_note', array('invoice_id' => $invoice->get_id(), 'user_note' => $note)); |
|
| 209 | + do_action('getpaid_new_customer_note', $invoice, $note); |
|
| 210 | 210 | return $note_id; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * Checks if the current user cna view an invoice receipt. |
| 68 | 68 | */ |
| 69 | 69 | function wpinv_can_view_receipt( $invoice ) { |
| 70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
| 70 | + return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -1280,22 +1280,22 @@ discard block |
||
| 1280 | 1280 | */ |
| 1281 | 1281 | function getpaid_get_invoice_status_classes() { |
| 1282 | 1282 | |
| 1283 | - return apply_filters( |
|
| 1284 | - 'getpaid_get_invoice_status_classes', |
|
| 1285 | - array( |
|
| 1283 | + return apply_filters( |
|
| 1284 | + 'getpaid_get_invoice_status_classes', |
|
| 1285 | + array( |
|
| 1286 | 1286 | 'wpi-quote-declined' => 'badge-danger', |
| 1287 | 1287 | 'wpi-failed' => 'badge-danger', |
| 1288 | - 'wpi-processing' => 'badge-info', |
|
| 1289 | - 'wpi-onhold' => 'badge-warning', |
|
| 1290 | - 'wpi-quote-accepted' => 'badge-success', |
|
| 1291 | - 'publish' => 'badge-success', |
|
| 1292 | - 'wpi-renewal' => 'badge-primary', |
|
| 1288 | + 'wpi-processing' => 'badge-info', |
|
| 1289 | + 'wpi-onhold' => 'badge-warning', |
|
| 1290 | + 'wpi-quote-accepted' => 'badge-success', |
|
| 1291 | + 'publish' => 'badge-success', |
|
| 1292 | + 'wpi-renewal' => 'badge-primary', |
|
| 1293 | 1293 | 'wpi-cancelled' => 'badge-secondary', |
| 1294 | 1294 | 'wpi-pending' => 'badge-dark', |
| 1295 | 1295 | 'wpi-quote-pending' => 'badge-dark', |
| 1296 | 1296 | 'wpi-refunded' => 'badge-secondary', |
| 1297 | - ) |
|
| 1298 | - ); |
|
| 1297 | + ) |
|
| 1298 | + ); |
|
| 1299 | 1299 | |
| 1300 | 1300 | } |
| 1301 | 1301 | |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | function getpaid_get_invoice_tax_rate( $invoice, $item ) { |
| 1310 | 1310 | |
| 1311 | 1311 | $rates = getpaid_get_item_tax_rates( $item, $invoice->get_country(), $invoice->get_state() ); |
| 1312 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 1312 | + $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 1313 | 1313 | $rates = wp_list_pluck( $rates, 'rate' ); |
| 1314 | 1314 | |
| 1315 | 1315 | return array_sum( $rates ); |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | function getpaid_get_current_invoice_id() { |
| 15 | 15 | |
| 16 | 16 | // Ensure that we have an invoice key. |
| 17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
| 17 | + if (empty($_GET['invoice_key'])) { |
|
| 18 | 18 | return 0; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // Retrieve an invoice using the key. |
| 22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
| 22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
| 23 | 23 | |
| 24 | 24 | // Compare the invoice key and the parsed key. |
| 25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
| 25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
| 26 | 26 | return $invoice->get_id(); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Checks if the current user cna view an invoice. |
| 34 | 34 | */ |
| 35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
| 36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 35 | +function wpinv_user_can_view_invoice($invoice) { |
|
| 36 | + $invoice = new WPInv_Invoice($invoice); |
|
| 37 | 37 | |
| 38 | 38 | // Abort if the invoice does not exist. |
| 39 | - if ( 0 == $invoice->get_id() ) { |
|
| 39 | + if (0 == $invoice->get_id()) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Don't allow trash, draft status |
| 44 | - if ( $invoice->is_draft() ) { |
|
| 44 | + if ($invoice->is_draft()) { |
|
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
| 49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
| 49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
| 50 | 50 | return true; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // Always enable for admins.. |
| 54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
| 54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
| 55 | 55 | return true; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Else, ensure that this is their invoice. |
| 59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
| 59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
| 60 | 60 | return true; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
| 63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Checks if the current user cna view an invoice receipt. |
| 68 | 68 | */ |
| 69 | -function wpinv_can_view_receipt( $invoice ) { |
|
| 70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
| 69 | +function wpinv_can_view_receipt($invoice) { |
|
| 70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function getpaid_get_invoice_post_types() { |
| 79 | 79 | $post_types = array( |
| 80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
| 81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
| 80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
| 81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | // Ensure the quotes addon is installed. |
| 85 | - if ( ! defined( 'WPINV_QUOTES_VERSION' ) ) { |
|
| 86 | - unset( $post_types['wpi_quote'] ); |
|
| 85 | + if (!defined('WPINV_QUOTES_VERSION')) { |
|
| 86 | + unset($post_types['wpi_quote']); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
| 89 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @param string $post_type The post type to check for. |
| 97 | 97 | */ |
| 98 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
| 99 | - return is_scalar( $post_type ) && ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
| 98 | +function getpaid_is_invoice_post_type($post_type) { |
|
| 99 | + return is_scalar($post_type) && !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 107 | 107 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 108 | 108 | */ |
| 109 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
| 110 | - $data[ 'invoice_id' ] = 0; |
|
| 111 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 109 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
| 110 | + $data['invoice_id'] = 0; |
|
| 111 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -118,36 +118,36 @@ discard block |
||
| 118 | 118 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 119 | 119 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 120 | 120 | */ |
| 121 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
| 121 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
| 122 | 122 | |
| 123 | 123 | // Backwards compatibility. |
| 124 | - if ( ! empty( $data['ID'] ) ) { |
|
| 124 | + if (!empty($data['ID'])) { |
|
| 125 | 125 | $data['invoice_id'] = $data['ID']; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Do we have an invoice id? |
| 129 | - if ( empty( $data['invoice_id'] ) ) { |
|
| 130 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
| 129 | + if (empty($data['invoice_id'])) { |
|
| 130 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // Retrieve the invoice. |
| 134 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
| 134 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
| 135 | 135 | |
| 136 | 136 | // And abort if it does not exist. |
| 137 | - if ( empty( $invoice ) ) { |
|
| 138 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
| 137 | + if (empty($invoice)) { |
|
| 138 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Do not update totals for paid / refunded invoices. |
| 142 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 142 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 143 | 143 | |
| 144 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
| 145 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
| 144 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
| 145 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 150 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 151 | 151 | |
| 152 | 152 | } |
| 153 | 153 | |
@@ -158,34 +158,34 @@ discard block |
||
| 158 | 158 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 159 | 159 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 160 | 160 | */ |
| 161 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
| 161 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
| 162 | 162 | |
| 163 | 163 | // Ensure that we have invoice data. |
| 164 | - if ( empty( $data ) ) { |
|
| 164 | + if (empty($data)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // The invoice id will be provided when updating an invoice. |
| 169 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
| 169 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
| 170 | 170 | |
| 171 | 171 | // Retrieve the invoice. |
| 172 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
| 172 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
| 173 | 173 | |
| 174 | 174 | // Do we have an error? |
| 175 | - if ( ! empty( $invoice->last_error ) ) { |
|
| 176 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
| 175 | + if (!empty($invoice->last_error)) { |
|
| 176 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // Backwards compatibility (billing address). |
| 180 | - if ( ! empty( $data['user_info'] ) ) { |
|
| 180 | + if (!empty($data['user_info'])) { |
|
| 181 | 181 | |
| 182 | - foreach ( $data['user_info'] as $key => $value ) { |
|
| 182 | + foreach ($data['user_info'] as $key => $value) { |
|
| 183 | 183 | |
| 184 | - if ( $key == 'discounts' ) { |
|
| 184 | + if ($key == 'discounts') { |
|
| 185 | 185 | $value = (array) $value; |
| 186 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
| 186 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
| 187 | 187 | } else { |
| 188 | - $data[ $key ] = $value; |
|
| 188 | + $data[$key] = $value; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | } |
@@ -193,30 +193,30 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Backwards compatibility. |
| 196 | - if ( ! empty( $data['payment_details'] ) ) { |
|
| 196 | + if (!empty($data['payment_details'])) { |
|
| 197 | 197 | |
| 198 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
| 199 | - $data[ $key ] = $value; |
|
| 198 | + foreach ($data['payment_details'] as $key => $value) { |
|
| 199 | + $data[$key] = $value; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Set up the owner of the invoice. |
| 205 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
| 205 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
| 206 | 206 | |
| 207 | 207 | // Make sure the user exists. |
| 208 | - if ( ! get_userdata( $user_id ) ) { |
|
| 209 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
| 208 | + if (!get_userdata($user_id)) { |
|
| 209 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $address = wpinv_get_user_address( $user_id ); |
|
| 212 | + $address = wpinv_get_user_address($user_id); |
|
| 213 | 213 | |
| 214 | - foreach ( $address as $key => $value ) { |
|
| 214 | + foreach ($address as $key => $value) { |
|
| 215 | 215 | |
| 216 | - if ( $value == '' ) { |
|
| 217 | - $address[ $key ] = null; |
|
| 216 | + if ($value == '') { |
|
| 217 | + $address[$key] = null; |
|
| 218 | 218 | } else { |
| 219 | - $address[ $key ] = wpinv_clean( $value ); |
|
| 219 | + $address[$key] = wpinv_clean($value); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | } |
@@ -227,103 +227,103 @@ discard block |
||
| 227 | 227 | array( |
| 228 | 228 | |
| 229 | 229 | // Basic info. |
| 230 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
| 231 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
| 232 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
| 233 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
| 234 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
| 235 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
| 236 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
| 237 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
| 238 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
| 239 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
| 240 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
| 241 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
| 242 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
| 230 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
| 231 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
| 232 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
| 233 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
| 234 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
| 235 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
| 236 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
| 237 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
| 238 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
| 239 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
| 240 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
| 241 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
| 242 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
| 243 | 243 | |
| 244 | 244 | // Payment info. |
| 245 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
| 246 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
| 247 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
| 248 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
| 249 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
| 250 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
| 251 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
| 252 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
| 253 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
| 254 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
| 255 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
| 256 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
| 245 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
| 246 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
| 247 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
| 248 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
| 249 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
| 250 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
| 251 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
| 252 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
| 253 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
| 254 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
| 255 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
| 256 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | // Billing details. |
| 260 | 260 | 'user_id' => $data['user_id'], |
| 261 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
| 262 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
| 263 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
| 264 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
| 265 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
| 266 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
| 267 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
| 268 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
| 269 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
| 270 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
| 271 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
| 261 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
| 262 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
| 263 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
| 264 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
| 265 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
| 266 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
| 267 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
| 268 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
| 269 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
| 270 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
| 271 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
| 272 | 272 | |
| 273 | 273 | ) |
| 274 | 274 | |
| 275 | 275 | ); |
| 276 | 276 | |
| 277 | 277 | // Backwards compatibililty. |
| 278 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
| 278 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
| 279 | 279 | $data['items'] = array(); |
| 280 | 280 | |
| 281 | - foreach( $data['cart_details'] as $_item ) { |
|
| 281 | + foreach ($data['cart_details'] as $_item) { |
|
| 282 | 282 | |
| 283 | 283 | // Ensure that we have an item id. |
| 284 | - if ( empty( $_item['id'] ) ) { |
|
| 284 | + if (empty($_item['id'])) { |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // Retrieve the item. |
| 289 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
| 289 | + $item = new GetPaid_Form_Item($_item['id']); |
|
| 290 | 290 | |
| 291 | 291 | // Ensure that it is purchasable. |
| 292 | - if ( ! $item->can_purchase() ) { |
|
| 292 | + if (!$item->can_purchase()) { |
|
| 293 | 293 | continue; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Set quantity. |
| 297 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
| 298 | - $item->set_quantity( $_item['quantity'] ); |
|
| 297 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
| 298 | + $item->set_quantity($_item['quantity']); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | // Set price. |
| 302 | - if ( isset( $_item['item_price'] ) ) { |
|
| 303 | - $item->set_price( $_item['item_price'] ); |
|
| 302 | + if (isset($_item['item_price'])) { |
|
| 303 | + $item->set_price($_item['item_price']); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if ( isset( $_item['custom_price'] ) ) { |
|
| 307 | - $item->set_price( $_item['custom_price'] ); |
|
| 306 | + if (isset($_item['custom_price'])) { |
|
| 307 | + $item->set_price($_item['custom_price']); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Set name. |
| 311 | - if ( ! empty( $_item['name'] ) ) { |
|
| 312 | - $item->set_name( $_item['name'] ); |
|
| 311 | + if (!empty($_item['name'])) { |
|
| 312 | + $item->set_name($_item['name']); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Set description. |
| 316 | - if ( isset( $_item['description'] ) ) { |
|
| 317 | - $item->set_custom_description( $_item['description'] ); |
|
| 316 | + if (isset($_item['description'])) { |
|
| 317 | + $item->set_custom_description($_item['description']); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Set meta. |
| 321 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
| 321 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
| 322 | 322 | |
| 323 | - $item->set_item_meta( $_item['meta'] ); |
|
| 323 | + $item->set_item_meta($_item['meta']); |
|
| 324 | 324 | |
| 325 | - if ( isset( $_item['meta']['description'] ) ) { |
|
| 326 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
| 325 | + if (isset($_item['meta']['description'])) { |
|
| 326 | + $item->set_custom_description($_item['meta']['description']); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | } |
@@ -334,14 +334,14 @@ discard block |
||
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Add invoice items. |
| 337 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
| 337 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
| 338 | 338 | |
| 339 | - $invoice->set_items( array() ); |
|
| 339 | + $invoice->set_items(array()); |
|
| 340 | 340 | |
| 341 | - foreach ( $data['items'] as $item ) { |
|
| 341 | + foreach ($data['items'] as $item) { |
|
| 342 | 342 | |
| 343 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
| 344 | - $invoice->add_item( $item ); |
|
| 343 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
| 344 | + $invoice->add_item($item); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | } |
@@ -352,30 +352,30 @@ discard block |
||
| 352 | 352 | $invoice->recalculate_total(); |
| 353 | 353 | $invoice->save(); |
| 354 | 354 | |
| 355 | - if ( ! $invoice->get_id() ) { |
|
| 356 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
| 355 | + if (!$invoice->get_id()) { |
|
| 356 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | // Add private note. |
| 360 | - if ( ! empty( $data['private_note'] ) ) { |
|
| 361 | - $invoice->add_note( $data['private_note'] ); |
|
| 360 | + if (!empty($data['private_note'])) { |
|
| 361 | + $invoice->add_note($data['private_note']); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // User notes. |
| 365 | - if ( !empty( $data['user_note'] ) ) { |
|
| 366 | - $invoice->add_note( $data['user_note'], true ); |
|
| 365 | + if (!empty($data['user_note'])) { |
|
| 366 | + $invoice->add_note($data['user_note'], true); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | // Created via. |
| 370 | - if ( isset( $data['created_via'] ) ) { |
|
| 371 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
| 370 | + if (isset($data['created_via'])) { |
|
| 371 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | // Backwards compatiblity. |
| 375 | - if ( $invoice->is_quote() ) { |
|
| 375 | + if ($invoice->is_quote()) { |
|
| 376 | 376 | |
| 377 | - if ( isset( $data['valid_until'] ) ) { |
|
| 378 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
| 377 | + if (isset($data['valid_until'])) { |
|
| 378 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | } |
@@ -390,20 +390,20 @@ discard block |
||
| 390 | 390 | * @param $bool $deprecated |
| 391 | 391 | * @return WPInv_Invoice|null |
| 392 | 392 | */ |
| 393 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
| 393 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
| 394 | 394 | |
| 395 | 395 | // If we are retrieving the invoice from the cart... |
| 396 | - if ( $deprecated && empty( $invoice ) ) { |
|
| 396 | + if ($deprecated && empty($invoice)) { |
|
| 397 | 397 | $invoice = (int) getpaid_get_current_invoice_id(); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | // Retrieve the invoice. |
| 401 | - if ( ! is_a( $invoice, 'WPInv_Invoice' ) ) { |
|
| 402 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 401 | + if (!is_a($invoice, 'WPInv_Invoice')) { |
|
| 402 | + $invoice = new WPInv_Invoice($invoice); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | // Check if it exists. |
| 406 | - if ( $invoice->exists() ) { |
|
| 406 | + if ($invoice->exists()) { |
|
| 407 | 407 | return $invoice; |
| 408 | 408 | } |
| 409 | 409 | |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | * @param array $args Args to search for. |
| 417 | 417 | * @return WPInv_Invoice[]|int[]|object |
| 418 | 418 | */ |
| 419 | -function wpinv_get_invoices( $args ) { |
|
| 419 | +function wpinv_get_invoices($args) { |
|
| 420 | 420 | |
| 421 | 421 | // Prepare args. |
| 422 | 422 | $args = wp_parse_args( |
| 423 | 423 | $args, |
| 424 | 424 | array( |
| 425 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 425 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 426 | 426 | 'type' => 'wpi_invoice', |
| 427 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 427 | + 'limit' => get_option('posts_per_page'), |
|
| 428 | 428 | 'return' => 'objects', |
| 429 | 429 | ) |
| 430 | 430 | ); |
@@ -442,24 +442,24 @@ discard block |
||
| 442 | 442 | 'post__in' => 'include', |
| 443 | 443 | ); |
| 444 | 444 | |
| 445 | - foreach ( $map_legacy as $to => $from ) { |
|
| 446 | - if ( isset( $args[ $from ] ) ) { |
|
| 447 | - $args[ $to ] = $args[ $from ]; |
|
| 448 | - unset( $args[ $from ] ); |
|
| 445 | + foreach ($map_legacy as $to => $from) { |
|
| 446 | + if (isset($args[$from])) { |
|
| 447 | + $args[$to] = $args[$from]; |
|
| 448 | + unset($args[$from]); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | // Backwards compatibility. |
| 453 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
| 453 | + if (!empty($args['email']) && empty($args['user'])) { |
|
| 454 | 454 | $args['user'] = $args['email']; |
| 455 | - unset( $args['email'] ); |
|
| 455 | + unset($args['email']); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // Handle cases where the user is set as an email. |
| 459 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
| 460 | - $user = get_user_by( 'email', $args['user'] ); |
|
| 459 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
| 460 | + $user = get_user_by('email', $args['user']); |
|
| 461 | 461 | |
| 462 | - if ( $user ) { |
|
| 462 | + if ($user) { |
|
| 463 | 463 | $args['author'] = $user->user_email; |
| 464 | 464 | } |
| 465 | 465 | |
@@ -470,31 +470,31 @@ discard block |
||
| 470 | 470 | |
| 471 | 471 | // Show all posts. |
| 472 | 472 | $paginate = true; |
| 473 | - if ( isset( $args['paginate'] ) ) { |
|
| 473 | + if (isset($args['paginate'])) { |
|
| 474 | 474 | |
| 475 | 475 | $paginate = $args['paginate']; |
| 476 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
| 477 | - unset( $args['paginate'] ); |
|
| 476 | + $args['no_found_rows'] = empty($args['paginate']); |
|
| 477 | + unset($args['paginate']); |
|
| 478 | 478 | |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | // Whether to return objects or fields. |
| 482 | 482 | $return = $args['return']; |
| 483 | - unset( $args['return'] ); |
|
| 483 | + unset($args['return']); |
|
| 484 | 484 | |
| 485 | 485 | // Get invoices. |
| 486 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
| 486 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
| 487 | 487 | |
| 488 | 488 | // Prepare the results. |
| 489 | - if ( 'objects' === $return ) { |
|
| 490 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
| 491 | - } elseif ( 'self' === $return ) { |
|
| 489 | + if ('objects' === $return) { |
|
| 490 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
| 491 | + } elseif ('self' === $return) { |
|
| 492 | 492 | return $invoices; |
| 493 | 493 | } else { |
| 494 | 494 | $results = $invoices->posts; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - if ( $paginate ) { |
|
| 497 | + if ($paginate) { |
|
| 498 | 498 | return (object) array( |
| 499 | 499 | 'invoices' => $results, |
| 500 | 500 | 'total' => $invoices->found_posts, |
@@ -512,8 +512,8 @@ discard block |
||
| 512 | 512 | * @param string $transaction_id The transaction id to check. |
| 513 | 513 | * @return int Invoice id on success or 0 on failure |
| 514 | 514 | */ |
| 515 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
| 516 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
| 515 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
| 516 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -522,8 +522,8 @@ discard block |
||
| 522 | 522 | * @param string $invoice_number The invoice number to check. |
| 523 | 523 | * @return int Invoice id on success or 0 on failure |
| 524 | 524 | */ |
| 525 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
| 526 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
| 525 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
| 526 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | /** |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | * @param string $invoice_key The invoice key to check. |
| 533 | 533 | * @return int Invoice id on success or 0 on failure |
| 534 | 534 | */ |
| 535 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
| 536 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
| 535 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
| 536 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
@@ -543,19 +543,19 @@ discard block |
||
| 543 | 543 | * @param string $type Optionally filter by type i.e customer|system |
| 544 | 544 | * @return array|null |
| 545 | 545 | */ |
| 546 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
| 546 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
| 547 | 547 | |
| 548 | 548 | // Prepare the invoice. |
| 549 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 550 | - if ( empty( $invoice ) ) { |
|
| 549 | + $invoice = wpinv_get_invoice($invoice); |
|
| 550 | + if (empty($invoice)) { |
|
| 551 | 551 | return NULL; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | // Fetch notes. |
| 555 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
| 555 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
| 556 | 556 | |
| 557 | 557 | // Filter the notes. |
| 558 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
| 558 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | /** |
@@ -563,10 +563,10 @@ discard block |
||
| 563 | 563 | * |
| 564 | 564 | * @param string $post_type |
| 565 | 565 | */ |
| 566 | -function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) { |
|
| 566 | +function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') { |
|
| 567 | 567 | |
| 568 | - $label = getpaid_get_post_type_label( $post_type, false ); |
|
| 569 | - $label = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label ); |
|
| 568 | + $label = getpaid_get_post_type_label($post_type, false); |
|
| 569 | + $label = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label); |
|
| 570 | 570 | $columns = array( |
| 571 | 571 | |
| 572 | 572 | 'invoice-number' => array( |
@@ -575,22 +575,22 @@ discard block |
||
| 575 | 575 | ), |
| 576 | 576 | |
| 577 | 577 | 'created-date' => array( |
| 578 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
| 578 | + 'title' => __('Created Date', 'invoicing'), |
|
| 579 | 579 | 'class' => 'text-left' |
| 580 | 580 | ), |
| 581 | 581 | |
| 582 | 582 | 'payment-date' => array( |
| 583 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
| 583 | + 'title' => __('Payment Date', 'invoicing'), |
|
| 584 | 584 | 'class' => 'text-left' |
| 585 | 585 | ), |
| 586 | 586 | |
| 587 | 587 | 'invoice-status' => array( |
| 588 | - 'title' => __( 'Status', 'invoicing' ), |
|
| 588 | + 'title' => __('Status', 'invoicing'), |
|
| 589 | 589 | 'class' => 'text-center' |
| 590 | 590 | ), |
| 591 | 591 | |
| 592 | 592 | 'invoice-total' => array( |
| 593 | - 'title' => __( 'Total', 'invoicing' ), |
|
| 593 | + 'title' => __('Total', 'invoicing'), |
|
| 594 | 594 | 'class' => 'text-right' |
| 595 | 595 | ), |
| 596 | 596 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | ); |
| 603 | 603 | |
| 604 | - return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type ); |
|
| 604 | + return apply_filters('wpinv_user_invoices_columns', $columns, $post_type); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -611,59 +611,59 @@ discard block |
||
| 611 | 611 | |
| 612 | 612 | // Find the invoice. |
| 613 | 613 | $invoice_id = getpaid_get_current_invoice_id(); |
| 614 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 614 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 615 | 615 | |
| 616 | 616 | // Abort if non was found. |
| 617 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
| 617 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
| 618 | 618 | |
| 619 | 619 | return aui()->alert( |
| 620 | 620 | array( |
| 621 | 621 | 'type' => 'warning', |
| 622 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
| 622 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
| 623 | 623 | ) |
| 624 | 624 | ); |
| 625 | 625 | |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | // Can the user view this invoice? |
| 629 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
| 629 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
| 630 | 630 | |
| 631 | 631 | return aui()->alert( |
| 632 | 632 | array( |
| 633 | 633 | 'type' => 'warning', |
| 634 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
| 634 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
| 635 | 635 | ) |
| 636 | 636 | ); |
| 637 | 637 | |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | // Load the template. |
| 641 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
| 641 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
| 642 | 642 | |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
| 646 | 646 | * Displays the invoice history. |
| 647 | 647 | */ |
| 648 | -function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) { |
|
| 648 | +function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') { |
|
| 649 | 649 | |
| 650 | 650 | // Ensure that we have a user id. |
| 651 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
| 651 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
| 652 | 652 | $user_id = get_current_user_id(); |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - $label = getpaid_get_post_type_label( $post_type ); |
|
| 656 | - $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label ); |
|
| 655 | + $label = getpaid_get_post_type_label($post_type); |
|
| 656 | + $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label); |
|
| 657 | 657 | |
| 658 | 658 | // View user id. |
| 659 | - if ( empty( $user_id ) ) { |
|
| 659 | + if (empty($user_id)) { |
|
| 660 | 660 | |
| 661 | 661 | return aui()->alert( |
| 662 | 662 | array( |
| 663 | 663 | 'type' => 'warning', |
| 664 | 664 | 'content' => sprintf( |
| 665 | - __( 'You must be logged in to view your %s.', 'invoicing' ), |
|
| 666 | - strtolower( $label ) |
|
| 665 | + __('You must be logged in to view your %s.', 'invoicing'), |
|
| 666 | + strtolower($label) |
|
| 667 | 667 | ) |
| 668 | 668 | ) |
| 669 | 669 | ); |
@@ -674,23 +674,23 @@ discard block |
||
| 674 | 674 | $invoices = wpinv_get_invoices( |
| 675 | 675 | |
| 676 | 676 | array( |
| 677 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 677 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
| 678 | 678 | 'user' => $user_id, |
| 679 | 679 | 'paginate' => true, |
| 680 | 680 | 'type' => $post_type, |
| 681 | - 'status' => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ), |
|
| 681 | + 'status' => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)), |
|
| 682 | 682 | ) |
| 683 | 683 | |
| 684 | 684 | ); |
| 685 | 685 | |
| 686 | - if ( empty( $invoices->total ) ) { |
|
| 686 | + if (empty($invoices->total)) { |
|
| 687 | 687 | |
| 688 | 688 | return aui()->alert( |
| 689 | 689 | array( |
| 690 | 690 | 'type' => 'info', |
| 691 | 691 | 'content' => sprintf( |
| 692 | - __( 'No %s found.', 'invoicing' ), |
|
| 693 | - strtolower( $label ) |
|
| 692 | + __('No %s found.', 'invoicing'), |
|
| 693 | + strtolower($label) |
|
| 694 | 694 | ) |
| 695 | 695 | ) |
| 696 | 696 | ); |
@@ -698,38 +698,38 @@ discard block |
||
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | // Load the template. |
| 701 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) ); |
|
| 701 | + return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type')); |
|
| 702 | 702 | |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | /** |
| 706 | 706 | * Formats an invoice number given an invoice type. |
| 707 | 707 | */ |
| 708 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
| 708 | +function wpinv_format_invoice_number($number, $type = '') { |
|
| 709 | 709 | |
| 710 | 710 | // Allow other plugins to overide this. |
| 711 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
| 712 | - if ( null !== $check ) { |
|
| 711 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
| 712 | + if (null !== $check) { |
|
| 713 | 713 | return $check; |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | // Ensure that we have a numeric number. |
| 717 | - if ( ! is_numeric( $number ) ) { |
|
| 717 | + if (!is_numeric($number)) { |
|
| 718 | 718 | return $number; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | // Format the number. |
| 722 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd', 5 ) ); |
|
| 723 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
| 724 | - $prefix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) ); |
|
| 725 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
| 726 | - $postfix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) ); |
|
| 727 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
| 722 | + $padd = absint((int) wpinv_get_option('invoice_number_padd', 5)); |
|
| 723 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
| 724 | + $prefix = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type)); |
|
| 725 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
| 726 | + $postfix = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type)); |
|
| 727 | + $formatted_number = zeroise(absint($number), $padd); |
|
| 728 | 728 | |
| 729 | 729 | // Add the prefix and post fix. |
| 730 | 730 | $formatted_number = $prefix . $formatted_number . $postfix; |
| 731 | 731 | |
| 732 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
| 732 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | /** |
@@ -738,58 +738,58 @@ discard block |
||
| 738 | 738 | * @param string $type. |
| 739 | 739 | * @return int|null|bool |
| 740 | 740 | */ |
| 741 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
| 741 | +function wpinv_get_next_invoice_number($type = '') { |
|
| 742 | 742 | |
| 743 | 743 | // Allow plugins to overide this. |
| 744 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
| 745 | - if ( null !== $check ) { |
|
| 744 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
| 745 | + if (null !== $check) { |
|
| 746 | 746 | return $check; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | // Ensure sequential invoice numbers is active. |
| 750 | - if ( ! wpinv_sequential_number_active() ) { |
|
| 750 | + if (!wpinv_sequential_number_active()) { |
|
| 751 | 751 | return false; |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | // Retrieve the current number and the start number. |
| 755 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
| 756 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
| 755 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
| 756 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
| 757 | 757 | |
| 758 | 758 | // Ensure that we are starting at a positive integer. |
| 759 | - $start = max( $start, 1 ); |
|
| 759 | + $start = max($start, 1); |
|
| 760 | 760 | |
| 761 | 761 | // If this is the first invoice, use the start number. |
| 762 | - $number = max( $start, $number ); |
|
| 762 | + $number = max($start, $number); |
|
| 763 | 763 | |
| 764 | 764 | // Format the invoice number. |
| 765 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
| 765 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
| 766 | 766 | |
| 767 | 767 | // Ensure that this number is unique. |
| 768 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
| 768 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
| 769 | 769 | |
| 770 | 770 | // We found a match. Nice. |
| 771 | - if ( empty( $invoice_id ) ) { |
|
| 772 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
| 773 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
| 771 | + if (empty($invoice_id)) { |
|
| 772 | + update_option('wpinv_last_invoice_number', $number); |
|
| 773 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
| 777 | - return wpinv_get_next_invoice_number( $type ); |
|
| 776 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
| 777 | + return wpinv_get_next_invoice_number($type); |
|
| 778 | 778 | |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
| 782 | 782 | * The prefix used for invoice paths. |
| 783 | 783 | */ |
| 784 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
| 785 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
| 784 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
| 785 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | -function wpinv_generate_post_name( $post_ID ) { |
|
| 789 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
| 790 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
| 788 | +function wpinv_generate_post_name($post_ID) { |
|
| 789 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
| 790 | + $post_name = sanitize_title($prefix . $post_ID); |
|
| 791 | 791 | |
| 792 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
| 792 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
@@ -797,8 +797,8 @@ discard block |
||
| 797 | 797 | * |
| 798 | 798 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 799 | 799 | */ |
| 800 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
| 801 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 800 | +function wpinv_is_invoice_viewed($invoice) { |
|
| 801 | + $invoice = new WPInv_Invoice($invoice); |
|
| 802 | 802 | return (bool) $invoice->get_is_viewed(); |
| 803 | 803 | } |
| 804 | 804 | |
@@ -807,17 +807,17 @@ discard block |
||
| 807 | 807 | * |
| 808 | 808 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 809 | 809 | */ |
| 810 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
| 811 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 810 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
| 811 | + $invoice = new WPInv_Invoice($invoice); |
|
| 812 | 812 | |
| 813 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
| 814 | - $invoice->set_is_viewed( true ); |
|
| 813 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
| 814 | + $invoice->set_is_viewed(true); |
|
| 815 | 815 | $invoice->save(); |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | } |
| 819 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 820 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 819 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 820 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | 823 | * Processes an invoice refund. |
@@ -826,27 +826,27 @@ discard block |
||
| 826 | 826 | * @param array $status_transition |
| 827 | 827 | * @todo: descrease customer/store earnings |
| 828 | 828 | */ |
| 829 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
| 829 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
| 830 | 830 | |
| 831 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
| 831 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
| 832 | 832 | return; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | $discount_code = $invoice->get_discount_code(); |
| 836 | - if ( ! empty( $discount_code ) ) { |
|
| 837 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 836 | + if (!empty($discount_code)) { |
|
| 837 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 838 | 838 | |
| 839 | - if ( $discount->exists() ) { |
|
| 839 | + if ($discount->exists()) { |
|
| 840 | 840 | $discount->increase_usage( -1 ); |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
| 846 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
| 847 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
| 845 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
| 846 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
| 847 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
| 848 | 848 | } |
| 849 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
| 849 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
| 850 | 850 | |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -854,49 +854,49 @@ discard block |
||
| 854 | 854 | * |
| 855 | 855 | * @param int $invoice_id |
| 856 | 856 | */ |
| 857 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
| 857 | +function getpaid_process_invoice_payment($invoice_id) { |
|
| 858 | 858 | |
| 859 | 859 | // Fetch the invoice. |
| 860 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 860 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 861 | 861 | |
| 862 | 862 | // We only want to do this once. |
| 863 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
| 863 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
| 864 | 864 | return; |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
| 867 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
| 868 | 868 | |
| 869 | 869 | // Fires when processing a payment. |
| 870 | - do_action( 'getpaid_process_payment', $invoice ); |
|
| 870 | + do_action('getpaid_process_payment', $invoice); |
|
| 871 | 871 | |
| 872 | 872 | // Fire an action for each invoice item. |
| 873 | - foreach( $invoice->get_items() as $item ) { |
|
| 874 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
| 873 | + foreach ($invoice->get_items() as $item) { |
|
| 874 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | // Increase discount usage. |
| 878 | 878 | $discount_code = $invoice->get_discount_code(); |
| 879 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
| 880 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 879 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
| 880 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 881 | 881 | |
| 882 | - if ( $discount->exists() ) { |
|
| 882 | + if ($discount->exists()) { |
|
| 883 | 883 | $discount->increase_usage(); |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | // Record reverse vat. |
| 889 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
| 889 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
| 890 | 890 | |
| 891 | 891 | $taxes = $invoice->get_total_tax(); |
| 892 | - if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) { |
|
| 893 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
| 892 | + if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) { |
|
| 893 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | } |
| 899 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
| 899 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
| 900 | 900 | |
| 901 | 901 | /** |
| 902 | 902 | * Returns an array of invoice item columns |
@@ -904,13 +904,13 @@ discard block |
||
| 904 | 904 | * @param int|WPInv_Invoice $invoice |
| 905 | 905 | * @return array |
| 906 | 906 | */ |
| 907 | -function getpaid_invoice_item_columns( $invoice ) { |
|
| 907 | +function getpaid_invoice_item_columns($invoice) { |
|
| 908 | 908 | |
| 909 | 909 | // Prepare the invoice. |
| 910 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 910 | + $invoice = new WPInv_Invoice($invoice); |
|
| 911 | 911 | |
| 912 | 912 | // Abort if there is no invoice. |
| 913 | - if ( 0 == $invoice->get_id() ) { |
|
| 913 | + if (0 == $invoice->get_id()) { |
|
| 914 | 914 | return array(); |
| 915 | 915 | } |
| 916 | 916 | |
@@ -918,57 +918,57 @@ discard block |
||
| 918 | 918 | $columns = apply_filters( |
| 919 | 919 | 'getpaid_invoice_item_columns', |
| 920 | 920 | array( |
| 921 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 922 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 923 | - 'tax_rate' => __( 'Tax Rate', 'invoicing' ), |
|
| 924 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 925 | - 'subtotal' => __( 'Item Subtotal', 'invoicing' ), |
|
| 921 | + 'name' => __('Item', 'invoicing'), |
|
| 922 | + 'price' => __('Price', 'invoicing'), |
|
| 923 | + 'tax_rate' => __('Tax Rate', 'invoicing'), |
|
| 924 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 925 | + 'subtotal' => __('Item Subtotal', 'invoicing'), |
|
| 926 | 926 | ), |
| 927 | 927 | $invoice |
| 928 | 928 | ); |
| 929 | 929 | |
| 930 | 930 | // Quantities. |
| 931 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
| 931 | + if (isset($columns['quantity'])) { |
|
| 932 | 932 | |
| 933 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 934 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
| 933 | + if ('hours' == $invoice->get_template()) { |
|
| 934 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
| 938 | - unset( $columns[ 'quantity' ] ); |
|
| 937 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
| 938 | + unset($columns['quantity']); |
|
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | |
| 944 | 944 | // Price. |
| 945 | - if ( isset( $columns[ 'price' ] ) ) { |
|
| 945 | + if (isset($columns['price'])) { |
|
| 946 | 946 | |
| 947 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 948 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
| 947 | + if ('amount' == $invoice->get_template()) { |
|
| 948 | + $columns['price'] = __('Amount', 'invoicing'); |
|
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 952 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
| 951 | + if ('hours' == $invoice->get_template()) { |
|
| 952 | + $columns['price'] = __('Rate', 'invoicing'); |
|
| 953 | 953 | } |
| 954 | 954 | |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | |
| 958 | 958 | // Sub total. |
| 959 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
| 959 | + if (isset($columns['subtotal'])) { |
|
| 960 | 960 | |
| 961 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 962 | - unset( $columns[ 'subtotal' ] ); |
|
| 961 | + if ('amount' == $invoice->get_template()) { |
|
| 962 | + unset($columns['subtotal']); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | // Tax rates. |
| 968 | - if ( isset( $columns[ 'tax_rate' ] ) ) { |
|
| 968 | + if (isset($columns['tax_rate'])) { |
|
| 969 | 969 | |
| 970 | - if ( 0 == $invoice->get_tax() ) { |
|
| 971 | - unset( $columns[ 'tax_rate' ] ); |
|
| 970 | + if (0 == $invoice->get_tax()) { |
|
| 971 | + unset($columns['tax_rate']); |
|
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | } |
@@ -982,38 +982,38 @@ discard block |
||
| 982 | 982 | * @param int|WPInv_Invoice $invoice |
| 983 | 983 | * @return array |
| 984 | 984 | */ |
| 985 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
| 985 | +function getpaid_invoice_totals_rows($invoice) { |
|
| 986 | 986 | |
| 987 | 987 | // Prepare the invoice. |
| 988 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 988 | + $invoice = new WPInv_Invoice($invoice); |
|
| 989 | 989 | |
| 990 | 990 | // Abort if there is no invoice. |
| 991 | - if ( 0 == $invoice->get_id() ) { |
|
| 991 | + if (0 == $invoice->get_id()) { |
|
| 992 | 992 | return array(); |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | $totals = apply_filters( |
| 996 | 996 | 'getpaid_invoice_totals_rows', |
| 997 | 997 | array( |
| 998 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 999 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 1000 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
| 1001 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 1002 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 998 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 999 | + 'tax' => __('Tax', 'invoicing'), |
|
| 1000 | + 'fee' => __('Fee', 'invoicing'), |
|
| 1001 | + 'discount' => __('Discount', 'invoicing'), |
|
| 1002 | + 'total' => __('Total', 'invoicing'), |
|
| 1003 | 1003 | ), |
| 1004 | 1004 | $invoice |
| 1005 | 1005 | ); |
| 1006 | 1006 | |
| 1007 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
| 1008 | - unset( $totals['tax'] ); |
|
| 1007 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
| 1008 | + unset($totals['tax']); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - if ( 0 == $invoice->get_total_fees() && isset( $totals['fee'] ) ) { |
|
| 1012 | - unset( $totals['fee'] ); |
|
| 1011 | + if (0 == $invoice->get_total_fees() && isset($totals['fee'])) { |
|
| 1012 | + unset($totals['fee']); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - if ( 0 == $invoice->get_total_discount() && isset( $totals['discount'] ) ) { |
|
| 1016 | - unset( $totals['discount'] ); |
|
| 1015 | + if (0 == $invoice->get_total_discount() && isset($totals['discount'])) { |
|
| 1016 | + unset($totals['discount']); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | return $totals; |
@@ -1024,47 +1024,47 @@ discard block |
||
| 1024 | 1024 | * |
| 1025 | 1025 | * @param WPInv_Invoice $invoice |
| 1026 | 1026 | */ |
| 1027 | -function getpaid_new_invoice( $invoice ) { |
|
| 1027 | +function getpaid_new_invoice($invoice) { |
|
| 1028 | 1028 | |
| 1029 | - if ( ! $invoice->get_status() ) { |
|
| 1029 | + if (!$invoice->get_status()) { |
|
| 1030 | 1030 | return; |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | // Add an invoice created note. |
| 1034 | 1034 | $invoice->add_note( |
| 1035 | 1035 | sprintf( |
| 1036 | - __( '%s created with the status "%s".', 'invoicing' ), |
|
| 1037 | - ucfirst( $invoice->get_invoice_quote_type() ), |
|
| 1038 | - wpinv_status_nicename( $invoice->get_status(), $invoice ) |
|
| 1036 | + __('%s created with the status "%s".', 'invoicing'), |
|
| 1037 | + ucfirst($invoice->get_invoice_quote_type()), |
|
| 1038 | + wpinv_status_nicename($invoice->get_status(), $invoice) |
|
| 1039 | 1039 | ) |
| 1040 | 1040 | ); |
| 1041 | 1041 | |
| 1042 | 1042 | } |
| 1043 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
| 1043 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
| 1044 | 1044 | |
| 1045 | 1045 | /** |
| 1046 | 1046 | * This function updates invoice caches. |
| 1047 | 1047 | * |
| 1048 | 1048 | * @param WPInv_Invoice $invoice |
| 1049 | 1049 | */ |
| 1050 | -function getpaid_update_invoice_caches( $invoice ) { |
|
| 1050 | +function getpaid_update_invoice_caches($invoice) { |
|
| 1051 | 1051 | |
| 1052 | 1052 | // Cache invoice number. |
| 1053 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
| 1053 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
| 1054 | 1054 | |
| 1055 | 1055 | // Cache invoice key. |
| 1056 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
| 1056 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
| 1057 | 1057 | |
| 1058 | 1058 | // (Maybe) cache transaction id. |
| 1059 | 1059 | $transaction_id = $invoice->get_transaction_id(); |
| 1060 | 1060 | |
| 1061 | - if ( ! empty( $transaction_id ) ) { |
|
| 1062 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
| 1061 | + if (!empty($transaction_id)) { |
|
| 1062 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | } |
| 1066 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
| 1067 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
| 1066 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
| 1067 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
| 1068 | 1068 | |
| 1069 | 1069 | /** |
| 1070 | 1070 | * Duplicates an invoice. |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
| 1075 | 1075 | * @return WPInv_Invoice The new invoice. |
| 1076 | 1076 | */ |
| 1077 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
| 1077 | +function getpaid_duplicate_invoice($old_invoice) { |
|
| 1078 | 1078 | |
| 1079 | 1079 | // Create the new invoice. |
| 1080 | 1080 | $invoice = new WPInv_Invoice(); |
@@ -1135,121 +1135,121 @@ discard block |
||
| 1135 | 1135 | * @param WPInv_Invoice $invoice |
| 1136 | 1136 | * @return array |
| 1137 | 1137 | */ |
| 1138 | -function getpaid_get_invoice_meta( $invoice ) { |
|
| 1138 | +function getpaid_get_invoice_meta($invoice) { |
|
| 1139 | 1139 | |
| 1140 | 1140 | // Load the invoice meta. |
| 1141 | 1141 | $meta = array( |
| 1142 | 1142 | |
| 1143 | 1143 | 'number' => array( |
| 1144 | 1144 | 'label' => sprintf( |
| 1145 | - __( '%s Number', 'invoicing' ), |
|
| 1146 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1145 | + __('%s Number', 'invoicing'), |
|
| 1146 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1147 | 1147 | ), |
| 1148 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
| 1148 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
| 1149 | 1149 | ), |
| 1150 | 1150 | |
| 1151 | 1151 | 'status' => array( |
| 1152 | 1152 | 'label' => sprintf( |
| 1153 | - __( '%s Status', 'invoicing' ), |
|
| 1154 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1153 | + __('%s Status', 'invoicing'), |
|
| 1154 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1155 | 1155 | ), |
| 1156 | 1156 | 'value' => $invoice->get_status_label_html(), |
| 1157 | 1157 | ), |
| 1158 | 1158 | |
| 1159 | 1159 | 'date' => array( |
| 1160 | 1160 | 'label' => sprintf( |
| 1161 | - __( '%s Date', 'invoicing' ), |
|
| 1162 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1161 | + __('%s Date', 'invoicing'), |
|
| 1162 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1163 | 1163 | ), |
| 1164 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
| 1164 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
| 1165 | 1165 | ), |
| 1166 | 1166 | |
| 1167 | 1167 | 'date_paid' => array( |
| 1168 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
| 1169 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
| 1168 | + 'label' => __('Paid On', 'invoicing'), |
|
| 1169 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
| 1170 | 1170 | ), |
| 1171 | 1171 | |
| 1172 | 1172 | 'gateway' => array( |
| 1173 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
| 1174 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
| 1173 | + 'label' => __('Payment Method', 'invoicing'), |
|
| 1174 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
| 1175 | 1175 | ), |
| 1176 | 1176 | |
| 1177 | 1177 | 'transaction_id' => array( |
| 1178 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
| 1179 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
| 1178 | + 'label' => __('Transaction ID', 'invoicing'), |
|
| 1179 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
| 1180 | 1180 | ), |
| 1181 | 1181 | |
| 1182 | 1182 | 'due_date' => array( |
| 1183 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
| 1184 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
| 1183 | + 'label' => __('Due Date', 'invoicing'), |
|
| 1184 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
| 1185 | 1185 | ), |
| 1186 | 1186 | |
| 1187 | 1187 | 'vat_number' => array( |
| 1188 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 1189 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
| 1188 | + 'label' => __('VAT Number', 'invoicing'), |
|
| 1189 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
| 1190 | 1190 | ), |
| 1191 | 1191 | |
| 1192 | 1192 | ); |
| 1193 | 1193 | |
| 1194 | 1194 | // If it is not paid, remove the date of payment. |
| 1195 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 1196 | - unset( $meta[ 'date_paid' ] ); |
|
| 1197 | - unset( $meta[ 'transaction_id' ] ); |
|
| 1195 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 1196 | + unset($meta['date_paid']); |
|
| 1197 | + unset($meta['transaction_id']); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
| 1201 | - unset( $meta[ 'gateway' ] ); |
|
| 1200 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
| 1201 | + unset($meta['gateway']); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | // Only display the due date if due dates are enabled. |
| 1205 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
| 1206 | - unset( $meta[ 'due_date' ] ); |
|
| 1205 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
| 1206 | + unset($meta['due_date']); |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | // Only display the vat number if taxes are enabled. |
| 1210 | - if ( ! wpinv_use_taxes() ) { |
|
| 1211 | - unset( $meta[ 'vat_number' ] ); |
|
| 1210 | + if (!wpinv_use_taxes()) { |
|
| 1211 | + unset($meta['vat_number']); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | // Link to the parent invoice. |
| 1215 | - if ( $invoice->get_parent_id() > 0 ) { |
|
| 1215 | + if ($invoice->get_parent_id() > 0) { |
|
| 1216 | 1216 | |
| 1217 | - $meta[ 'parent' ] = array( |
|
| 1217 | + $meta['parent'] = array( |
|
| 1218 | 1218 | |
| 1219 | 1219 | 'label' => sprintf( |
| 1220 | - __( 'Parent %s', 'invoicing' ), |
|
| 1221 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 1220 | + __('Parent %s', 'invoicing'), |
|
| 1221 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 1222 | 1222 | ), |
| 1223 | 1223 | |
| 1224 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
| 1224 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
| 1225 | 1225 | |
| 1226 | 1226 | ); |
| 1227 | 1227 | |
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | |
| 1231 | - if ( $invoice->is_recurring() ) { |
|
| 1231 | + if ($invoice->is_recurring()) { |
|
| 1232 | 1232 | |
| 1233 | - $subscription = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 1234 | - if ( ! empty ( $subscription ) && ! is_array( $subscription ) && $subscription->exists() ) { |
|
| 1233 | + $subscription = getpaid_get_invoice_subscriptions($invoice); |
|
| 1234 | + if (!empty ($subscription) && !is_array($subscription) && $subscription->exists()) { |
|
| 1235 | 1235 | |
| 1236 | 1236 | // Display the renewal date. |
| 1237 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
| 1237 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
| 1238 | 1238 | |
| 1239 | - $meta[ 'renewal_date' ] = array( |
|
| 1240 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 1241 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
| 1239 | + $meta['renewal_date'] = array( |
|
| 1240 | + 'label' => __('Renews On', 'invoicing'), |
|
| 1241 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
| 1242 | 1242 | ); |
| 1243 | 1243 | |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - if ( $invoice->is_parent() ) { |
|
| 1246 | + if ($invoice->is_parent()) { |
|
| 1247 | 1247 | |
| 1248 | 1248 | // Display the recurring amount. |
| 1249 | - $meta[ 'recurring_total' ] = array( |
|
| 1249 | + $meta['recurring_total'] = array( |
|
| 1250 | 1250 | |
| 1251 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
| 1252 | - 'value' => wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ), |
|
| 1251 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
| 1252 | + 'value' => wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency()), |
|
| 1253 | 1253 | |
| 1254 | 1254 | ); |
| 1255 | 1255 | |
@@ -1259,15 +1259,15 @@ discard block |
||
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | // Add the invoice total to the meta. |
| 1262 | - $meta[ 'invoice_total' ] = array( |
|
| 1262 | + $meta['invoice_total'] = array( |
|
| 1263 | 1263 | |
| 1264 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
| 1265 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
| 1264 | + 'label' => __('Total Amount', 'invoicing'), |
|
| 1265 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
| 1266 | 1266 | |
| 1267 | 1267 | ); |
| 1268 | 1268 | |
| 1269 | 1269 | // Provide a way for third party plugins to filter the meta. |
| 1270 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
| 1270 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
| 1271 | 1271 | |
| 1272 | 1272 | return $meta; |
| 1273 | 1273 | |
@@ -1306,12 +1306,12 @@ discard block |
||
| 1306 | 1306 | * @param GetPaid_Form_Item $item |
| 1307 | 1307 | * @return float |
| 1308 | 1308 | */ |
| 1309 | -function getpaid_get_invoice_tax_rate( $invoice, $item ) { |
|
| 1309 | +function getpaid_get_invoice_tax_rate($invoice, $item) { |
|
| 1310 | 1310 | |
| 1311 | - $rates = getpaid_get_item_tax_rates( $item, $invoice->get_country(), $invoice->get_state() ); |
|
| 1312 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 1313 | - $rates = wp_list_pluck( $rates, 'rate' ); |
|
| 1311 | + $rates = getpaid_get_item_tax_rates($item, $invoice->get_country(), $invoice->get_state()); |
|
| 1312 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
| 1313 | + $rates = wp_list_pluck($rates, 'rate'); |
|
| 1314 | 1314 | |
| 1315 | - return array_sum( $rates ); |
|
| 1315 | + return array_sum($rates); |
|
| 1316 | 1316 | |
| 1317 | 1317 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; // Exit if accessed directly |
|
| 10 | + exit; // Exit if accessed directly |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | class GetPaid_Meta_Box_Payment_Form { |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * Output the metabox. |
|
| 20 | - * |
|
| 21 | - * @param WP_Post $post |
|
| 22 | - */ |
|
| 19 | + * Output the metabox. |
|
| 20 | + * |
|
| 21 | + * @param WP_Post $post |
|
| 22 | + */ |
|
| 23 | 23 | public static function output( $post ) { |
| 24 | 24 | ?> |
| 25 | 25 | <style> |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | - * Save meta box data. |
|
| 106 | - * |
|
| 107 | - * @param int $post_id |
|
| 108 | - */ |
|
| 109 | - public static function save( $post_id ) { |
|
| 105 | + * Save meta box data. |
|
| 106 | + * |
|
| 107 | + * @param int $post_id |
|
| 108 | + */ |
|
| 109 | + public static function save( $post_id ) { |
|
| 110 | 110 | |
| 111 | 111 | // Prepare the form. |
| 112 | 112 | $form = new GetPaid_Payment_Form( $post_id ); |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | - * Converts an array fo form items to objects. |
|
| 141 | - * |
|
| 142 | - * @param array $items |
|
| 143 | - */ |
|
| 144 | - public static function item_to_objects( $items ) { |
|
| 140 | + * Converts an array fo form items to objects. |
|
| 141 | + * |
|
| 142 | + * @param array $items |
|
| 143 | + */ |
|
| 144 | + public static function item_to_objects( $items ) { |
|
| 145 | 145 | |
| 146 | 146 | $objects = array(); |
| 147 | 147 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; // Exit if accessed directly |
| 11 | 11 | } |
| 12 | 12 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @param WP_Post $post |
| 22 | 22 | */ |
| 23 | - public static function output( $post ) { |
|
| 23 | + public static function output($post) { |
|
| 24 | 24 | ?> |
| 25 | 25 | <style> |
| 26 | 26 | .wpinv-form-builder-edit-field-wrapper label.d-block > span:first-child{ |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | <div class="col-sm-4"> |
| 34 | 34 | |
| 35 | 35 | <!-- Builder tabs --> |
| 36 | - <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button> |
|
| 36 | + <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button> |
|
| 37 | 37 | |
| 38 | 38 | <!-- Builder tab content --> |
| 39 | 39 | <div class="mt-4"> |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | <!-- Available builder elements --> |
| 42 | 42 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
| 43 | 43 | <div class="wpinv-form-builder-add-field-types"> |
| 44 | - <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
|
| 44 | + <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small> |
|
| 45 | 45 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
| 46 | 46 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
| 47 | 47 | <button class="button btn text-dark"> |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | <!-- Edit an element --> |
| 57 | 57 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;"> |
| 58 | 58 | <div class="wpinv-form-builder-edit-field-wrapper"> |
| 59 | - <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
|
| 60 | - <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?> |
|
| 59 | + <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?> |
|
| 60 | + <?php do_action('getpaid_payment_form_edit_element_template', $post); ?> |
|
| 61 | 61 | <div class='form-group'> |
| 62 | - <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ) ?></label> |
|
| 62 | + <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing') ?></label> |
|
| 63 | 63 | <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'> |
| 64 | - <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option> |
|
| 65 | - <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option> |
|
| 66 | - <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option> |
|
| 64 | + <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option> |
|
| 65 | + <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option> |
|
| 66 | + <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option> |
|
| 67 | 67 | </select> |
| 68 | 68 | </div> |
| 69 | 69 | <div> |
| 70 | - <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button> |
|
| 70 | + <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button> |
|
| 71 | 71 | </div> |
| 72 | 72 | </div> |
| 73 | 73 | </div> |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | </div> |
| 78 | 78 | <div class="col-sm-8 border-left"> |
| 79 | - <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
|
| 80 | - <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
|
| 79 | + <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small> |
|
| 80 | + <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p> |
|
| 81 | 81 | |
| 82 | 82 | <div class="container-fluid"> |
| 83 | 83 | <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;"> |
| 84 | 84 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element && active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
| 85 | 85 | <div class="wpinv-form-builder-element-preview-inner"> |
| 86 | 86 | <div class="wpinv-payment-form-field-preview-overlay"></div> |
| 87 | - <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
|
| 87 | + <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?> |
|
| 88 | 88 | </div> |
| 89 | 89 | </div> |
| 90 | 90 | </draggable> |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | </div> |
| 99 | 99 | <?php |
| 100 | 100 | |
| 101 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 101 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -106,33 +106,33 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param int $post_id |
| 108 | 108 | */ |
| 109 | - public static function save( $post_id ) { |
|
| 109 | + public static function save($post_id) { |
|
| 110 | 110 | |
| 111 | 111 | // Prepare the form. |
| 112 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
| 112 | + $form = new GetPaid_Payment_Form($post_id); |
|
| 113 | 113 | |
| 114 | 114 | // Fetch form items. |
| 115 | - $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true ); |
|
| 115 | + $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true); |
|
| 116 | 116 | |
| 117 | 117 | // Ensure that we have an array... |
| 118 | - if ( empty( $form_items ) ) { |
|
| 118 | + if (empty($form_items)) { |
|
| 119 | 119 | $form_items = array(); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // Add it to the form. |
| 123 | - $form->set_items( self::item_to_objects( $form_items ) ); |
|
| 123 | + $form->set_items(self::item_to_objects($form_items)); |
|
| 124 | 124 | |
| 125 | 125 | // Save form elements. |
| 126 | - $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true ); |
|
| 127 | - if ( empty( $form_elements ) ) { |
|
| 126 | + $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true); |
|
| 127 | + if (empty($form_elements)) { |
|
| 128 | 128 | $form_elements = array(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $form->set_elements( $form_elements ); |
|
| 131 | + $form->set_elements($form_elements); |
|
| 132 | 132 | |
| 133 | 133 | // Persist data to the datastore. |
| 134 | 134 | $form->save(); |
| 135 | - do_action( 'getpaid_payment_form_metabox_save', $post_id, $form ); |
|
| 135 | + do_action('getpaid_payment_form_metabox_save', $post_id, $form); |
|
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | |
@@ -141,14 +141,14 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @param array $items |
| 143 | 143 | */ |
| 144 | - public static function item_to_objects( $items ) { |
|
| 144 | + public static function item_to_objects($items) { |
|
| 145 | 145 | |
| 146 | 146 | $objects = array(); |
| 147 | 147 | |
| 148 | - foreach ( $items as $item ) { |
|
| 149 | - $_item = new GetPaid_Form_Item( $item['id'] ); |
|
| 150 | - $_item->set_allow_quantities( (bool) $item['allow_quantities'] ); |
|
| 151 | - $_item->set_is_required( (bool) $item['required'] ); |
|
| 148 | + foreach ($items as $item) { |
|
| 149 | + $_item = new GetPaid_Form_Item($item['id']); |
|
| 150 | + $_item->set_allow_quantities((bool) $item['allow_quantities']); |
|
| 151 | + $_item->set_is_required((bool) $item['required']); |
|
| 152 | 152 | $objects[] = $_item; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -13,168 +13,168 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class GetPaid_Tax { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Calculates tax for a line item. |
|
| 18 | - * |
|
| 19 | - * @param float $price The price to calc tax on. |
|
| 20 | - * @param array $rates The rates to apply. |
|
| 21 | - * @param boolean $price_includes_tax Whether the passed price has taxes included. |
|
| 22 | - * @return array Array of tax name => tax amount. |
|
| 23 | - */ |
|
| 24 | - public static function calc_tax( $price, $rates, $price_includes_tax = false ) { |
|
| 25 | - |
|
| 26 | - if ( $price_includes_tax ) { |
|
| 27 | - $taxes = self::calc_inclusive_tax( $price, $rates ); |
|
| 28 | - } else { |
|
| 29 | - $taxes = self::calc_exclusive_tax( $price, $rates ); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax ); |
|
| 33 | - |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Calc tax from inclusive price. |
|
| 38 | - * |
|
| 39 | - * @param float $price Price to calculate tax for. |
|
| 40 | - * @param array $rates Array of tax rates. |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - public static function calc_inclusive_tax( $price, $rates ) { |
|
| 44 | - $taxes = array(); |
|
| 45 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 46 | - |
|
| 47 | - // Add tax rates. |
|
| 48 | - $tax_rate = 1 + ( array_sum( $tax_rates ) / 100 ); |
|
| 49 | - |
|
| 50 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 51 | - $the_rate = ( $rate / 100 ) / $tax_rate; |
|
| 52 | - $net_price = $price - ( $the_rate * $price ); |
|
| 53 | - $tax_amount = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price ); |
|
| 54 | - $taxes[ $name ] = $tax_amount; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - // Round all taxes to precision (4DP) before passing them back. |
|
| 58 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 59 | - |
|
| 60 | - return $taxes; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Calc tax from exclusive price. |
|
| 65 | - * |
|
| 66 | - * @param float $price Price to calculate tax for. |
|
| 67 | - * @param array $rates Array of tax rates. |
|
| 68 | - * @return array |
|
| 69 | - */ |
|
| 70 | - public static function calc_exclusive_tax( $price, $rates ) { |
|
| 71 | - $taxes = array(); |
|
| 72 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 73 | - |
|
| 74 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 75 | - |
|
| 76 | - $tax_amount = $price * ( $rate / 100 ); |
|
| 77 | - $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price ); |
|
| 78 | - |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - // Round all taxes to precision (4DP) before passing them back. |
|
| 82 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 83 | - |
|
| 84 | - return $taxes; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Get's an array of all tax rates. |
|
| 89 | - * |
|
| 90 | - * @return array |
|
| 91 | - */ |
|
| 92 | - public static function get_all_tax_rates() { |
|
| 93 | - |
|
| 94 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 95 | - |
|
| 96 | - return apply_filters( |
|
| 97 | - 'getpaid_get_all_tax_rates', |
|
| 98 | - array_filter( wpinv_parse_list( $rates ) ) |
|
| 99 | - ); |
|
| 100 | - |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Get's an array of default tax rates. |
|
| 105 | - * |
|
| 106 | - * @return array |
|
| 107 | - */ |
|
| 108 | - public static function get_default_tax_rates() { |
|
| 109 | - |
|
| 110 | - return apply_filters( |
|
| 111 | - 'getpaid_get_default_tax_rates', |
|
| 112 | - array( |
|
| 113 | - array( |
|
| 114 | - 'country' => wpinv_get_default_country(), |
|
| 115 | - 'state' => wpinv_get_default_state(), |
|
| 116 | - 'global' => true, |
|
| 117 | - 'rate' => wpinv_get_default_tax_rate(), |
|
| 118 | - 'name' => __( 'Base Tax', 'invoicing' ), |
|
| 119 | - ) |
|
| 120 | - ) |
|
| 121 | - ); |
|
| 122 | - |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Get's an array of tax rates for a given address. |
|
| 127 | - * |
|
| 128 | - * @param string $country |
|
| 129 | - * @param string $state |
|
| 130 | - * @return array |
|
| 131 | - */ |
|
| 132 | - public static function get_address_tax_rates( $country, $state ) { |
|
| 133 | - |
|
| 134 | - $all_tax_rates = self::get_all_tax_rates(); |
|
| 135 | - $matching_rates = array_merge( |
|
| 136 | - wp_list_filter( $all_tax_rates, array( 'country' => $country ) ), |
|
| 137 | - wp_list_filter( $all_tax_rates, array( 'country' => '' ) ) |
|
| 138 | - ); |
|
| 139 | - |
|
| 140 | - foreach ( $matching_rates as $i => $rate ) { |
|
| 141 | - |
|
| 142 | - $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) ); |
|
| 143 | - if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) { |
|
| 144 | - unset( $matching_rates[ $i ] ); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state ); |
|
| 150 | - |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Sums a set of taxes to form a single total. Result is rounded to precision. |
|
| 155 | - * |
|
| 156 | - * @param array $taxes Array of taxes. |
|
| 157 | - * @return float |
|
| 158 | - */ |
|
| 159 | - public static function get_tax_total( $taxes ) { |
|
| 160 | - return self::round( array_sum( $taxes ) ); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Round to precision. |
|
| 165 | - * |
|
| 166 | - * Filter example: to return rounding to .5 cents you'd use: |
|
| 167 | - * |
|
| 168 | - * function euro_5cent_rounding( $in ) { |
|
| 169 | - * return round( $in / 5, 2 ) * 5; |
|
| 170 | - * } |
|
| 171 | - * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' ); |
|
| 172 | - * |
|
| 173 | - * @param float|int $in Value to round. |
|
| 174 | - * @return float |
|
| 175 | - */ |
|
| 176 | - public static function round( $in ) { |
|
| 177 | - return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in ); |
|
| 178 | - } |
|
| 16 | + /** |
|
| 17 | + * Calculates tax for a line item. |
|
| 18 | + * |
|
| 19 | + * @param float $price The price to calc tax on. |
|
| 20 | + * @param array $rates The rates to apply. |
|
| 21 | + * @param boolean $price_includes_tax Whether the passed price has taxes included. |
|
| 22 | + * @return array Array of tax name => tax amount. |
|
| 23 | + */ |
|
| 24 | + public static function calc_tax( $price, $rates, $price_includes_tax = false ) { |
|
| 25 | + |
|
| 26 | + if ( $price_includes_tax ) { |
|
| 27 | + $taxes = self::calc_inclusive_tax( $price, $rates ); |
|
| 28 | + } else { |
|
| 29 | + $taxes = self::calc_exclusive_tax( $price, $rates ); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax ); |
|
| 33 | + |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Calc tax from inclusive price. |
|
| 38 | + * |
|
| 39 | + * @param float $price Price to calculate tax for. |
|
| 40 | + * @param array $rates Array of tax rates. |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + public static function calc_inclusive_tax( $price, $rates ) { |
|
| 44 | + $taxes = array(); |
|
| 45 | + $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 46 | + |
|
| 47 | + // Add tax rates. |
|
| 48 | + $tax_rate = 1 + ( array_sum( $tax_rates ) / 100 ); |
|
| 49 | + |
|
| 50 | + foreach ( $tax_rates as $name => $rate ) { |
|
| 51 | + $the_rate = ( $rate / 100 ) / $tax_rate; |
|
| 52 | + $net_price = $price - ( $the_rate * $price ); |
|
| 53 | + $tax_amount = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price ); |
|
| 54 | + $taxes[ $name ] = $tax_amount; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + // Round all taxes to precision (4DP) before passing them back. |
|
| 58 | + $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 59 | + |
|
| 60 | + return $taxes; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Calc tax from exclusive price. |
|
| 65 | + * |
|
| 66 | + * @param float $price Price to calculate tax for. |
|
| 67 | + * @param array $rates Array of tax rates. |
|
| 68 | + * @return array |
|
| 69 | + */ |
|
| 70 | + public static function calc_exclusive_tax( $price, $rates ) { |
|
| 71 | + $taxes = array(); |
|
| 72 | + $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 73 | + |
|
| 74 | + foreach ( $tax_rates as $name => $rate ) { |
|
| 75 | + |
|
| 76 | + $tax_amount = $price * ( $rate / 100 ); |
|
| 77 | + $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price ); |
|
| 78 | + |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + // Round all taxes to precision (4DP) before passing them back. |
|
| 82 | + $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 83 | + |
|
| 84 | + return $taxes; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Get's an array of all tax rates. |
|
| 89 | + * |
|
| 90 | + * @return array |
|
| 91 | + */ |
|
| 92 | + public static function get_all_tax_rates() { |
|
| 93 | + |
|
| 94 | + $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 95 | + |
|
| 96 | + return apply_filters( |
|
| 97 | + 'getpaid_get_all_tax_rates', |
|
| 98 | + array_filter( wpinv_parse_list( $rates ) ) |
|
| 99 | + ); |
|
| 100 | + |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Get's an array of default tax rates. |
|
| 105 | + * |
|
| 106 | + * @return array |
|
| 107 | + */ |
|
| 108 | + public static function get_default_tax_rates() { |
|
| 109 | + |
|
| 110 | + return apply_filters( |
|
| 111 | + 'getpaid_get_default_tax_rates', |
|
| 112 | + array( |
|
| 113 | + array( |
|
| 114 | + 'country' => wpinv_get_default_country(), |
|
| 115 | + 'state' => wpinv_get_default_state(), |
|
| 116 | + 'global' => true, |
|
| 117 | + 'rate' => wpinv_get_default_tax_rate(), |
|
| 118 | + 'name' => __( 'Base Tax', 'invoicing' ), |
|
| 119 | + ) |
|
| 120 | + ) |
|
| 121 | + ); |
|
| 122 | + |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Get's an array of tax rates for a given address. |
|
| 127 | + * |
|
| 128 | + * @param string $country |
|
| 129 | + * @param string $state |
|
| 130 | + * @return array |
|
| 131 | + */ |
|
| 132 | + public static function get_address_tax_rates( $country, $state ) { |
|
| 133 | + |
|
| 134 | + $all_tax_rates = self::get_all_tax_rates(); |
|
| 135 | + $matching_rates = array_merge( |
|
| 136 | + wp_list_filter( $all_tax_rates, array( 'country' => $country ) ), |
|
| 137 | + wp_list_filter( $all_tax_rates, array( 'country' => '' ) ) |
|
| 138 | + ); |
|
| 139 | + |
|
| 140 | + foreach ( $matching_rates as $i => $rate ) { |
|
| 141 | + |
|
| 142 | + $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) ); |
|
| 143 | + if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) { |
|
| 144 | + unset( $matching_rates[ $i ] ); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state ); |
|
| 150 | + |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Sums a set of taxes to form a single total. Result is rounded to precision. |
|
| 155 | + * |
|
| 156 | + * @param array $taxes Array of taxes. |
|
| 157 | + * @return float |
|
| 158 | + */ |
|
| 159 | + public static function get_tax_total( $taxes ) { |
|
| 160 | + return self::round( array_sum( $taxes ) ); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Round to precision. |
|
| 165 | + * |
|
| 166 | + * Filter example: to return rounding to .5 cents you'd use: |
|
| 167 | + * |
|
| 168 | + * function euro_5cent_rounding( $in ) { |
|
| 169 | + * return round( $in / 5, 2 ) * 5; |
|
| 170 | + * } |
|
| 171 | + * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' ); |
|
| 172 | + * |
|
| 173 | + * @param float|int $in Value to round. |
|
| 174 | + * @return float |
|
| 175 | + */ |
|
| 176 | + public static function round( $in ) { |
|
| 177 | + return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in ); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Class GetPaid_Tax |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | * @param boolean $price_includes_tax Whether the passed price has taxes included. |
| 22 | 22 | * @return array Array of tax name => tax amount. |
| 23 | 23 | */ |
| 24 | - public static function calc_tax( $price, $rates, $price_includes_tax = false ) { |
|
| 24 | + public static function calc_tax($price, $rates, $price_includes_tax = false) { |
|
| 25 | 25 | |
| 26 | - if ( $price_includes_tax ) { |
|
| 27 | - $taxes = self::calc_inclusive_tax( $price, $rates ); |
|
| 26 | + if ($price_includes_tax) { |
|
| 27 | + $taxes = self::calc_inclusive_tax($price, $rates); |
|
| 28 | 28 | } else { |
| 29 | - $taxes = self::calc_exclusive_tax( $price, $rates ); |
|
| 29 | + $taxes = self::calc_exclusive_tax($price, $rates); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax ); |
|
| 32 | + return apply_filters('getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax); |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,22 +40,22 @@ discard block |
||
| 40 | 40 | * @param array $rates Array of tax rates. |
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | - public static function calc_inclusive_tax( $price, $rates ) { |
|
| 43 | + public static function calc_inclusive_tax($price, $rates) { |
|
| 44 | 44 | $taxes = array(); |
| 45 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 45 | + $tax_rates = wp_list_pluck($rates, 'rate', 'name'); |
|
| 46 | 46 | |
| 47 | 47 | // Add tax rates. |
| 48 | - $tax_rate = 1 + ( array_sum( $tax_rates ) / 100 ); |
|
| 48 | + $tax_rate = 1 + (array_sum($tax_rates) / 100); |
|
| 49 | 49 | |
| 50 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 51 | - $the_rate = ( $rate / 100 ) / $tax_rate; |
|
| 52 | - $net_price = $price - ( $the_rate * $price ); |
|
| 53 | - $tax_amount = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price ); |
|
| 54 | - $taxes[ $name ] = $tax_amount; |
|
| 50 | + foreach ($tax_rates as $name => $rate) { |
|
| 51 | + $the_rate = ($rate / 100) / $tax_rate; |
|
| 52 | + $net_price = $price - ($the_rate * $price); |
|
| 53 | + $tax_amount = apply_filters('getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price); |
|
| 54 | + $taxes[$name] = $tax_amount; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Round all taxes to precision (4DP) before passing them back. |
| 58 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 58 | + $taxes = array_map(array(__CLASS__, 'round'), $taxes); |
|
| 59 | 59 | |
| 60 | 60 | return $taxes; |
| 61 | 61 | } |
@@ -67,19 +67,19 @@ discard block |
||
| 67 | 67 | * @param array $rates Array of tax rates. |
| 68 | 68 | * @return array |
| 69 | 69 | */ |
| 70 | - public static function calc_exclusive_tax( $price, $rates ) { |
|
| 70 | + public static function calc_exclusive_tax($price, $rates) { |
|
| 71 | 71 | $taxes = array(); |
| 72 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 72 | + $tax_rates = wp_list_pluck($rates, 'rate', 'name'); |
|
| 73 | 73 | |
| 74 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 74 | + foreach ($tax_rates as $name => $rate) { |
|
| 75 | 75 | |
| 76 | - $tax_amount = $price * ( $rate / 100 ); |
|
| 77 | - $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price ); |
|
| 76 | + $tax_amount = $price * ($rate / 100); |
|
| 77 | + $taxes[$name] = apply_filters('getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Round all taxes to precision (4DP) before passing them back. |
| 82 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 82 | + $taxes = array_map(array(__CLASS__, 'round'), $taxes); |
|
| 83 | 83 | |
| 84 | 84 | return $taxes; |
| 85 | 85 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public static function get_all_tax_rates() { |
| 93 | 93 | |
| 94 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 94 | + $rates = get_option('wpinv_tax_rates', array()); |
|
| 95 | 95 | |
| 96 | 96 | return apply_filters( |
| 97 | 97 | 'getpaid_get_all_tax_rates', |
| 98 | - array_filter( wpinv_parse_list( $rates ) ) |
|
| 98 | + array_filter(wpinv_parse_list($rates)) |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | 101 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'state' => wpinv_get_default_state(), |
| 116 | 116 | 'global' => true, |
| 117 | 117 | 'rate' => wpinv_get_default_tax_rate(), |
| 118 | - 'name' => __( 'Base Tax', 'invoicing' ), |
|
| 118 | + 'name' => __('Base Tax', 'invoicing'), |
|
| 119 | 119 | ) |
| 120 | 120 | ) |
| 121 | 121 | ); |
@@ -129,24 +129,24 @@ discard block |
||
| 129 | 129 | * @param string $state |
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | - public static function get_address_tax_rates( $country, $state ) { |
|
| 132 | + public static function get_address_tax_rates($country, $state) { |
|
| 133 | 133 | |
| 134 | 134 | $all_tax_rates = self::get_all_tax_rates(); |
| 135 | 135 | $matching_rates = array_merge( |
| 136 | - wp_list_filter( $all_tax_rates, array( 'country' => $country ) ), |
|
| 137 | - wp_list_filter( $all_tax_rates, array( 'country' => '' ) ) |
|
| 136 | + wp_list_filter($all_tax_rates, array('country' => $country)), |
|
| 137 | + wp_list_filter($all_tax_rates, array('country' => '')) |
|
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | - foreach ( $matching_rates as $i => $rate ) { |
|
| 140 | + foreach ($matching_rates as $i => $rate) { |
|
| 141 | 141 | |
| 142 | - $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) ); |
|
| 143 | - if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) { |
|
| 144 | - unset( $matching_rates[ $i ] ); |
|
| 142 | + $states = array_filter(wpinv_clean(explode(',', strtolower($rate['state'])))); |
|
| 143 | + if (empty($rate['global']) && !in_array(strtolower($state), $states)) { |
|
| 144 | + unset($matching_rates[$i]); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state ); |
|
| 149 | + return apply_filters('getpaid_get_address_tax_rates', $matching_rates, $country, $state); |
|
| 150 | 150 | |
| 151 | 151 | } |
| 152 | 152 | |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * @param array $taxes Array of taxes. |
| 157 | 157 | * @return float |
| 158 | 158 | */ |
| 159 | - public static function get_tax_total( $taxes ) { |
|
| 160 | - return self::round( array_sum( $taxes ) ); |
|
| 159 | + public static function get_tax_total($taxes) { |
|
| 160 | + return self::round(array_sum($taxes)); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * @param float|int $in Value to round. |
| 174 | 174 | * @return float |
| 175 | 175 | */ |
| 176 | - public static function round( $in ) { |
|
| 177 | - return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in ); |
|
| 176 | + public static function round($in) { |
|
| 177 | + return apply_filters('getpaid_tax_round', round($in, 4), $in); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @deprecated |
| 247 | 247 | */ |
| 248 | 248 | function wpinv_get_payment_key( $invoice = 0 ) { |
| 249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 249 | + $invoice = new WPInv_Invoice( $invoice ); |
|
| 250 | 250 | return $invoice->get_key(); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @deprecated |
| 425 | 425 | */ |
| 426 | 426 | function wpinv_get_checkout_session() { |
| 427 | - return false; |
|
| 427 | + return false; |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -1273,5 +1273,5 @@ discard block |
||
| 1273 | 1273 | * @deprecated |
| 1274 | 1274 | */ |
| 1275 | 1275 | function wpinv_get_subscription( $invoice ) { |
| 1276 | - return wpinv_get_invoice_subscription( $invoice ); |
|
| 1276 | + return wpinv_get_invoice_subscription( $invoice ); |
|
| 1277 | 1277 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
| 19 | 19 | * @deprecated |
| 20 | 20 | */ |
| 21 | 21 | function wpinv_get_invoice_cart() { |
| 22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
| 22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @deprecated |
| 27 | 27 | */ |
| 28 | -function wpinv_get_invoice_description( $invoice ) { |
|
| 29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 28 | +function wpinv_get_invoice_description($invoice) { |
|
| 29 | + $invoice = new WPInv_Invoice($invoice); |
|
| 30 | 30 | return $invoice->get_description(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @deprecated |
| 35 | 35 | */ |
| 36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
| 37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
| 37 | + $invoice = new WPInv_Invoice($invoice); |
|
| 38 | 38 | return $invoice->get_currency(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @deprecated |
| 43 | 43 | */ |
| 44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
| 45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 44 | +function wpinv_get_payment_user_email($invoice) { |
|
| 45 | + $invoice = new WPInv_Invoice($invoice); |
|
| 46 | 46 | return $invoice->get_email(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @deprecated |
| 51 | 51 | */ |
| 52 | -function wpinv_get_user_id( $invoice ) { |
|
| 53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 52 | +function wpinv_get_user_id($invoice) { |
|
| 53 | + $invoice = new WPInv_Invoice($invoice); |
|
| 54 | 54 | return $invoice->get_user_id(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * @deprecated |
| 59 | 59 | */ |
| 60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
| 61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
| 61 | + $invoice = new WPInv_Invoice($invoice); |
|
| 62 | 62 | |
| 63 | - if ( $return_label ) { |
|
| 63 | + if ($return_label) { |
|
| 64 | 64 | return $invoice->get_status_nicename(); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * @deprecated |
| 72 | 72 | */ |
| 73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
| 74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
| 74 | + $invoice = new WPInv_Invoice($invoice); |
|
| 75 | 75 | |
| 76 | - if ( $return_label ) { |
|
| 76 | + if ($return_label) { |
|
| 77 | 77 | return $invoice->get_gateway_title(); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @deprecated |
| 85 | 85 | */ |
| 86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
| 87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
| 86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
| 87 | + return wpinv_get_payment_gateway($invoice, true); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @deprecated |
| 92 | 92 | */ |
| 93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
| 94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
| 94 | + $invoice = new WPInv_Invoice($invoice); |
|
| 95 | 95 | return $invoice->get_transaction_id(); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @deprecated |
| 100 | 100 | */ |
| 101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
| 102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 103 | - return $invoice->get_meta( $meta_key, $single ); |
|
| 101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
| 102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 103 | + return $invoice->get_meta($meta_key, $single); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @deprecated |
| 108 | 108 | */ |
| 109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
| 110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
| 109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
| 110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * @deprecated |
| 116 | 116 | */ |
| 117 | -function wpinv_get_items( $invoice = 0 ) { |
|
| 118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 117 | +function wpinv_get_items($invoice = 0) { |
|
| 118 | + $invoice = new WPInv_Invoice($invoice); |
|
| 119 | 119 | return $invoice->get_items(); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * @deprecated |
| 124 | 124 | */ |
| 125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
| 126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 125 | +function wpinv_get_fees($invoice = 0) { |
|
| 126 | + $invoice = new WPInv_Invoice($invoice); |
|
| 127 | 127 | return $invoice->get_fees(); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * @deprecated |
| 132 | 132 | */ |
| 133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
| 134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 133 | +function wpinv_get_invoice_ip($invoice) { |
|
| 134 | + $invoice = new WPInv_Invoice($invoice); |
|
| 135 | 135 | return $invoice->get_ip(); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * @deprecated |
| 140 | 140 | */ |
| 141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
| 142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 141 | +function wpinv_get_invoice_user_info($invoice) { |
|
| 142 | + $invoice = new WPInv_Invoice($invoice); |
|
| 143 | 143 | return $invoice->get_user_info(); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * @deprecated |
| 148 | 148 | */ |
| 149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
| 150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
| 150 | + $invoice = new WPInv_Invoice($invoice); |
|
| 151 | 151 | $subtotal = $invoice->get_subtotal(); |
| 152 | 152 | |
| 153 | - if ( $currency ) { |
|
| 154 | - return wpinv_price( $subtotal, $invoice->get_currency() ); |
|
| 153 | + if ($currency) { |
|
| 154 | + return wpinv_price($subtotal, $invoice->get_currency()); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | /** |
| 161 | 161 | * @deprecated |
| 162 | 162 | */ |
| 163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
| 164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
| 164 | + $invoice = new WPInv_Invoice($invoice); |
|
| 165 | 165 | $tax = $invoice->get_total_tax(); |
| 166 | 166 | |
| 167 | - if ( $currency ) { |
|
| 168 | - return wpinv_price( $tax, $invoice->get_currency() ); |
|
| 167 | + if ($currency) { |
|
| 168 | + return wpinv_price($tax, $invoice->get_currency()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * @deprecated |
| 176 | 176 | */ |
| 177 | -function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) { |
|
| 178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 177 | +function wpinv_discount($invoice = 0, $currency = false, $deprecated) { |
|
| 178 | + $invoice = new WPInv_Invoice($invoice); |
|
| 179 | 179 | $discount = $invoice->get_total_discount(); |
| 180 | 180 | |
| 181 | - if ( $currency ) { |
|
| 182 | - return wpinv_price( $discount, $invoice->get_currency() ); |
|
| 181 | + if ($currency) { |
|
| 182 | + return wpinv_price($discount, $invoice->get_currency()); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | /** |
| 189 | 189 | * @deprecated |
| 190 | 190 | */ |
| 191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
| 192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 191 | +function wpinv_discount_code($invoice = 0) { |
|
| 192 | + $invoice = new WPInv_Invoice($invoice); |
|
| 193 | 193 | return $invoice->get_discount_code(); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * @deprecated |
| 198 | 198 | */ |
| 199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
| 200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
| 200 | + $invoice = new WPInv_Invoice($invoice); |
|
| 201 | 201 | $total = $invoice->get_total(); |
| 202 | 202 | |
| 203 | - if ( $currency ) { |
|
| 204 | - return wpinv_price( $total, $invoice->get_currency() ); |
|
| 203 | + if ($currency) { |
|
| 204 | + return wpinv_price($total, $invoice->get_currency()); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
| 210 | 210 | /** |
| 211 | 211 | * @deprecated |
| 212 | 212 | */ |
| 213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
| 214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
| 214 | + $invoice = new WPInv_Invoice($invoice); |
|
| 215 | 215 | |
| 216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
| 216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
| 217 | 217 | $date_created = $invoice->get_created_date(); |
| 218 | 218 | |
| 219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
| 219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * @deprecated |
| 224 | 224 | */ |
| 225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
| 226 | - wpinv_get_date_created( $invoice, $format ); |
|
| 225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
| 226 | + wpinv_get_date_created($invoice, $format); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | 230 | * @deprecated |
| 231 | 231 | */ |
| 232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
| 233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
| 233 | + $invoice = new WPInv_Invoice($invoice); |
|
| 234 | 234 | return $invoice->get_vat_number(); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | 238 | * @deprecated |
| 239 | 239 | */ |
| 240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
| 241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
| 240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
| 241 | + $invoice = new WPInv_Invoice($invoice); |
|
| 242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * @deprecated |
| 247 | 247 | */ |
| 248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
| 249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 248 | +function wpinv_get_payment_key($invoice = 0) { |
|
| 249 | + $invoice = new WPInv_Invoice($invoice); |
|
| 250 | 250 | return $invoice->get_key(); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * @deprecated |
| 255 | 255 | */ |
| 256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
| 257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
| 257 | + $invoice = new WPInv_Invoice($invoice); |
|
| 258 | 258 | return $invoice->get_number(); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
| 401 | 401 | /** |
| 402 | 402 | * @deprecated |
| 403 | 403 | */ |
| 404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
| 405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 406 | - return $invoice->update_status( $new_status ); |
|
| 404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
| 405 | + $invoice = new WPInv_Invoice($invoice); |
|
| 406 | + return $invoice->update_status($new_status); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
| 456 | 456 | /** |
| 457 | 457 | * @deprecated |
| 458 | 458 | */ |
| 459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
| 459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
| 460 | 460 | |
| 461 | 461 | // Fetch the invoice. |
| 462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 463 | 463 | |
| 464 | - if ( 0 == $invoice->get_id() ) { |
|
| 464 | + if (0 == $invoice->get_id()) { |
|
| 465 | 465 | return false; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // Prepare the transaction id. |
| 469 | - if ( empty( $transaction_id ) ) { |
|
| 469 | + if (empty($transaction_id)) { |
|
| 470 | 470 | $transaction_id = $invoice_id; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // Set the transaction id; |
| 474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
| 474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
| 475 | 475 | |
| 476 | 476 | // Save the invoice. |
| 477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
| 484 | 484 | * @param WPInv_Invoice $invoice |
| 485 | 485 | * @param string $gateway |
| 486 | 486 | */ |
| 487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
| 487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
| 488 | 488 | |
| 489 | 489 | $payment_data = array( |
| 490 | 490 | 'invoice_id' => $invoice->get_id(), |
| 491 | 491 | 'items' => $invoice->get_cart_details(), |
| 492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
| 492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
| 493 | 493 | 'fees' => $invoice->get_total_fees(), |
| 494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
| 495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
| 497 | 497 | 'price' => $invoice->get_total(), |
| 498 | 498 | 'invoice_key' => $invoice->get_key(), |
| 499 | 499 | 'user_email' => $invoice->get_email(), |
| 500 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 500 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 501 | 501 | 'user_info' => $invoice->get_user_info(), |
| 502 | - 'post_data' => stripslashes_deep( $_POST ), |
|
| 502 | + 'post_data' => stripslashes_deep($_POST), |
|
| 503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
| 504 | 504 | 'gateway' => $gateway, |
| 505 | 505 | 'card_info' => array(), |
| 506 | 506 | 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
| 509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
| 519 | 519 | /** |
| 520 | 520 | * @deprecated |
| 521 | 521 | */ |
| 522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
| 523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 525 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
| 523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
| 524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
| 525 | + wp_die($message, $title, array('response' => $status)); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
| 640 | 640 | /** |
| 641 | 641 | * @deprecated |
| 642 | 642 | */ |
| 643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
| 644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
| 643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
| 644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** |
| 648 | 648 | * @deprecated |
| 649 | 649 | */ |
| 650 | -function wpinv_clean_invoice_number( $number ) { |
|
| 650 | +function wpinv_clean_invoice_number($number) { |
|
| 651 | 651 | return $number; |
| 652 | 652 | } |
| 653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
| 852 | 852 | /** |
| 853 | 853 | * @deprecated |
| 854 | 854 | */ |
| 855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
| 855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
| 856 | 856 | |
| 857 | - if ( $echo ) { |
|
| 858 | - echo wpinv_item_price( $item_id ); |
|
| 857 | + if ($echo) { |
|
| 858 | + echo wpinv_item_price($item_id); |
|
| 859 | 859 | } else { |
| 860 | - return wpinv_item_price( $item_id ); |
|
| 860 | + return wpinv_item_price($item_id); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | } |
@@ -1272,6 +1272,6 @@ discard block |
||
| 1272 | 1272 | * @return WPInv_Subscription|bool |
| 1273 | 1273 | * @deprecated |
| 1274 | 1274 | */ |
| 1275 | -function wpinv_get_subscription( $invoice ) { |
|
| 1276 | - return wpinv_get_invoice_subscription( $invoice ); |
|
| 1275 | +function wpinv_get_subscription($invoice) { |
|
| 1276 | + return wpinv_get_invoice_subscription($invoice); |
|
| 1277 | 1277 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | - exit; |
|
| 8 | + exit; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -15,198 +15,198 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class GetPaid_Subscription_Data_Store { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * A map of database fields to data types. |
|
| 20 | - * |
|
| 21 | - * @since 1.0.19 |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $database_fields_to_data_type = array( |
|
| 25 | - 'id' => '%d', |
|
| 26 | - 'customer_id' => '%d', |
|
| 27 | - 'frequency' => '%d', |
|
| 28 | - 'period' => '%s', |
|
| 29 | - 'initial_amount' => '%s', |
|
| 30 | - 'recurring_amount' => '%s', |
|
| 31 | - 'bill_times' => '%d', |
|
| 32 | - 'transaction_id' => '%s', |
|
| 33 | - 'parent_payment_id' => '%d', |
|
| 34 | - 'product_id' => '%d', |
|
| 35 | - 'created' => '%s', |
|
| 36 | - 'expiration' => '%s', |
|
| 37 | - 'trial_period' => '%s', |
|
| 38 | - 'status' => '%s', |
|
| 39 | - 'profile_id' => '%s', |
|
| 40 | - ); |
|
| 41 | - |
|
| 42 | - /* |
|
| 18 | + /** |
|
| 19 | + * A map of database fields to data types. |
|
| 20 | + * |
|
| 21 | + * @since 1.0.19 |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $database_fields_to_data_type = array( |
|
| 25 | + 'id' => '%d', |
|
| 26 | + 'customer_id' => '%d', |
|
| 27 | + 'frequency' => '%d', |
|
| 28 | + 'period' => '%s', |
|
| 29 | + 'initial_amount' => '%s', |
|
| 30 | + 'recurring_amount' => '%s', |
|
| 31 | + 'bill_times' => '%d', |
|
| 32 | + 'transaction_id' => '%s', |
|
| 33 | + 'parent_payment_id' => '%d', |
|
| 34 | + 'product_id' => '%d', |
|
| 35 | + 'created' => '%s', |
|
| 36 | + 'expiration' => '%s', |
|
| 37 | + 'trial_period' => '%s', |
|
| 38 | + 'status' => '%s', |
|
| 39 | + 'profile_id' => '%s', |
|
| 40 | + ); |
|
| 41 | + |
|
| 42 | + /* |
|
| 43 | 43 | |-------------------------------------------------------------------------- |
| 44 | 44 | | CRUD Methods |
| 45 | 45 | |-------------------------------------------------------------------------- |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Method to create a new subscription in the database. |
|
| 50 | - * |
|
| 51 | - * @param WPInv_Subscription $subscription Subscription object. |
|
| 52 | - */ |
|
| 53 | - public function create( &$subscription ) { |
|
| 54 | - global $wpdb; |
|
| 55 | - |
|
| 56 | - $values = array(); |
|
| 57 | - $formats = array(); |
|
| 58 | - |
|
| 59 | - $fields = $this->database_fields_to_data_type; |
|
| 60 | - unset( $fields['id'] ); |
|
| 61 | - |
|
| 62 | - foreach ( $fields as $key => $format ) { |
|
| 63 | - $method = "get_$key"; |
|
| 64 | - $values[$key] = $subscription->$method( 'edit' ); |
|
| 65 | - $formats[] = $format; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats ); |
|
| 69 | - |
|
| 70 | - if ( $result ) { |
|
| 71 | - $subscription->set_id( $wpdb->insert_id ); |
|
| 72 | - $subscription->apply_changes(); |
|
| 73 | - $subscription->clear_cache(); |
|
| 74 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
| 75 | - do_action( 'getpaid_new_subscription', $subscription ); |
|
| 76 | - return true; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - return false; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Method to read a subscription from the database. |
|
| 84 | - * |
|
| 85 | - * @param WPInv_Subscription $subscription Subscription object. |
|
| 86 | - * |
|
| 87 | - */ |
|
| 88 | - public function read( &$subscription ) { |
|
| 89 | - global $wpdb; |
|
| 90 | - |
|
| 91 | - $subscription->set_defaults(); |
|
| 92 | - |
|
| 93 | - if ( ! $subscription->get_id() ) { |
|
| 94 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
| 95 | - $subscription->set_id( 0 ); |
|
| 96 | - return false; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // Maybe retrieve from the cache. |
|
| 100 | - $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' ); |
|
| 101 | - |
|
| 102 | - // If not found, retrieve from the db. |
|
| 103 | - if ( false === $raw_subscription ) { |
|
| 104 | - |
|
| 105 | - $raw_subscription = $wpdb->get_row( |
|
| 106 | - $wpdb->prepare( |
|
| 107 | - "SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d", |
|
| 108 | - $subscription->get_id() |
|
| 109 | - ) |
|
| 110 | - ); |
|
| 111 | - |
|
| 112 | - // Update the cache with our data |
|
| 113 | - wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' ); |
|
| 114 | - |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - if ( ! $raw_subscription ) { |
|
| 118 | - $subscription->set_id( 0 ); |
|
| 119 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
| 120 | - return false; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) { |
|
| 124 | - $method = "set_$key"; |
|
| 125 | - $subscription->$method( $raw_subscription->$key ); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $subscription->set_object_read( true ); |
|
| 129 | - do_action( 'getpaid_read_subscription', $subscription ); |
|
| 130 | - |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Method to update a subscription in the database. |
|
| 135 | - * |
|
| 136 | - * @param WPInv_Subscription $subscription Subscription object. |
|
| 137 | - */ |
|
| 138 | - public function update( &$subscription ) { |
|
| 139 | - global $wpdb; |
|
| 140 | - |
|
| 141 | - $changes = $subscription->get_changes(); |
|
| 142 | - $values = array(); |
|
| 143 | - $formats = array(); |
|
| 144 | - |
|
| 145 | - foreach ( $this->database_fields_to_data_type as $key => $format ) { |
|
| 146 | - if ( array_key_exists( $key, $changes ) ) { |
|
| 147 | - $method = "get_$key"; |
|
| 148 | - $values[$key] = $subscription->$method( 'edit' ); |
|
| 149 | - $formats[] = $format; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - if ( empty( $values ) ) { |
|
| 154 | - return; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - $wpdb->update( |
|
| 158 | - $wpdb->prefix . 'wpinv_subscriptions', |
|
| 159 | - $values, |
|
| 160 | - array( |
|
| 161 | - 'id' => $subscription->get_id(), |
|
| 162 | - ), |
|
| 163 | - $formats, |
|
| 164 | - '%d' |
|
| 165 | - ); |
|
| 166 | - |
|
| 167 | - // Apply the changes. |
|
| 168 | - $subscription->apply_changes(); |
|
| 169 | - |
|
| 170 | - // Delete cache. |
|
| 171 | - $subscription->clear_cache(); |
|
| 172 | - |
|
| 173 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() ); |
|
| 174 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
| 175 | - |
|
| 176 | - // Fire a hook. |
|
| 177 | - do_action( 'getpaid_update_subscription', $subscription ); |
|
| 178 | - |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Method to delete a subscription from the database. |
|
| 183 | - * |
|
| 184 | - * @param WPInv_Subscription $subscription |
|
| 185 | - */ |
|
| 186 | - public function delete( &$subscription ) { |
|
| 187 | - global $wpdb; |
|
| 188 | - |
|
| 189 | - $wpdb->query( |
|
| 190 | - $wpdb->prepare( |
|
| 191 | - "DELETE FROM {$wpdb->prefix}wpinv_subscriptions |
|
| 48 | + /** |
|
| 49 | + * Method to create a new subscription in the database. |
|
| 50 | + * |
|
| 51 | + * @param WPInv_Subscription $subscription Subscription object. |
|
| 52 | + */ |
|
| 53 | + public function create( &$subscription ) { |
|
| 54 | + global $wpdb; |
|
| 55 | + |
|
| 56 | + $values = array(); |
|
| 57 | + $formats = array(); |
|
| 58 | + |
|
| 59 | + $fields = $this->database_fields_to_data_type; |
|
| 60 | + unset( $fields['id'] ); |
|
| 61 | + |
|
| 62 | + foreach ( $fields as $key => $format ) { |
|
| 63 | + $method = "get_$key"; |
|
| 64 | + $values[$key] = $subscription->$method( 'edit' ); |
|
| 65 | + $formats[] = $format; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats ); |
|
| 69 | + |
|
| 70 | + if ( $result ) { |
|
| 71 | + $subscription->set_id( $wpdb->insert_id ); |
|
| 72 | + $subscription->apply_changes(); |
|
| 73 | + $subscription->clear_cache(); |
|
| 74 | + update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
| 75 | + do_action( 'getpaid_new_subscription', $subscription ); |
|
| 76 | + return true; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + return false; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Method to read a subscription from the database. |
|
| 84 | + * |
|
| 85 | + * @param WPInv_Subscription $subscription Subscription object. |
|
| 86 | + * |
|
| 87 | + */ |
|
| 88 | + public function read( &$subscription ) { |
|
| 89 | + global $wpdb; |
|
| 90 | + |
|
| 91 | + $subscription->set_defaults(); |
|
| 92 | + |
|
| 93 | + if ( ! $subscription->get_id() ) { |
|
| 94 | + $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
| 95 | + $subscription->set_id( 0 ); |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // Maybe retrieve from the cache. |
|
| 100 | + $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' ); |
|
| 101 | + |
|
| 102 | + // If not found, retrieve from the db. |
|
| 103 | + if ( false === $raw_subscription ) { |
|
| 104 | + |
|
| 105 | + $raw_subscription = $wpdb->get_row( |
|
| 106 | + $wpdb->prepare( |
|
| 107 | + "SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d", |
|
| 108 | + $subscription->get_id() |
|
| 109 | + ) |
|
| 110 | + ); |
|
| 111 | + |
|
| 112 | + // Update the cache with our data |
|
| 113 | + wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' ); |
|
| 114 | + |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + if ( ! $raw_subscription ) { |
|
| 118 | + $subscription->set_id( 0 ); |
|
| 119 | + $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
| 120 | + return false; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) { |
|
| 124 | + $method = "set_$key"; |
|
| 125 | + $subscription->$method( $raw_subscription->$key ); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $subscription->set_object_read( true ); |
|
| 129 | + do_action( 'getpaid_read_subscription', $subscription ); |
|
| 130 | + |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Method to update a subscription in the database. |
|
| 135 | + * |
|
| 136 | + * @param WPInv_Subscription $subscription Subscription object. |
|
| 137 | + */ |
|
| 138 | + public function update( &$subscription ) { |
|
| 139 | + global $wpdb; |
|
| 140 | + |
|
| 141 | + $changes = $subscription->get_changes(); |
|
| 142 | + $values = array(); |
|
| 143 | + $formats = array(); |
|
| 144 | + |
|
| 145 | + foreach ( $this->database_fields_to_data_type as $key => $format ) { |
|
| 146 | + if ( array_key_exists( $key, $changes ) ) { |
|
| 147 | + $method = "get_$key"; |
|
| 148 | + $values[$key] = $subscription->$method( 'edit' ); |
|
| 149 | + $formats[] = $format; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + if ( empty( $values ) ) { |
|
| 154 | + return; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + $wpdb->update( |
|
| 158 | + $wpdb->prefix . 'wpinv_subscriptions', |
|
| 159 | + $values, |
|
| 160 | + array( |
|
| 161 | + 'id' => $subscription->get_id(), |
|
| 162 | + ), |
|
| 163 | + $formats, |
|
| 164 | + '%d' |
|
| 165 | + ); |
|
| 166 | + |
|
| 167 | + // Apply the changes. |
|
| 168 | + $subscription->apply_changes(); |
|
| 169 | + |
|
| 170 | + // Delete cache. |
|
| 171 | + $subscription->clear_cache(); |
|
| 172 | + |
|
| 173 | + update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() ); |
|
| 174 | + update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
| 175 | + |
|
| 176 | + // Fire a hook. |
|
| 177 | + do_action( 'getpaid_update_subscription', $subscription ); |
|
| 178 | + |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Method to delete a subscription from the database. |
|
| 183 | + * |
|
| 184 | + * @param WPInv_Subscription $subscription |
|
| 185 | + */ |
|
| 186 | + public function delete( &$subscription ) { |
|
| 187 | + global $wpdb; |
|
| 188 | + |
|
| 189 | + $wpdb->query( |
|
| 190 | + $wpdb->prepare( |
|
| 191 | + "DELETE FROM {$wpdb->prefix}wpinv_subscriptions |
|
| 192 | 192 | WHERE id = %d", |
| 193 | - $subscription->get_id() |
|
| 194 | - ) |
|
| 195 | - ); |
|
| 193 | + $subscription->get_id() |
|
| 194 | + ) |
|
| 195 | + ); |
|
| 196 | 196 | |
| 197 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' ); |
|
| 198 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' ); |
|
| 197 | + delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' ); |
|
| 198 | + delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' ); |
|
| 199 | 199 | |
| 200 | - // Delete cache. |
|
| 201 | - $subscription->clear_cache(); |
|
| 200 | + // Delete cache. |
|
| 201 | + $subscription->clear_cache(); |
|
| 202 | 202 | |
| 203 | - // Fire a hook. |
|
| 204 | - do_action( 'getpaid_delete_subscription', $subscription ); |
|
| 203 | + // Fire a hook. |
|
| 204 | + do_action( 'getpaid_delete_subscription', $subscription ); |
|
| 205 | 205 | |
| 206 | - $subscription->set_id( 0 ); |
|
| 207 | - } |
|
| 206 | + $subscription->set_id( 0 ); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - /* |
|
| 209 | + /* |
|
| 210 | 210 | |-------------------------------------------------------------------------- |
| 211 | 211 | | Additional Methods |
| 212 | 212 | |-------------------------------------------------------------------------- |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * GetPaid_Subscription_Data_Store class file. |
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 7 | +if (!defined('ABSPATH')) { |
|
| 8 | 8 | exit; |
| 9 | 9 | } |
| 10 | 10 | |
@@ -50,29 +50,29 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @param WPInv_Subscription $subscription Subscription object. |
| 52 | 52 | */ |
| 53 | - public function create( &$subscription ) { |
|
| 53 | + public function create(&$subscription) { |
|
| 54 | 54 | global $wpdb; |
| 55 | 55 | |
| 56 | 56 | $values = array(); |
| 57 | 57 | $formats = array(); |
| 58 | 58 | |
| 59 | 59 | $fields = $this->database_fields_to_data_type; |
| 60 | - unset( $fields['id'] ); |
|
| 60 | + unset($fields['id']); |
|
| 61 | 61 | |
| 62 | - foreach ( $fields as $key => $format ) { |
|
| 62 | + foreach ($fields as $key => $format) { |
|
| 63 | 63 | $method = "get_$key"; |
| 64 | - $values[$key] = $subscription->$method( 'edit' ); |
|
| 64 | + $values[$key] = $subscription->$method('edit'); |
|
| 65 | 65 | $formats[] = $format; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats ); |
|
| 68 | + $result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $values, $formats); |
|
| 69 | 69 | |
| 70 | - if ( $result ) { |
|
| 71 | - $subscription->set_id( $wpdb->insert_id ); |
|
| 70 | + if ($result) { |
|
| 71 | + $subscription->set_id($wpdb->insert_id); |
|
| 72 | 72 | $subscription->apply_changes(); |
| 73 | 73 | $subscription->clear_cache(); |
| 74 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
| 75 | - do_action( 'getpaid_new_subscription', $subscription ); |
|
| 74 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id()); |
|
| 75 | + do_action('getpaid_new_subscription', $subscription); |
|
| 76 | 76 | return true; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -85,22 +85,22 @@ discard block |
||
| 85 | 85 | * @param WPInv_Subscription $subscription Subscription object. |
| 86 | 86 | * |
| 87 | 87 | */ |
| 88 | - public function read( &$subscription ) { |
|
| 88 | + public function read(&$subscription) { |
|
| 89 | 89 | global $wpdb; |
| 90 | 90 | |
| 91 | 91 | $subscription->set_defaults(); |
| 92 | 92 | |
| 93 | - if ( ! $subscription->get_id() ) { |
|
| 94 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
| 95 | - $subscription->set_id( 0 ); |
|
| 93 | + if (!$subscription->get_id()) { |
|
| 94 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
| 95 | + $subscription->set_id(0); |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Maybe retrieve from the cache. |
| 100 | - $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' ); |
|
| 100 | + $raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions'); |
|
| 101 | 101 | |
| 102 | 102 | // If not found, retrieve from the db. |
| 103 | - if ( false === $raw_subscription ) { |
|
| 103 | + if (false === $raw_subscription) { |
|
| 104 | 104 | |
| 105 | 105 | $raw_subscription = $wpdb->get_row( |
| 106 | 106 | $wpdb->prepare( |
@@ -110,23 +110,23 @@ discard block |
||
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | 112 | // Update the cache with our data |
| 113 | - wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' ); |
|
| 113 | + wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions'); |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( ! $raw_subscription ) { |
|
| 118 | - $subscription->set_id( 0 ); |
|
| 119 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
| 117 | + if (!$raw_subscription) { |
|
| 118 | + $subscription->set_id(0); |
|
| 119 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) { |
|
| 124 | - $method = "set_$key"; |
|
| 125 | - $subscription->$method( $raw_subscription->$key ); |
|
| 123 | + foreach (array_keys($this->database_fields_to_data_type) as $key) { |
|
| 124 | + $method = "set_$key"; |
|
| 125 | + $subscription->$method($raw_subscription->$key); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $subscription->set_object_read( true ); |
|
| 129 | - do_action( 'getpaid_read_subscription', $subscription ); |
|
| 128 | + $subscription->set_object_read(true); |
|
| 129 | + do_action('getpaid_read_subscription', $subscription); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -135,22 +135,22 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param WPInv_Subscription $subscription Subscription object. |
| 137 | 137 | */ |
| 138 | - public function update( &$subscription ) { |
|
| 138 | + public function update(&$subscription) { |
|
| 139 | 139 | global $wpdb; |
| 140 | 140 | |
| 141 | 141 | $changes = $subscription->get_changes(); |
| 142 | 142 | $values = array(); |
| 143 | 143 | $formats = array(); |
| 144 | 144 | |
| 145 | - foreach ( $this->database_fields_to_data_type as $key => $format ) { |
|
| 146 | - if ( array_key_exists( $key, $changes ) ) { |
|
| 145 | + foreach ($this->database_fields_to_data_type as $key => $format) { |
|
| 146 | + if (array_key_exists($key, $changes)) { |
|
| 147 | 147 | $method = "get_$key"; |
| 148 | - $values[$key] = $subscription->$method( 'edit' ); |
|
| 148 | + $values[$key] = $subscription->$method('edit'); |
|
| 149 | 149 | $formats[] = $format; |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( empty( $values ) ) { |
|
| 153 | + if (empty($values)) { |
|
| 154 | 154 | return; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | // Delete cache. |
| 171 | 171 | $subscription->clear_cache(); |
| 172 | 172 | |
| 173 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() ); |
|
| 174 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
| 173 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id()); |
|
| 174 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id()); |
|
| 175 | 175 | |
| 176 | 176 | // Fire a hook. |
| 177 | - do_action( 'getpaid_update_subscription', $subscription ); |
|
| 177 | + do_action('getpaid_update_subscription', $subscription); |
|
| 178 | 178 | |
| 179 | 179 | } |
| 180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param WPInv_Subscription $subscription |
| 185 | 185 | */ |
| 186 | - public function delete( &$subscription ) { |
|
| 186 | + public function delete(&$subscription) { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | 189 | $wpdb->query( |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | ) |
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' ); |
|
| 198 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' ); |
|
| 197 | + delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id'); |
|
| 198 | + delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id'); |
|
| 199 | 199 | |
| 200 | 200 | // Delete cache. |
| 201 | 201 | $subscription->clear_cache(); |
| 202 | 202 | |
| 203 | 203 | // Fire a hook. |
| 204 | - do_action( 'getpaid_delete_subscription', $subscription ); |
|
| 204 | + do_action('getpaid_delete_subscription', $subscription); |
|
| 205 | 205 | |
| 206 | - $subscription->set_id( 0 ); |
|
| 206 | + $subscription->set_id(0); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /* |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | class WPInv_Invoice extends GetPaid_Data { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Which data store to load. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 17 | + * Which data store to load. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | 21 | protected $data_store_name = 'invoice'; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * This is the name of this object type. |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 24 | + * This is the name of this object type. |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | protected $object_type = 'invoice'; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.19 |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $data = array( |
|
| 37 | - 'parent_id' => 0, |
|
| 38 | - 'status' => 'wpi-pending', |
|
| 39 | - 'version' => '', |
|
| 40 | - 'date_created' => null, |
|
| 31 | + * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.19 |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $data = array( |
|
| 37 | + 'parent_id' => 0, |
|
| 38 | + 'status' => 'wpi-pending', |
|
| 39 | + 'version' => '', |
|
| 40 | + 'date_created' => null, |
|
| 41 | 41 | 'date_modified' => null, |
| 42 | 42 | 'due_date' => null, |
| 43 | 43 | 'completed_date' => null, |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | 'subtotal' => 0, |
| 68 | 68 | 'total_discount' => 0, |
| 69 | 69 | 'total_tax' => 0, |
| 70 | - 'total_fees' => 0, |
|
| 71 | - 'total' => 0, |
|
| 70 | + 'total_fees' => 0, |
|
| 71 | + 'total' => 0, |
|
| 72 | 72 | 'fees' => array(), |
| 73 | 73 | 'discounts' => array(), |
| 74 | 74 | 'taxes' => array(), |
@@ -80,22 +80,22 @@ discard block |
||
| 80 | 80 | 'transaction_id' => '', |
| 81 | 81 | 'currency' => '', |
| 82 | 82 | 'disable_taxes' => false, |
| 83 | - 'subscription_id' => null, |
|
| 84 | - 'remote_subscription_id' => null, |
|
| 85 | - 'is_viewed' => false, |
|
| 86 | - 'email_cc' => '', |
|
| 87 | - 'template' => 'quantity', // hours, amount only |
|
| 88 | - 'created_via' => null, |
|
| 83 | + 'subscription_id' => null, |
|
| 84 | + 'remote_subscription_id' => null, |
|
| 85 | + 'is_viewed' => false, |
|
| 86 | + 'email_cc' => '', |
|
| 87 | + 'template' => 'quantity', // hours, amount only |
|
| 88 | + 'created_via' => null, |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * Stores meta in cache for future reads. |
|
| 93 | - * |
|
| 94 | - * A group must be set to to enable caching. |
|
| 95 | - * |
|
| 96 | - * @var string |
|
| 97 | - */ |
|
| 98 | - protected $cache_group = 'getpaid_invoices'; |
|
| 92 | + * Stores meta in cache for future reads. |
|
| 93 | + * |
|
| 94 | + * A group must be set to to enable caching. |
|
| 95 | + * |
|
| 96 | + * @var string |
|
| 97 | + */ |
|
| 98 | + protected $cache_group = 'getpaid_invoices'; |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Stores a reference to the original WP_Post object |
@@ -109,111 +109,111 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @var int |
| 111 | 111 | */ |
| 112 | - protected $recurring_item = null; |
|
| 112 | + protected $recurring_item = null; |
|
| 113 | 113 | |
| 114 | - /** |
|
| 114 | + /** |
|
| 115 | 115 | * Stores an array of item totals. |
| 116 | - * |
|
| 117 | - * e.g $totals['discount'] = array( |
|
| 118 | - * 'initial' => 10, |
|
| 119 | - * 'recurring' => 10, |
|
| 120 | - * ) |
|
| 116 | + * |
|
| 117 | + * e.g $totals['discount'] = array( |
|
| 118 | + * 'initial' => 10, |
|
| 119 | + * 'recurring' => 10, |
|
| 120 | + * ) |
|
| 121 | 121 | * |
| 122 | 122 | * @var array |
| 123 | 123 | */ |
| 124 | - protected $totals = array(); |
|
| 124 | + protected $totals = array(); |
|
| 125 | 125 | |
| 126 | - /** |
|
| 126 | + /** |
|
| 127 | 127 | * Tax rate. |
| 128 | - * |
|
| 128 | + * |
|
| 129 | 129 | * @var float |
| 130 | 130 | */ |
| 131 | - protected $tax_rate = 0; |
|
| 131 | + protected $tax_rate = 0; |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Stores the status transition information. |
|
| 135 | - * |
|
| 136 | - * @since 1.0.19 |
|
| 137 | - * @var bool|array |
|
| 138 | - */ |
|
| 139 | - protected $status_transition = false; |
|
| 133 | + /** |
|
| 134 | + * Stores the status transition information. |
|
| 135 | + * |
|
| 136 | + * @since 1.0.19 |
|
| 137 | + * @var bool|array |
|
| 138 | + */ |
|
| 139 | + protected $status_transition = false; |
|
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 143 | - * |
|
| 144 | - * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 145 | - */ |
|
| 142 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 143 | + * |
|
| 144 | + * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 145 | + */ |
|
| 146 | 146 | public function __construct( $invoice = 0 ) { |
| 147 | 147 | |
| 148 | 148 | parent::__construct( $invoice ); |
| 149 | 149 | |
| 150 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 151 | - $this->set_id( (int) $invoice ); |
|
| 152 | - } elseif ( $invoice instanceof self ) { |
|
| 153 | - $this->set_id( $invoice->get_id() ); |
|
| 154 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 155 | - $this->set_id( $invoice->ID ); |
|
| 156 | - } elseif ( is_array( $invoice ) ) { |
|
| 157 | - $this->set_props( $invoice ); |
|
| 158 | - |
|
| 159 | - if ( isset( $invoice['ID'] ) ) { |
|
| 160 | - $this->set_id( $invoice['ID'] ); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 164 | - $this->set_id( $invoice_id ); |
|
| 165 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 166 | - $this->set_id( $invoice_id ); |
|
| 167 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 168 | - $this->set_id( $invoice_id ); |
|
| 169 | - } else { |
|
| 170 | - $this->set_object_read( true ); |
|
| 171 | - } |
|
| 150 | + if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 151 | + $this->set_id( (int) $invoice ); |
|
| 152 | + } elseif ( $invoice instanceof self ) { |
|
| 153 | + $this->set_id( $invoice->get_id() ); |
|
| 154 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 155 | + $this->set_id( $invoice->ID ); |
|
| 156 | + } elseif ( is_array( $invoice ) ) { |
|
| 157 | + $this->set_props( $invoice ); |
|
| 158 | + |
|
| 159 | + if ( isset( $invoice['ID'] ) ) { |
|
| 160 | + $this->set_id( $invoice['ID'] ); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 164 | + $this->set_id( $invoice_id ); |
|
| 165 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 166 | + $this->set_id( $invoice_id ); |
|
| 167 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 168 | + $this->set_id( $invoice_id ); |
|
| 169 | + } else { |
|
| 170 | + $this->set_object_read( true ); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | // Load the datastore. |
| 174 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 174 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 175 | 175 | |
| 176 | - if ( $this->get_id() > 0 ) { |
|
| 176 | + if ( $this->get_id() > 0 ) { |
|
| 177 | 177 | $this->post = get_post( $this->get_id() ); |
| 178 | 178 | $this->ID = $this->get_id(); |
| 179 | - $this->data_store->read( $this ); |
|
| 179 | + $this->data_store->read( $this ); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * Given an invoice key/number, it returns its id. |
|
| 186 | - * |
|
| 187 | - * |
|
| 188 | - * @static |
|
| 189 | - * @param string $value The invoice key or number |
|
| 190 | - * @param string $field Either key, transaction_id or number. |
|
| 191 | - * @since 1.0.15 |
|
| 192 | - * @return int |
|
| 193 | - */ |
|
| 194 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 185 | + * Given an invoice key/number, it returns its id. |
|
| 186 | + * |
|
| 187 | + * |
|
| 188 | + * @static |
|
| 189 | + * @param string $value The invoice key or number |
|
| 190 | + * @param string $field Either key, transaction_id or number. |
|
| 191 | + * @since 1.0.15 |
|
| 192 | + * @return int |
|
| 193 | + */ |
|
| 194 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 195 | 195 | global $wpdb; |
| 196 | 196 | |
| 197 | - // Trim the value. |
|
| 198 | - $value = trim( $value ); |
|
| 197 | + // Trim the value. |
|
| 198 | + $value = trim( $value ); |
|
| 199 | 199 | |
| 200 | - if ( empty( $value ) ) { |
|
| 201 | - return 0; |
|
| 202 | - } |
|
| 200 | + if ( empty( $value ) ) { |
|
| 201 | + return 0; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | // Valid fields. |
| 205 | 205 | $fields = array( 'key', 'number', 'transaction_id' ); |
| 206 | 206 | |
| 207 | - // Ensure a field has been passed. |
|
| 208 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 209 | - return 0; |
|
| 210 | - } |
|
| 207 | + // Ensure a field has been passed. |
|
| 208 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 209 | + return 0; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - // Maybe retrieve from the cache. |
|
| 213 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 214 | - if ( false !== $invoice_id ) { |
|
| 215 | - return $invoice_id; |
|
| 216 | - } |
|
| 212 | + // Maybe retrieve from the cache. |
|
| 213 | + $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 214 | + if ( false !== $invoice_id ) { |
|
| 215 | + return $invoice_id; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | 218 | // Fetch from the db. |
| 219 | 219 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | - // Update the cache with our data |
|
| 225 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 224 | + // Update the cache with our data |
|
| 225 | + wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 226 | 226 | |
| 227 | - return $invoice_id; |
|
| 227 | + return $invoice_id; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -250,83 +250,83 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Get parent invoice ID. |
|
| 254 | - * |
|
| 255 | - * @since 1.0.19 |
|
| 256 | - * @param string $context View or edit context. |
|
| 257 | - * @return int |
|
| 258 | - */ |
|
| 259 | - public function get_parent_id( $context = 'view' ) { |
|
| 260 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 253 | + * Get parent invoice ID. |
|
| 254 | + * |
|
| 255 | + * @since 1.0.19 |
|
| 256 | + * @param string $context View or edit context. |
|
| 257 | + * @return int |
|
| 258 | + */ |
|
| 259 | + public function get_parent_id( $context = 'view' ) { |
|
| 260 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | - * Get parent invoice. |
|
| 265 | - * |
|
| 266 | - * @since 1.0.19 |
|
| 267 | - * @return WPInv_Invoice |
|
| 268 | - */ |
|
| 264 | + * Get parent invoice. |
|
| 265 | + * |
|
| 266 | + * @since 1.0.19 |
|
| 267 | + * @return WPInv_Invoice |
|
| 268 | + */ |
|
| 269 | 269 | public function get_parent_payment() { |
| 270 | 270 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | - * Alias for self::get_parent_payment(). |
|
| 275 | - * |
|
| 276 | - * @since 1.0.19 |
|
| 277 | - * @return WPInv_Invoice |
|
| 278 | - */ |
|
| 274 | + * Alias for self::get_parent_payment(). |
|
| 275 | + * |
|
| 276 | + * @since 1.0.19 |
|
| 277 | + * @return WPInv_Invoice |
|
| 278 | + */ |
|
| 279 | 279 | public function get_parent() { |
| 280 | 280 | return $this->get_parent_payment(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | - * Get invoice status. |
|
| 285 | - * |
|
| 286 | - * @since 1.0.19 |
|
| 287 | - * @param string $context View or edit context. |
|
| 288 | - * @return string |
|
| 289 | - */ |
|
| 290 | - public function get_status( $context = 'view' ) { |
|
| 291 | - return $this->get_prop( 'status', $context ); |
|
| 292 | - } |
|
| 284 | + * Get invoice status. |
|
| 285 | + * |
|
| 286 | + * @since 1.0.19 |
|
| 287 | + * @param string $context View or edit context. |
|
| 288 | + * @return string |
|
| 289 | + */ |
|
| 290 | + public function get_status( $context = 'view' ) { |
|
| 291 | + return $this->get_prop( 'status', $context ); |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - /** |
|
| 295 | - * Retrieves an array of possible invoice statuses. |
|
| 296 | - * |
|
| 297 | - * @since 1.0.19 |
|
| 298 | - * @return array |
|
| 299 | - */ |
|
| 300 | - public function get_all_statuses() { |
|
| 301 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Get invoice status nice name. |
|
| 306 | - * |
|
| 307 | - * @since 1.0.19 |
|
| 308 | - * @return string |
|
| 309 | - */ |
|
| 294 | + /** |
|
| 295 | + * Retrieves an array of possible invoice statuses. |
|
| 296 | + * |
|
| 297 | + * @since 1.0.19 |
|
| 298 | + * @return array |
|
| 299 | + */ |
|
| 300 | + public function get_all_statuses() { |
|
| 301 | + return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Get invoice status nice name. |
|
| 306 | + * |
|
| 307 | + * @since 1.0.19 |
|
| 308 | + * @return string |
|
| 309 | + */ |
|
| 310 | 310 | public function get_status_nicename() { |
| 311 | - $statuses = $this->get_all_statuses(); |
|
| 311 | + $statuses = $this->get_all_statuses(); |
|
| 312 | 312 | |
| 313 | 313 | $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
| 314 | 314 | |
| 315 | 315 | return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * Retrieves the invoice status class |
|
| 320 | - * |
|
| 321 | - * @since 1.0.19 |
|
| 322 | - * @return string |
|
| 323 | - */ |
|
| 324 | - public function get_status_class() { |
|
| 325 | - $statuses = getpaid_get_invoice_status_classes(); |
|
| 326 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
| 327 | - } |
|
| 318 | + /** |
|
| 319 | + * Retrieves the invoice status class |
|
| 320 | + * |
|
| 321 | + * @since 1.0.19 |
|
| 322 | + * @return string |
|
| 323 | + */ |
|
| 324 | + public function get_status_class() { |
|
| 325 | + $statuses = getpaid_get_invoice_status_classes(); |
|
| 326 | + return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - /** |
|
| 329 | + /** |
|
| 330 | 330 | * Retrieves the invoice status label html |
| 331 | 331 | * |
| 332 | 332 | * @since 1.0.0 |
@@ -334,263 +334,263 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function get_status_label_html() { |
| 336 | 336 | |
| 337 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 338 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 339 | - $class = esc_attr( $this->get_status_class() ); |
|
| 337 | + $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 338 | + $status = sanitize_html_class( $this->get_status() ); |
|
| 339 | + $class = esc_attr( $this->get_status_class() ); |
|
| 340 | 340 | |
| 341 | - return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
|
| 342 | - } |
|
| 341 | + return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | - * Get plugin version when the invoice was created. |
|
| 346 | - * |
|
| 347 | - * @since 1.0.19 |
|
| 348 | - * @param string $context View or edit context. |
|
| 349 | - * @return string |
|
| 350 | - */ |
|
| 351 | - public function get_version( $context = 'view' ) { |
|
| 352 | - return $this->get_prop( 'version', $context ); |
|
| 353 | - } |
|
| 345 | + * Get plugin version when the invoice was created. |
|
| 346 | + * |
|
| 347 | + * @since 1.0.19 |
|
| 348 | + * @param string $context View or edit context. |
|
| 349 | + * @return string |
|
| 350 | + */ |
|
| 351 | + public function get_version( $context = 'view' ) { |
|
| 352 | + return $this->get_prop( 'version', $context ); |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - /** |
|
| 356 | - * @deprecated |
|
| 357 | - */ |
|
| 358 | - public function get_invoice_date( $format = true ) { |
|
| 359 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 360 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 361 | - $formatted = getpaid_format_date( $date ); |
|
| 355 | + /** |
|
| 356 | + * @deprecated |
|
| 357 | + */ |
|
| 358 | + public function get_invoice_date( $format = true ) { |
|
| 359 | + $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 360 | + $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 361 | + $formatted = getpaid_format_date( $date ); |
|
| 362 | 362 | |
| 363 | - if ( $format ) { |
|
| 364 | - return $formatted; |
|
| 365 | - } |
|
| 363 | + if ( $format ) { |
|
| 364 | + return $formatted; |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - return empty( $formatted ) ? '' : $date; |
|
| 367 | + return empty( $formatted ) ? '' : $date; |
|
| 368 | 368 | |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | - * Get date when the invoice was created. |
|
| 373 | - * |
|
| 374 | - * @since 1.0.19 |
|
| 375 | - * @param string $context View or edit context. |
|
| 376 | - * @return string |
|
| 377 | - */ |
|
| 378 | - public function get_date_created( $context = 'view' ) { |
|
| 379 | - return $this->get_prop( 'date_created', $context ); |
|
| 380 | - } |
|
| 372 | + * Get date when the invoice was created. |
|
| 373 | + * |
|
| 374 | + * @since 1.0.19 |
|
| 375 | + * @param string $context View or edit context. |
|
| 376 | + * @return string |
|
| 377 | + */ |
|
| 378 | + public function get_date_created( $context = 'view' ) { |
|
| 379 | + return $this->get_prop( 'date_created', $context ); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - /** |
|
| 383 | - * Alias for self::get_date_created(). |
|
| 384 | - * |
|
| 385 | - * @since 1.0.19 |
|
| 386 | - * @param string $context View or edit context. |
|
| 387 | - * @return string |
|
| 388 | - */ |
|
| 389 | - public function get_created_date( $context = 'view' ) { |
|
| 390 | - return $this->get_date_created( $context ); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Get GMT date when the invoice was created. |
|
| 395 | - * |
|
| 396 | - * @since 1.0.19 |
|
| 397 | - * @param string $context View or edit context. |
|
| 398 | - * @return string |
|
| 399 | - */ |
|
| 400 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 382 | + /** |
|
| 383 | + * Alias for self::get_date_created(). |
|
| 384 | + * |
|
| 385 | + * @since 1.0.19 |
|
| 386 | + * @param string $context View or edit context. |
|
| 387 | + * @return string |
|
| 388 | + */ |
|
| 389 | + public function get_created_date( $context = 'view' ) { |
|
| 390 | + return $this->get_date_created( $context ); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Get GMT date when the invoice was created. |
|
| 395 | + * |
|
| 396 | + * @since 1.0.19 |
|
| 397 | + * @param string $context View or edit context. |
|
| 398 | + * @return string |
|
| 399 | + */ |
|
| 400 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 401 | 401 | $date = $this->get_date_created( $context ); |
| 402 | 402 | |
| 403 | 403 | if ( $date ) { |
| 404 | 404 | $date = get_gmt_from_date( $date ); |
| 405 | 405 | } |
| 406 | - return $date; |
|
| 406 | + return $date; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
| 410 | - * Get date when the invoice was last modified. |
|
| 411 | - * |
|
| 412 | - * @since 1.0.19 |
|
| 413 | - * @param string $context View or edit context. |
|
| 414 | - * @return string |
|
| 415 | - */ |
|
| 416 | - public function get_date_modified( $context = 'view' ) { |
|
| 417 | - return $this->get_prop( 'date_modified', $context ); |
|
| 418 | - } |
|
| 410 | + * Get date when the invoice was last modified. |
|
| 411 | + * |
|
| 412 | + * @since 1.0.19 |
|
| 413 | + * @param string $context View or edit context. |
|
| 414 | + * @return string |
|
| 415 | + */ |
|
| 416 | + public function get_date_modified( $context = 'view' ) { |
|
| 417 | + return $this->get_prop( 'date_modified', $context ); |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - /** |
|
| 421 | - * Alias for self::get_date_modified(). |
|
| 422 | - * |
|
| 423 | - * @since 1.0.19 |
|
| 424 | - * @param string $context View or edit context. |
|
| 425 | - * @return string |
|
| 426 | - */ |
|
| 427 | - public function get_modified_date( $context = 'view' ) { |
|
| 428 | - return $this->get_date_modified( $context ); |
|
| 420 | + /** |
|
| 421 | + * Alias for self::get_date_modified(). |
|
| 422 | + * |
|
| 423 | + * @since 1.0.19 |
|
| 424 | + * @param string $context View or edit context. |
|
| 425 | + * @return string |
|
| 426 | + */ |
|
| 427 | + public function get_modified_date( $context = 'view' ) { |
|
| 428 | + return $this->get_date_modified( $context ); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
| 432 | - * Get GMT date when the invoice was last modified. |
|
| 433 | - * |
|
| 434 | - * @since 1.0.19 |
|
| 435 | - * @param string $context View or edit context. |
|
| 436 | - * @return string |
|
| 437 | - */ |
|
| 438 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 432 | + * Get GMT date when the invoice was last modified. |
|
| 433 | + * |
|
| 434 | + * @since 1.0.19 |
|
| 435 | + * @param string $context View or edit context. |
|
| 436 | + * @return string |
|
| 437 | + */ |
|
| 438 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 439 | 439 | $date = $this->get_date_modified( $context ); |
| 440 | 440 | |
| 441 | 441 | if ( $date ) { |
| 442 | 442 | $date = get_gmt_from_date( $date ); |
| 443 | 443 | } |
| 444 | - return $date; |
|
| 444 | + return $date; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | - * Get the invoice due date. |
|
| 449 | - * |
|
| 450 | - * @since 1.0.19 |
|
| 451 | - * @param string $context View or edit context. |
|
| 452 | - * @return string |
|
| 453 | - */ |
|
| 454 | - public function get_due_date( $context = 'view' ) { |
|
| 455 | - return $this->get_prop( 'due_date', $context ); |
|
| 448 | + * Get the invoice due date. |
|
| 449 | + * |
|
| 450 | + * @since 1.0.19 |
|
| 451 | + * @param string $context View or edit context. |
|
| 452 | + * @return string |
|
| 453 | + */ |
|
| 454 | + public function get_due_date( $context = 'view' ) { |
|
| 455 | + return $this->get_prop( 'due_date', $context ); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | - * Alias for self::get_due_date(). |
|
| 460 | - * |
|
| 461 | - * @since 1.0.19 |
|
| 462 | - * @param string $context View or edit context. |
|
| 463 | - * @return string |
|
| 464 | - */ |
|
| 465 | - public function get_date_due( $context = 'view' ) { |
|
| 466 | - return $this->get_due_date( $context ); |
|
| 459 | + * Alias for self::get_due_date(). |
|
| 460 | + * |
|
| 461 | + * @since 1.0.19 |
|
| 462 | + * @param string $context View or edit context. |
|
| 463 | + * @return string |
|
| 464 | + */ |
|
| 465 | + public function get_date_due( $context = 'view' ) { |
|
| 466 | + return $this->get_due_date( $context ); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
| 470 | - * Get the invoice GMT due date. |
|
| 471 | - * |
|
| 472 | - * @since 1.0.19 |
|
| 473 | - * @param string $context View or edit context. |
|
| 474 | - * @return string |
|
| 475 | - */ |
|
| 476 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 470 | + * Get the invoice GMT due date. |
|
| 471 | + * |
|
| 472 | + * @since 1.0.19 |
|
| 473 | + * @param string $context View or edit context. |
|
| 474 | + * @return string |
|
| 475 | + */ |
|
| 476 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 477 | 477 | $date = $this->get_due_date( $context ); |
| 478 | 478 | |
| 479 | 479 | if ( $date ) { |
| 480 | 480 | $date = get_gmt_from_date( $date ); |
| 481 | 481 | } |
| 482 | - return $date; |
|
| 482 | + return $date; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | /** |
| 486 | - * Alias for self::get_due_date_gmt(). |
|
| 487 | - * |
|
| 488 | - * @since 1.0.19 |
|
| 489 | - * @param string $context View or edit context. |
|
| 490 | - * @return string |
|
| 491 | - */ |
|
| 492 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 493 | - return $this->get_due_date_gmt( $context ); |
|
| 486 | + * Alias for self::get_due_date_gmt(). |
|
| 487 | + * |
|
| 488 | + * @since 1.0.19 |
|
| 489 | + * @param string $context View or edit context. |
|
| 490 | + * @return string |
|
| 491 | + */ |
|
| 492 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 493 | + return $this->get_due_date_gmt( $context ); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
| 497 | - * Get date when the invoice was completed. |
|
| 498 | - * |
|
| 499 | - * @since 1.0.19 |
|
| 500 | - * @param string $context View or edit context. |
|
| 501 | - * @return string |
|
| 502 | - */ |
|
| 503 | - public function get_completed_date( $context = 'view' ) { |
|
| 504 | - return $this->get_prop( 'completed_date', $context ); |
|
| 497 | + * Get date when the invoice was completed. |
|
| 498 | + * |
|
| 499 | + * @since 1.0.19 |
|
| 500 | + * @param string $context View or edit context. |
|
| 501 | + * @return string |
|
| 502 | + */ |
|
| 503 | + public function get_completed_date( $context = 'view' ) { |
|
| 504 | + return $this->get_prop( 'completed_date', $context ); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /** |
| 508 | - * Alias for self::get_completed_date(). |
|
| 509 | - * |
|
| 510 | - * @since 1.0.19 |
|
| 511 | - * @param string $context View or edit context. |
|
| 512 | - * @return string |
|
| 513 | - */ |
|
| 514 | - public function get_date_completed( $context = 'view' ) { |
|
| 515 | - return $this->get_completed_date( $context ); |
|
| 508 | + * Alias for self::get_completed_date(). |
|
| 509 | + * |
|
| 510 | + * @since 1.0.19 |
|
| 511 | + * @param string $context View or edit context. |
|
| 512 | + * @return string |
|
| 513 | + */ |
|
| 514 | + public function get_date_completed( $context = 'view' ) { |
|
| 515 | + return $this->get_completed_date( $context ); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | - * Get GMT date when the invoice was was completed. |
|
| 520 | - * |
|
| 521 | - * @since 1.0.19 |
|
| 522 | - * @param string $context View or edit context. |
|
| 523 | - * @return string |
|
| 524 | - */ |
|
| 525 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 519 | + * Get GMT date when the invoice was was completed. |
|
| 520 | + * |
|
| 521 | + * @since 1.0.19 |
|
| 522 | + * @param string $context View or edit context. |
|
| 523 | + * @return string |
|
| 524 | + */ |
|
| 525 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 526 | 526 | $date = $this->get_completed_date( $context ); |
| 527 | 527 | |
| 528 | 528 | if ( $date ) { |
| 529 | 529 | $date = get_gmt_from_date( $date ); |
| 530 | 530 | } |
| 531 | - return $date; |
|
| 531 | + return $date; |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
| 535 | - * Alias for self::get_completed_date_gmt(). |
|
| 536 | - * |
|
| 537 | - * @since 1.0.19 |
|
| 538 | - * @param string $context View or edit context. |
|
| 539 | - * @return string |
|
| 540 | - */ |
|
| 541 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 542 | - return $this->get_completed_date_gmt( $context ); |
|
| 535 | + * Alias for self::get_completed_date_gmt(). |
|
| 536 | + * |
|
| 537 | + * @since 1.0.19 |
|
| 538 | + * @param string $context View or edit context. |
|
| 539 | + * @return string |
|
| 540 | + */ |
|
| 541 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 542 | + return $this->get_completed_date_gmt( $context ); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
| 546 | - * Get the invoice number. |
|
| 547 | - * |
|
| 548 | - * @since 1.0.19 |
|
| 549 | - * @param string $context View or edit context. |
|
| 550 | - * @return string |
|
| 551 | - */ |
|
| 552 | - public function get_number( $context = 'view' ) { |
|
| 553 | - $number = $this->get_prop( 'number', $context ); |
|
| 546 | + * Get the invoice number. |
|
| 547 | + * |
|
| 548 | + * @since 1.0.19 |
|
| 549 | + * @param string $context View or edit context. |
|
| 550 | + * @return string |
|
| 551 | + */ |
|
| 552 | + public function get_number( $context = 'view' ) { |
|
| 553 | + $number = $this->get_prop( 'number', $context ); |
|
| 554 | 554 | |
| 555 | - if ( empty( $number ) ) { |
|
| 556 | - $number = $this->generate_number(); |
|
| 557 | - $this->set_number( $this->generate_number() ); |
|
| 558 | - } |
|
| 555 | + if ( empty( $number ) ) { |
|
| 556 | + $number = $this->generate_number(); |
|
| 557 | + $this->set_number( $this->generate_number() ); |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | - return $number; |
|
| 560 | + return $number; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - /** |
|
| 564 | - * Set the invoice number. |
|
| 565 | - * |
|
| 566 | - * @since 1.0.19 |
|
| 567 | - */ |
|
| 568 | - public function maybe_set_number() { |
|
| 563 | + /** |
|
| 564 | + * Set the invoice number. |
|
| 565 | + * |
|
| 566 | + * @since 1.0.19 |
|
| 567 | + */ |
|
| 568 | + public function maybe_set_number() { |
|
| 569 | 569 | $number = $this->get_number(); |
| 570 | 570 | |
| 571 | 571 | if ( empty( $number ) || $this->get_id() == $number ) { |
| 572 | - $this->set_number( $this->generate_number() ); |
|
| 572 | + $this->set_number( $this->generate_number() ); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - } |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | 577 | /** |
| 578 | - * Get the invoice key. |
|
| 579 | - * |
|
| 580 | - * @since 1.0.19 |
|
| 581 | - * @param string $context View or edit context. |
|
| 582 | - * @return string |
|
| 583 | - */ |
|
| 584 | - public function get_key( $context = 'view' ) { |
|
| 578 | + * Get the invoice key. |
|
| 579 | + * |
|
| 580 | + * @since 1.0.19 |
|
| 581 | + * @param string $context View or edit context. |
|
| 582 | + * @return string |
|
| 583 | + */ |
|
| 584 | + public function get_key( $context = 'view' ) { |
|
| 585 | 585 | return $this->get_prop( 'key', $context ); |
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * Set the invoice key. |
|
| 590 | - * |
|
| 591 | - * @since 1.0.19 |
|
| 592 | - */ |
|
| 593 | - public function maybe_set_key() { |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * Set the invoice key. |
|
| 590 | + * |
|
| 591 | + * @since 1.0.19 |
|
| 592 | + */ |
|
| 593 | + public function maybe_set_key() { |
|
| 594 | 594 | $key = $this->get_key(); |
| 595 | 595 | |
| 596 | 596 | if ( empty( $key ) ) { |
@@ -601,140 +601,140 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
| 604 | - * Get the invoice type. |
|
| 605 | - * |
|
| 606 | - * @since 1.0.19 |
|
| 607 | - * @param string $context View or edit context. |
|
| 608 | - * @return string |
|
| 609 | - */ |
|
| 610 | - public function get_type( $context = 'view' ) { |
|
| 604 | + * Get the invoice type. |
|
| 605 | + * |
|
| 606 | + * @since 1.0.19 |
|
| 607 | + * @param string $context View or edit context. |
|
| 608 | + * @return string |
|
| 609 | + */ |
|
| 610 | + public function get_type( $context = 'view' ) { |
|
| 611 | 611 | return $this->get_prop( 'type', $context ); |
| 612 | - } |
|
| 613 | - |
|
| 614 | - /** |
|
| 615 | - * Returns the post type name. |
|
| 616 | - * |
|
| 617 | - * @since 1.0.19 |
|
| 618 | - * @return string |
|
| 619 | - */ |
|
| 620 | - public function get_invoice_quote_type() { |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + /** |
|
| 615 | + * Returns the post type name. |
|
| 616 | + * |
|
| 617 | + * @since 1.0.19 |
|
| 618 | + * @return string |
|
| 619 | + */ |
|
| 620 | + public function get_invoice_quote_type() { |
|
| 621 | 621 | return getpaid_get_post_type_label( $this->get_post_type(), false ); |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
| 625 | - * Get the invoice post type label. |
|
| 626 | - * |
|
| 627 | - * @since 1.0.19 |
|
| 628 | - * @param string $context View or edit context. |
|
| 629 | - * @return string |
|
| 630 | - */ |
|
| 631 | - public function get_label( $context = 'view' ) { |
|
| 625 | + * Get the invoice post type label. |
|
| 626 | + * |
|
| 627 | + * @since 1.0.19 |
|
| 628 | + * @param string $context View or edit context. |
|
| 629 | + * @return string |
|
| 630 | + */ |
|
| 631 | + public function get_label( $context = 'view' ) { |
|
| 632 | 632 | return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
| 633 | - } |
|
| 634 | - |
|
| 635 | - /** |
|
| 636 | - * Get the invoice post type. |
|
| 637 | - * |
|
| 638 | - * @since 1.0.19 |
|
| 639 | - * @param string $context View or edit context. |
|
| 640 | - * @return string |
|
| 641 | - */ |
|
| 642 | - public function get_post_type( $context = 'view' ) { |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + /** |
|
| 636 | + * Get the invoice post type. |
|
| 637 | + * |
|
| 638 | + * @since 1.0.19 |
|
| 639 | + * @param string $context View or edit context. |
|
| 640 | + * @return string |
|
| 641 | + */ |
|
| 642 | + public function get_post_type( $context = 'view' ) { |
|
| 643 | 643 | return $this->get_prop( 'post_type', $context ); |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | /** |
| 647 | - * Get the invoice mode. |
|
| 648 | - * |
|
| 649 | - * @since 1.0.19 |
|
| 650 | - * @param string $context View or edit context. |
|
| 651 | - * @return string |
|
| 652 | - */ |
|
| 653 | - public function get_mode( $context = 'view' ) { |
|
| 647 | + * Get the invoice mode. |
|
| 648 | + * |
|
| 649 | + * @since 1.0.19 |
|
| 650 | + * @param string $context View or edit context. |
|
| 651 | + * @return string |
|
| 652 | + */ |
|
| 653 | + public function get_mode( $context = 'view' ) { |
|
| 654 | 654 | return $this->get_prop( 'mode', $context ); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
| 658 | - * Get the invoice path. |
|
| 659 | - * |
|
| 660 | - * @since 1.0.19 |
|
| 661 | - * @param string $context View or edit context. |
|
| 662 | - * @return string |
|
| 663 | - */ |
|
| 664 | - public function get_path( $context = 'view' ) { |
|
| 658 | + * Get the invoice path. |
|
| 659 | + * |
|
| 660 | + * @since 1.0.19 |
|
| 661 | + * @param string $context View or edit context. |
|
| 662 | + * @return string |
|
| 663 | + */ |
|
| 664 | + public function get_path( $context = 'view' ) { |
|
| 665 | 665 | $path = $this->get_prop( 'path', $context ); |
| 666 | - $prefix = $this->get_type(); |
|
| 666 | + $prefix = $this->get_type(); |
|
| 667 | 667 | |
| 668 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 669 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 670 | - $this->set_path( $path ); |
|
| 671 | - } |
|
| 668 | + if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 669 | + $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 670 | + $this->set_path( $path ); |
|
| 671 | + } |
|
| 672 | 672 | |
| 673 | - return $path; |
|
| 673 | + return $path; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * Get the invoice name/title. |
|
| 678 | - * |
|
| 679 | - * @since 1.0.19 |
|
| 680 | - * @param string $context View or edit context. |
|
| 681 | - * @return string |
|
| 682 | - */ |
|
| 683 | - public function get_name( $context = 'view' ) { |
|
| 677 | + * Get the invoice name/title. |
|
| 678 | + * |
|
| 679 | + * @since 1.0.19 |
|
| 680 | + * @param string $context View or edit context. |
|
| 681 | + * @return string |
|
| 682 | + */ |
|
| 683 | + public function get_name( $context = 'view' ) { |
|
| 684 | 684 | return $this->get_prop( 'title', $context ); |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
| 688 | - * Alias of self::get_name(). |
|
| 689 | - * |
|
| 690 | - * @since 1.0.19 |
|
| 691 | - * @param string $context View or edit context. |
|
| 692 | - * @return string |
|
| 693 | - */ |
|
| 694 | - public function get_title( $context = 'view' ) { |
|
| 695 | - return $this->get_name( $context ); |
|
| 688 | + * Alias of self::get_name(). |
|
| 689 | + * |
|
| 690 | + * @since 1.0.19 |
|
| 691 | + * @param string $context View or edit context. |
|
| 692 | + * @return string |
|
| 693 | + */ |
|
| 694 | + public function get_title( $context = 'view' ) { |
|
| 695 | + return $this->get_name( $context ); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | /** |
| 699 | - * Get the invoice description. |
|
| 700 | - * |
|
| 701 | - * @since 1.0.19 |
|
| 702 | - * @param string $context View or edit context. |
|
| 703 | - * @return string |
|
| 704 | - */ |
|
| 705 | - public function get_description( $context = 'view' ) { |
|
| 706 | - return $this->get_prop( 'description', $context ); |
|
| 699 | + * Get the invoice description. |
|
| 700 | + * |
|
| 701 | + * @since 1.0.19 |
|
| 702 | + * @param string $context View or edit context. |
|
| 703 | + * @return string |
|
| 704 | + */ |
|
| 705 | + public function get_description( $context = 'view' ) { |
|
| 706 | + return $this->get_prop( 'description', $context ); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
| 710 | - * Alias of self::get_description(). |
|
| 711 | - * |
|
| 712 | - * @since 1.0.19 |
|
| 713 | - * @param string $context View or edit context. |
|
| 714 | - * @return string |
|
| 715 | - */ |
|
| 716 | - public function get_excerpt( $context = 'view' ) { |
|
| 717 | - return $this->get_description( $context ); |
|
| 710 | + * Alias of self::get_description(). |
|
| 711 | + * |
|
| 712 | + * @since 1.0.19 |
|
| 713 | + * @param string $context View or edit context. |
|
| 714 | + * @return string |
|
| 715 | + */ |
|
| 716 | + public function get_excerpt( $context = 'view' ) { |
|
| 717 | + return $this->get_description( $context ); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
| 721 | - * Alias of self::get_description(). |
|
| 722 | - * |
|
| 723 | - * @since 1.0.19 |
|
| 724 | - * @param string $context View or edit context. |
|
| 725 | - * @return string |
|
| 726 | - */ |
|
| 727 | - public function get_summary( $context = 'view' ) { |
|
| 728 | - return $this->get_description( $context ); |
|
| 721 | + * Alias of self::get_description(). |
|
| 722 | + * |
|
| 723 | + * @since 1.0.19 |
|
| 724 | + * @param string $context View or edit context. |
|
| 725 | + * @return string |
|
| 726 | + */ |
|
| 727 | + public function get_summary( $context = 'view' ) { |
|
| 728 | + return $this->get_description( $context ); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
| 732 | - * Returns the user info. |
|
| 733 | - * |
|
| 734 | - * @since 1.0.19 |
|
| 732 | + * Returns the user info. |
|
| 733 | + * |
|
| 734 | + * @since 1.0.19 |
|
| 735 | 735 | * @param string $context View or edit context. |
| 736 | - * @return array |
|
| 737 | - */ |
|
| 736 | + * @return array |
|
| 737 | + */ |
|
| 738 | 738 | public function get_user_info( $context = 'view' ) { |
| 739 | 739 | |
| 740 | 740 | $user_info = array( |
@@ -751,616 +751,616 @@ discard block |
||
| 751 | 751 | 'company' => $this->get_company( $context ), |
| 752 | 752 | 'vat_number' => $this->get_vat_number( $context ), |
| 753 | 753 | 'discount' => $this->get_discount_code( $context ), |
| 754 | - ); |
|
| 754 | + ); |
|
| 755 | 755 | |
| 756 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 756 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 757 | 757 | |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | - * Get the customer id. |
|
| 762 | - * |
|
| 763 | - * @since 1.0.19 |
|
| 764 | - * @param string $context View or edit context. |
|
| 765 | - * @return int |
|
| 766 | - */ |
|
| 767 | - public function get_author( $context = 'view' ) { |
|
| 768 | - return (int) $this->get_prop( 'author', $context ); |
|
| 761 | + * Get the customer id. |
|
| 762 | + * |
|
| 763 | + * @since 1.0.19 |
|
| 764 | + * @param string $context View or edit context. |
|
| 765 | + * @return int |
|
| 766 | + */ |
|
| 767 | + public function get_author( $context = 'view' ) { |
|
| 768 | + return (int) $this->get_prop( 'author', $context ); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
| 772 | - * Alias of self::get_author(). |
|
| 773 | - * |
|
| 774 | - * @since 1.0.19 |
|
| 775 | - * @param string $context View or edit context. |
|
| 776 | - * @return int |
|
| 777 | - */ |
|
| 778 | - public function get_user_id( $context = 'view' ) { |
|
| 779 | - return $this->get_author( $context ); |
|
| 772 | + * Alias of self::get_author(). |
|
| 773 | + * |
|
| 774 | + * @since 1.0.19 |
|
| 775 | + * @param string $context View or edit context. |
|
| 776 | + * @return int |
|
| 777 | + */ |
|
| 778 | + public function get_user_id( $context = 'view' ) { |
|
| 779 | + return $this->get_author( $context ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - /** |
|
| 783 | - * Alias of self::get_author(). |
|
| 784 | - * |
|
| 785 | - * @since 1.0.19 |
|
| 786 | - * @param string $context View or edit context. |
|
| 787 | - * @return int |
|
| 788 | - */ |
|
| 789 | - public function get_customer_id( $context = 'view' ) { |
|
| 790 | - return $this->get_author( $context ); |
|
| 782 | + /** |
|
| 783 | + * Alias of self::get_author(). |
|
| 784 | + * |
|
| 785 | + * @since 1.0.19 |
|
| 786 | + * @param string $context View or edit context. |
|
| 787 | + * @return int |
|
| 788 | + */ |
|
| 789 | + public function get_customer_id( $context = 'view' ) { |
|
| 790 | + return $this->get_author( $context ); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
| 794 | - * Get the customer's ip. |
|
| 795 | - * |
|
| 796 | - * @since 1.0.19 |
|
| 797 | - * @param string $context View or edit context. |
|
| 798 | - * @return string |
|
| 799 | - */ |
|
| 800 | - public function get_ip( $context = 'view' ) { |
|
| 801 | - return $this->get_prop( 'user_ip', $context ); |
|
| 794 | + * Get the customer's ip. |
|
| 795 | + * |
|
| 796 | + * @since 1.0.19 |
|
| 797 | + * @param string $context View or edit context. |
|
| 798 | + * @return string |
|
| 799 | + */ |
|
| 800 | + public function get_ip( $context = 'view' ) { |
|
| 801 | + return $this->get_prop( 'user_ip', $context ); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | - * Alias of self::get_ip(). |
|
| 806 | - * |
|
| 807 | - * @since 1.0.19 |
|
| 808 | - * @param string $context View or edit context. |
|
| 809 | - * @return string |
|
| 810 | - */ |
|
| 811 | - public function get_user_ip( $context = 'view' ) { |
|
| 812 | - return $this->get_ip( $context ); |
|
| 805 | + * Alias of self::get_ip(). |
|
| 806 | + * |
|
| 807 | + * @since 1.0.19 |
|
| 808 | + * @param string $context View or edit context. |
|
| 809 | + * @return string |
|
| 810 | + */ |
|
| 811 | + public function get_user_ip( $context = 'view' ) { |
|
| 812 | + return $this->get_ip( $context ); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - /** |
|
| 816 | - * Alias of self::get_ip(). |
|
| 817 | - * |
|
| 818 | - * @since 1.0.19 |
|
| 819 | - * @param string $context View or edit context. |
|
| 820 | - * @return string |
|
| 821 | - */ |
|
| 822 | - public function get_customer_ip( $context = 'view' ) { |
|
| 823 | - return $this->get_ip( $context ); |
|
| 815 | + /** |
|
| 816 | + * Alias of self::get_ip(). |
|
| 817 | + * |
|
| 818 | + * @since 1.0.19 |
|
| 819 | + * @param string $context View or edit context. |
|
| 820 | + * @return string |
|
| 821 | + */ |
|
| 822 | + public function get_customer_ip( $context = 'view' ) { |
|
| 823 | + return $this->get_ip( $context ); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |
| 827 | - * Get the customer's first name. |
|
| 828 | - * |
|
| 829 | - * @since 1.0.19 |
|
| 830 | - * @param string $context View or edit context. |
|
| 831 | - * @return string |
|
| 832 | - */ |
|
| 833 | - public function get_first_name( $context = 'view' ) { |
|
| 834 | - return $this->get_prop( 'first_name', $context ); |
|
| 827 | + * Get the customer's first name. |
|
| 828 | + * |
|
| 829 | + * @since 1.0.19 |
|
| 830 | + * @param string $context View or edit context. |
|
| 831 | + * @return string |
|
| 832 | + */ |
|
| 833 | + public function get_first_name( $context = 'view' ) { |
|
| 834 | + return $this->get_prop( 'first_name', $context ); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
| 838 | - * Alias of self::get_first_name(). |
|
| 839 | - * |
|
| 840 | - * @since 1.0.19 |
|
| 841 | - * @param string $context View or edit context. |
|
| 842 | - * @return string |
|
| 843 | - */ |
|
| 844 | - public function get_user_first_name( $context = 'view' ) { |
|
| 845 | - return $this->get_first_name( $context ); |
|
| 838 | + * Alias of self::get_first_name(). |
|
| 839 | + * |
|
| 840 | + * @since 1.0.19 |
|
| 841 | + * @param string $context View or edit context. |
|
| 842 | + * @return string |
|
| 843 | + */ |
|
| 844 | + public function get_user_first_name( $context = 'view' ) { |
|
| 845 | + return $this->get_first_name( $context ); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - /** |
|
| 849 | - * Alias of self::get_first_name(). |
|
| 850 | - * |
|
| 851 | - * @since 1.0.19 |
|
| 852 | - * @param string $context View or edit context. |
|
| 853 | - * @return string |
|
| 854 | - */ |
|
| 855 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 856 | - return $this->get_first_name( $context ); |
|
| 848 | + /** |
|
| 849 | + * Alias of self::get_first_name(). |
|
| 850 | + * |
|
| 851 | + * @since 1.0.19 |
|
| 852 | + * @param string $context View or edit context. |
|
| 853 | + * @return string |
|
| 854 | + */ |
|
| 855 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 856 | + return $this->get_first_name( $context ); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
| 860 | - * Get the customer's last name. |
|
| 861 | - * |
|
| 862 | - * @since 1.0.19 |
|
| 863 | - * @param string $context View or edit context. |
|
| 864 | - * @return string |
|
| 865 | - */ |
|
| 866 | - public function get_last_name( $context = 'view' ) { |
|
| 867 | - return $this->get_prop( 'last_name', $context ); |
|
| 860 | + * Get the customer's last name. |
|
| 861 | + * |
|
| 862 | + * @since 1.0.19 |
|
| 863 | + * @param string $context View or edit context. |
|
| 864 | + * @return string |
|
| 865 | + */ |
|
| 866 | + public function get_last_name( $context = 'view' ) { |
|
| 867 | + return $this->get_prop( 'last_name', $context ); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
| 871 | - * Alias of self::get_last_name(). |
|
| 872 | - * |
|
| 873 | - * @since 1.0.19 |
|
| 874 | - * @param string $context View or edit context. |
|
| 875 | - * @return string |
|
| 876 | - */ |
|
| 877 | - public function get_user_last_name( $context = 'view' ) { |
|
| 878 | - return $this->get_last_name( $context ); |
|
| 871 | + * Alias of self::get_last_name(). |
|
| 872 | + * |
|
| 873 | + * @since 1.0.19 |
|
| 874 | + * @param string $context View or edit context. |
|
| 875 | + * @return string |
|
| 876 | + */ |
|
| 877 | + public function get_user_last_name( $context = 'view' ) { |
|
| 878 | + return $this->get_last_name( $context ); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
| 882 | - * Alias of self::get_last_name(). |
|
| 883 | - * |
|
| 884 | - * @since 1.0.19 |
|
| 885 | - * @param string $context View or edit context. |
|
| 886 | - * @return string |
|
| 887 | - */ |
|
| 888 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 889 | - return $this->get_last_name( $context ); |
|
| 882 | + * Alias of self::get_last_name(). |
|
| 883 | + * |
|
| 884 | + * @since 1.0.19 |
|
| 885 | + * @param string $context View or edit context. |
|
| 886 | + * @return string |
|
| 887 | + */ |
|
| 888 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 889 | + return $this->get_last_name( $context ); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | /** |
| 893 | - * Get the customer's full name. |
|
| 894 | - * |
|
| 895 | - * @since 1.0.19 |
|
| 896 | - * @param string $context View or edit context. |
|
| 897 | - * @return string |
|
| 898 | - */ |
|
| 899 | - public function get_full_name( $context = 'view' ) { |
|
| 900 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 893 | + * Get the customer's full name. |
|
| 894 | + * |
|
| 895 | + * @since 1.0.19 |
|
| 896 | + * @param string $context View or edit context. |
|
| 897 | + * @return string |
|
| 898 | + */ |
|
| 899 | + public function get_full_name( $context = 'view' ) { |
|
| 900 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
| 904 | - * Alias of self::get_full_name(). |
|
| 905 | - * |
|
| 906 | - * @since 1.0.19 |
|
| 907 | - * @param string $context View or edit context. |
|
| 908 | - * @return string |
|
| 909 | - */ |
|
| 910 | - public function get_user_full_name( $context = 'view' ) { |
|
| 911 | - return $this->get_full_name( $context ); |
|
| 904 | + * Alias of self::get_full_name(). |
|
| 905 | + * |
|
| 906 | + * @since 1.0.19 |
|
| 907 | + * @param string $context View or edit context. |
|
| 908 | + * @return string |
|
| 909 | + */ |
|
| 910 | + public function get_user_full_name( $context = 'view' ) { |
|
| 911 | + return $this->get_full_name( $context ); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
| 915 | - * Alias of self::get_full_name(). |
|
| 916 | - * |
|
| 917 | - * @since 1.0.19 |
|
| 918 | - * @param string $context View or edit context. |
|
| 919 | - * @return string |
|
| 920 | - */ |
|
| 921 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 922 | - return $this->get_full_name( $context ); |
|
| 915 | + * Alias of self::get_full_name(). |
|
| 916 | + * |
|
| 917 | + * @since 1.0.19 |
|
| 918 | + * @param string $context View or edit context. |
|
| 919 | + * @return string |
|
| 920 | + */ |
|
| 921 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 922 | + return $this->get_full_name( $context ); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
| 926 | - * Get the customer's phone number. |
|
| 927 | - * |
|
| 928 | - * @since 1.0.19 |
|
| 929 | - * @param string $context View or edit context. |
|
| 930 | - * @return string |
|
| 931 | - */ |
|
| 932 | - public function get_phone( $context = 'view' ) { |
|
| 933 | - return $this->get_prop( 'phone', $context ); |
|
| 926 | + * Get the customer's phone number. |
|
| 927 | + * |
|
| 928 | + * @since 1.0.19 |
|
| 929 | + * @param string $context View or edit context. |
|
| 930 | + * @return string |
|
| 931 | + */ |
|
| 932 | + public function get_phone( $context = 'view' ) { |
|
| 933 | + return $this->get_prop( 'phone', $context ); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
| 937 | - * Alias of self::get_phone(). |
|
| 938 | - * |
|
| 939 | - * @since 1.0.19 |
|
| 940 | - * @param string $context View or edit context. |
|
| 941 | - * @return string |
|
| 942 | - */ |
|
| 943 | - public function get_phone_number( $context = 'view' ) { |
|
| 944 | - return $this->get_phone( $context ); |
|
| 937 | + * Alias of self::get_phone(). |
|
| 938 | + * |
|
| 939 | + * @since 1.0.19 |
|
| 940 | + * @param string $context View or edit context. |
|
| 941 | + * @return string |
|
| 942 | + */ |
|
| 943 | + public function get_phone_number( $context = 'view' ) { |
|
| 944 | + return $this->get_phone( $context ); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | /** |
| 948 | - * Alias of self::get_phone(). |
|
| 949 | - * |
|
| 950 | - * @since 1.0.19 |
|
| 951 | - * @param string $context View or edit context. |
|
| 952 | - * @return string |
|
| 953 | - */ |
|
| 954 | - public function get_user_phone( $context = 'view' ) { |
|
| 955 | - return $this->get_phone( $context ); |
|
| 956 | - } |
|
| 957 | - |
|
| 948 | + * Alias of self::get_phone(). |
|
| 949 | + * |
|
| 950 | + * @since 1.0.19 |
|
| 951 | + * @param string $context View or edit context. |
|
| 952 | + * @return string |
|
| 953 | + */ |
|
| 954 | + public function get_user_phone( $context = 'view' ) { |
|
| 955 | + return $this->get_phone( $context ); |
|
| 956 | + } |
|
| 957 | + |
|
| 958 | + /** |
|
| 959 | + * Alias of self::get_phone(). |
|
| 960 | + * |
|
| 961 | + * @since 1.0.19 |
|
| 962 | + * @param string $context View or edit context. |
|
| 963 | + * @return string |
|
| 964 | + */ |
|
| 965 | + public function get_customer_phone( $context = 'view' ) { |
|
| 966 | + return $this->get_phone( $context ); |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + /** |
|
| 970 | + * Get the customer's email address. |
|
| 971 | + * |
|
| 972 | + * @since 1.0.19 |
|
| 973 | + * @param string $context View or edit context. |
|
| 974 | + * @return string |
|
| 975 | + */ |
|
| 976 | + public function get_email( $context = 'view' ) { |
|
| 977 | + return $this->get_prop( 'email', $context ); |
|
| 978 | + } |
|
| 979 | + |
|
| 980 | + /** |
|
| 981 | + * Alias of self::get_email(). |
|
| 982 | + * |
|
| 983 | + * @since 1.0.19 |
|
| 984 | + * @param string $context View or edit context. |
|
| 985 | + * @return string |
|
| 986 | + */ |
|
| 987 | + public function get_email_address( $context = 'view' ) { |
|
| 988 | + return $this->get_email( $context ); |
|
| 989 | + } |
|
| 990 | + |
|
| 991 | + /** |
|
| 992 | + * Alias of self::get_email(). |
|
| 993 | + * |
|
| 994 | + * @since 1.0.19 |
|
| 995 | + * @param string $context View or edit context. |
|
| 996 | + * @return string |
|
| 997 | + */ |
|
| 998 | + public function get_user_email( $context = 'view' ) { |
|
| 999 | + return $this->get_email( $context ); |
|
| 1000 | + } |
|
| 1001 | + |
|
| 1002 | + /** |
|
| 1003 | + * Alias of self::get_email(). |
|
| 1004 | + * |
|
| 1005 | + * @since 1.0.19 |
|
| 1006 | + * @param string $context View or edit context. |
|
| 1007 | + * @return string |
|
| 1008 | + */ |
|
| 1009 | + public function get_customer_email( $context = 'view' ) { |
|
| 1010 | + return $this->get_email( $context ); |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + /** |
|
| 1014 | + * Get the customer's country. |
|
| 1015 | + * |
|
| 1016 | + * @since 1.0.19 |
|
| 1017 | + * @param string $context View or edit context. |
|
| 1018 | + * @return string |
|
| 1019 | + */ |
|
| 1020 | + public function get_country( $context = 'view' ) { |
|
| 1021 | + $country = $this->get_prop( 'country', $context ); |
|
| 1022 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * Alias of self::get_country(). |
|
| 1027 | + * |
|
| 1028 | + * @since 1.0.19 |
|
| 1029 | + * @param string $context View or edit context. |
|
| 1030 | + * @return string |
|
| 1031 | + */ |
|
| 1032 | + public function get_user_country( $context = 'view' ) { |
|
| 1033 | + return $this->get_country( $context ); |
|
| 1034 | + } |
|
| 1035 | + |
|
| 1036 | + /** |
|
| 1037 | + * Alias of self::get_country(). |
|
| 1038 | + * |
|
| 1039 | + * @since 1.0.19 |
|
| 1040 | + * @param string $context View or edit context. |
|
| 1041 | + * @return string |
|
| 1042 | + */ |
|
| 1043 | + public function get_customer_country( $context = 'view' ) { |
|
| 1044 | + return $this->get_country( $context ); |
|
| 1045 | + } |
|
| 1046 | + |
|
| 1047 | + /** |
|
| 1048 | + * Get the customer's state. |
|
| 1049 | + * |
|
| 1050 | + * @since 1.0.19 |
|
| 1051 | + * @param string $context View or edit context. |
|
| 1052 | + * @return string |
|
| 1053 | + */ |
|
| 1054 | + public function get_state( $context = 'view' ) { |
|
| 1055 | + $state = $this->get_prop( 'state', $context ); |
|
| 1056 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1057 | + } |
|
| 1058 | + |
|
| 958 | 1059 | /** |
| 959 | - * Alias of self::get_phone(). |
|
| 960 | - * |
|
| 961 | - * @since 1.0.19 |
|
| 962 | - * @param string $context View or edit context. |
|
| 963 | - * @return string |
|
| 964 | - */ |
|
| 965 | - public function get_customer_phone( $context = 'view' ) { |
|
| 966 | - return $this->get_phone( $context ); |
|
| 1060 | + * Alias of self::get_state(). |
|
| 1061 | + * |
|
| 1062 | + * @since 1.0.19 |
|
| 1063 | + * @param string $context View or edit context. |
|
| 1064 | + * @return string |
|
| 1065 | + */ |
|
| 1066 | + public function get_user_state( $context = 'view' ) { |
|
| 1067 | + return $this->get_state( $context ); |
|
| 967 | 1068 | } |
| 968 | 1069 | |
| 969 | 1070 | /** |
| 970 | - * Get the customer's email address. |
|
| 971 | - * |
|
| 972 | - * @since 1.0.19 |
|
| 973 | - * @param string $context View or edit context. |
|
| 974 | - * @return string |
|
| 975 | - */ |
|
| 976 | - public function get_email( $context = 'view' ) { |
|
| 977 | - return $this->get_prop( 'email', $context ); |
|
| 1071 | + * Alias of self::get_state(). |
|
| 1072 | + * |
|
| 1073 | + * @since 1.0.19 |
|
| 1074 | + * @param string $context View or edit context. |
|
| 1075 | + * @return string |
|
| 1076 | + */ |
|
| 1077 | + public function get_customer_state( $context = 'view' ) { |
|
| 1078 | + return $this->get_state( $context ); |
|
| 978 | 1079 | } |
| 979 | 1080 | |
| 980 | 1081 | /** |
| 981 | - * Alias of self::get_email(). |
|
| 982 | - * |
|
| 983 | - * @since 1.0.19 |
|
| 984 | - * @param string $context View or edit context. |
|
| 985 | - * @return string |
|
| 986 | - */ |
|
| 987 | - public function get_email_address( $context = 'view' ) { |
|
| 988 | - return $this->get_email( $context ); |
|
| 1082 | + * Get the customer's city. |
|
| 1083 | + * |
|
| 1084 | + * @since 1.0.19 |
|
| 1085 | + * @param string $context View or edit context. |
|
| 1086 | + * @return string |
|
| 1087 | + */ |
|
| 1088 | + public function get_city( $context = 'view' ) { |
|
| 1089 | + return $this->get_prop( 'city', $context ); |
|
| 989 | 1090 | } |
| 990 | 1091 | |
| 991 | 1092 | /** |
| 992 | - * Alias of self::get_email(). |
|
| 993 | - * |
|
| 994 | - * @since 1.0.19 |
|
| 995 | - * @param string $context View or edit context. |
|
| 996 | - * @return string |
|
| 997 | - */ |
|
| 998 | - public function get_user_email( $context = 'view' ) { |
|
| 999 | - return $this->get_email( $context ); |
|
| 1093 | + * Alias of self::get_city(). |
|
| 1094 | + * |
|
| 1095 | + * @since 1.0.19 |
|
| 1096 | + * @param string $context View or edit context. |
|
| 1097 | + * @return string |
|
| 1098 | + */ |
|
| 1099 | + public function get_user_city( $context = 'view' ) { |
|
| 1100 | + return $this->get_city( $context ); |
|
| 1000 | 1101 | } |
| 1001 | 1102 | |
| 1002 | 1103 | /** |
| 1003 | - * Alias of self::get_email(). |
|
| 1004 | - * |
|
| 1005 | - * @since 1.0.19 |
|
| 1006 | - * @param string $context View or edit context. |
|
| 1007 | - * @return string |
|
| 1008 | - */ |
|
| 1009 | - public function get_customer_email( $context = 'view' ) { |
|
| 1010 | - return $this->get_email( $context ); |
|
| 1104 | + * Alias of self::get_city(). |
|
| 1105 | + * |
|
| 1106 | + * @since 1.0.19 |
|
| 1107 | + * @param string $context View or edit context. |
|
| 1108 | + * @return string |
|
| 1109 | + */ |
|
| 1110 | + public function get_customer_city( $context = 'view' ) { |
|
| 1111 | + return $this->get_city( $context ); |
|
| 1011 | 1112 | } |
| 1012 | 1113 | |
| 1013 | 1114 | /** |
| 1014 | - * Get the customer's country. |
|
| 1015 | - * |
|
| 1016 | - * @since 1.0.19 |
|
| 1017 | - * @param string $context View or edit context. |
|
| 1018 | - * @return string |
|
| 1019 | - */ |
|
| 1020 | - public function get_country( $context = 'view' ) { |
|
| 1021 | - $country = $this->get_prop( 'country', $context ); |
|
| 1022 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1115 | + * Get the customer's zip. |
|
| 1116 | + * |
|
| 1117 | + * @since 1.0.19 |
|
| 1118 | + * @param string $context View or edit context. |
|
| 1119 | + * @return string |
|
| 1120 | + */ |
|
| 1121 | + public function get_zip( $context = 'view' ) { |
|
| 1122 | + return $this->get_prop( 'zip', $context ); |
|
| 1023 | 1123 | } |
| 1024 | 1124 | |
| 1025 | 1125 | /** |
| 1026 | - * Alias of self::get_country(). |
|
| 1027 | - * |
|
| 1028 | - * @since 1.0.19 |
|
| 1029 | - * @param string $context View or edit context. |
|
| 1030 | - * @return string |
|
| 1031 | - */ |
|
| 1032 | - public function get_user_country( $context = 'view' ) { |
|
| 1033 | - return $this->get_country( $context ); |
|
| 1126 | + * Alias of self::get_zip(). |
|
| 1127 | + * |
|
| 1128 | + * @since 1.0.19 |
|
| 1129 | + * @param string $context View or edit context. |
|
| 1130 | + * @return string |
|
| 1131 | + */ |
|
| 1132 | + public function get_user_zip( $context = 'view' ) { |
|
| 1133 | + return $this->get_zip( $context ); |
|
| 1134 | + } |
|
| 1135 | + |
|
| 1136 | + /** |
|
| 1137 | + * Alias of self::get_zip(). |
|
| 1138 | + * |
|
| 1139 | + * @since 1.0.19 |
|
| 1140 | + * @param string $context View or edit context. |
|
| 1141 | + * @return string |
|
| 1142 | + */ |
|
| 1143 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1144 | + return $this->get_zip( $context ); |
|
| 1145 | + } |
|
| 1146 | + |
|
| 1147 | + /** |
|
| 1148 | + * Get the customer's company. |
|
| 1149 | + * |
|
| 1150 | + * @since 1.0.19 |
|
| 1151 | + * @param string $context View or edit context. |
|
| 1152 | + * @return string |
|
| 1153 | + */ |
|
| 1154 | + public function get_company( $context = 'view' ) { |
|
| 1155 | + return $this->get_prop( 'company', $context ); |
|
| 1034 | 1156 | } |
| 1035 | 1157 | |
| 1036 | 1158 | /** |
| 1037 | - * Alias of self::get_country(). |
|
| 1038 | - * |
|
| 1039 | - * @since 1.0.19 |
|
| 1040 | - * @param string $context View or edit context. |
|
| 1041 | - * @return string |
|
| 1042 | - */ |
|
| 1043 | - public function get_customer_country( $context = 'view' ) { |
|
| 1044 | - return $this->get_country( $context ); |
|
| 1159 | + * Alias of self::get_company(). |
|
| 1160 | + * |
|
| 1161 | + * @since 1.0.19 |
|
| 1162 | + * @param string $context View or edit context. |
|
| 1163 | + * @return string |
|
| 1164 | + */ |
|
| 1165 | + public function get_user_company( $context = 'view' ) { |
|
| 1166 | + return $this->get_company( $context ); |
|
| 1167 | + } |
|
| 1168 | + |
|
| 1169 | + /** |
|
| 1170 | + * Alias of self::get_company(). |
|
| 1171 | + * |
|
| 1172 | + * @since 1.0.19 |
|
| 1173 | + * @param string $context View or edit context. |
|
| 1174 | + * @return string |
|
| 1175 | + */ |
|
| 1176 | + public function get_customer_company( $context = 'view' ) { |
|
| 1177 | + return $this->get_company( $context ); |
|
| 1178 | + } |
|
| 1179 | + |
|
| 1180 | + /** |
|
| 1181 | + * Get the customer's vat number. |
|
| 1182 | + * |
|
| 1183 | + * @since 1.0.19 |
|
| 1184 | + * @param string $context View or edit context. |
|
| 1185 | + * @return string |
|
| 1186 | + */ |
|
| 1187 | + public function get_vat_number( $context = 'view' ) { |
|
| 1188 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1045 | 1189 | } |
| 1046 | 1190 | |
| 1047 | 1191 | /** |
| 1048 | - * Get the customer's state. |
|
| 1049 | - * |
|
| 1050 | - * @since 1.0.19 |
|
| 1051 | - * @param string $context View or edit context. |
|
| 1052 | - * @return string |
|
| 1053 | - */ |
|
| 1054 | - public function get_state( $context = 'view' ) { |
|
| 1055 | - $state = $this->get_prop( 'state', $context ); |
|
| 1056 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1192 | + * Alias of self::get_vat_number(). |
|
| 1193 | + * |
|
| 1194 | + * @since 1.0.19 |
|
| 1195 | + * @param string $context View or edit context. |
|
| 1196 | + * @return string |
|
| 1197 | + */ |
|
| 1198 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1199 | + return $this->get_vat_number( $context ); |
|
| 1057 | 1200 | } |
| 1058 | 1201 | |
| 1059 | 1202 | /** |
| 1060 | - * Alias of self::get_state(). |
|
| 1061 | - * |
|
| 1062 | - * @since 1.0.19 |
|
| 1063 | - * @param string $context View or edit context. |
|
| 1064 | - * @return string |
|
| 1065 | - */ |
|
| 1066 | - public function get_user_state( $context = 'view' ) { |
|
| 1067 | - return $this->get_state( $context ); |
|
| 1203 | + * Alias of self::get_vat_number(). |
|
| 1204 | + * |
|
| 1205 | + * @since 1.0.19 |
|
| 1206 | + * @param string $context View or edit context. |
|
| 1207 | + * @return string |
|
| 1208 | + */ |
|
| 1209 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1210 | + return $this->get_vat_number( $context ); |
|
| 1068 | 1211 | } |
| 1069 | 1212 | |
| 1070 | 1213 | /** |
| 1071 | - * Alias of self::get_state(). |
|
| 1072 | - * |
|
| 1073 | - * @since 1.0.19 |
|
| 1074 | - * @param string $context View or edit context. |
|
| 1075 | - * @return string |
|
| 1076 | - */ |
|
| 1077 | - public function get_customer_state( $context = 'view' ) { |
|
| 1078 | - return $this->get_state( $context ); |
|
| 1214 | + * Get the customer's vat rate. |
|
| 1215 | + * |
|
| 1216 | + * @since 1.0.19 |
|
| 1217 | + * @param string $context View or edit context. |
|
| 1218 | + * @return string |
|
| 1219 | + */ |
|
| 1220 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1221 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1079 | 1222 | } |
| 1080 | 1223 | |
| 1081 | 1224 | /** |
| 1082 | - * Get the customer's city. |
|
| 1083 | - * |
|
| 1084 | - * @since 1.0.19 |
|
| 1085 | - * @param string $context View or edit context. |
|
| 1086 | - * @return string |
|
| 1087 | - */ |
|
| 1088 | - public function get_city( $context = 'view' ) { |
|
| 1089 | - return $this->get_prop( 'city', $context ); |
|
| 1225 | + * Alias of self::get_vat_rate(). |
|
| 1226 | + * |
|
| 1227 | + * @since 1.0.19 |
|
| 1228 | + * @param string $context View or edit context. |
|
| 1229 | + * @return string |
|
| 1230 | + */ |
|
| 1231 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1232 | + return $this->get_vat_rate( $context ); |
|
| 1090 | 1233 | } |
| 1091 | 1234 | |
| 1092 | 1235 | /** |
| 1093 | - * Alias of self::get_city(). |
|
| 1094 | - * |
|
| 1095 | - * @since 1.0.19 |
|
| 1096 | - * @param string $context View or edit context. |
|
| 1097 | - * @return string |
|
| 1098 | - */ |
|
| 1099 | - public function get_user_city( $context = 'view' ) { |
|
| 1100 | - return $this->get_city( $context ); |
|
| 1236 | + * Alias of self::get_vat_rate(). |
|
| 1237 | + * |
|
| 1238 | + * @since 1.0.19 |
|
| 1239 | + * @param string $context View or edit context. |
|
| 1240 | + * @return string |
|
| 1241 | + */ |
|
| 1242 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1243 | + return $this->get_vat_rate( $context ); |
|
| 1101 | 1244 | } |
| 1102 | 1245 | |
| 1103 | 1246 | /** |
| 1104 | - * Alias of self::get_city(). |
|
| 1105 | - * |
|
| 1106 | - * @since 1.0.19 |
|
| 1107 | - * @param string $context View or edit context. |
|
| 1108 | - * @return string |
|
| 1109 | - */ |
|
| 1110 | - public function get_customer_city( $context = 'view' ) { |
|
| 1111 | - return $this->get_city( $context ); |
|
| 1247 | + * Get the customer's address. |
|
| 1248 | + * |
|
| 1249 | + * @since 1.0.19 |
|
| 1250 | + * @param string $context View or edit context. |
|
| 1251 | + * @return string |
|
| 1252 | + */ |
|
| 1253 | + public function get_address( $context = 'view' ) { |
|
| 1254 | + return $this->get_prop( 'address', $context ); |
|
| 1112 | 1255 | } |
| 1113 | 1256 | |
| 1114 | 1257 | /** |
| 1115 | - * Get the customer's zip. |
|
| 1116 | - * |
|
| 1117 | - * @since 1.0.19 |
|
| 1118 | - * @param string $context View or edit context. |
|
| 1119 | - * @return string |
|
| 1120 | - */ |
|
| 1121 | - public function get_zip( $context = 'view' ) { |
|
| 1122 | - return $this->get_prop( 'zip', $context ); |
|
| 1258 | + * Alias of self::get_address(). |
|
| 1259 | + * |
|
| 1260 | + * @since 1.0.19 |
|
| 1261 | + * @param string $context View or edit context. |
|
| 1262 | + * @return string |
|
| 1263 | + */ |
|
| 1264 | + public function get_user_address( $context = 'view' ) { |
|
| 1265 | + return $this->get_address( $context ); |
|
| 1123 | 1266 | } |
| 1124 | 1267 | |
| 1125 | 1268 | /** |
| 1126 | - * Alias of self::get_zip(). |
|
| 1127 | - * |
|
| 1128 | - * @since 1.0.19 |
|
| 1129 | - * @param string $context View or edit context. |
|
| 1130 | - * @return string |
|
| 1131 | - */ |
|
| 1132 | - public function get_user_zip( $context = 'view' ) { |
|
| 1133 | - return $this->get_zip( $context ); |
|
| 1269 | + * Alias of self::get_address(). |
|
| 1270 | + * |
|
| 1271 | + * @since 1.0.19 |
|
| 1272 | + * @param string $context View or edit context. |
|
| 1273 | + * @return string |
|
| 1274 | + */ |
|
| 1275 | + public function get_customer_address( $context = 'view' ) { |
|
| 1276 | + return $this->get_address( $context ); |
|
| 1134 | 1277 | } |
| 1135 | 1278 | |
| 1136 | 1279 | /** |
| 1137 | - * Alias of self::get_zip(). |
|
| 1138 | - * |
|
| 1139 | - * @since 1.0.19 |
|
| 1140 | - * @param string $context View or edit context. |
|
| 1141 | - * @return string |
|
| 1142 | - */ |
|
| 1143 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1144 | - return $this->get_zip( $context ); |
|
| 1280 | + * Get whether the customer has viewed the invoice or not. |
|
| 1281 | + * |
|
| 1282 | + * @since 1.0.19 |
|
| 1283 | + * @param string $context View or edit context. |
|
| 1284 | + * @return bool |
|
| 1285 | + */ |
|
| 1286 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1287 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1145 | 1288 | } |
| 1146 | 1289 | |
| 1147 | 1290 | /** |
| 1148 | - * Get the customer's company. |
|
| 1149 | - * |
|
| 1150 | - * @since 1.0.19 |
|
| 1151 | - * @param string $context View or edit context. |
|
| 1152 | - * @return string |
|
| 1153 | - */ |
|
| 1154 | - public function get_company( $context = 'view' ) { |
|
| 1155 | - return $this->get_prop( 'company', $context ); |
|
| 1291 | + * Get other recipients for invoice communications. |
|
| 1292 | + * |
|
| 1293 | + * @since 1.0.19 |
|
| 1294 | + * @param string $context View or edit context. |
|
| 1295 | + * @return bool |
|
| 1296 | + */ |
|
| 1297 | + public function get_email_cc( $context = 'view' ) { |
|
| 1298 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1156 | 1299 | } |
| 1157 | 1300 | |
| 1158 | 1301 | /** |
| 1159 | - * Alias of self::get_company(). |
|
| 1160 | - * |
|
| 1161 | - * @since 1.0.19 |
|
| 1162 | - * @param string $context View or edit context. |
|
| 1163 | - * @return string |
|
| 1164 | - */ |
|
| 1165 | - public function get_user_company( $context = 'view' ) { |
|
| 1166 | - return $this->get_company( $context ); |
|
| 1302 | + * Get invoice template. |
|
| 1303 | + * |
|
| 1304 | + * @since 1.0.19 |
|
| 1305 | + * @param string $context View or edit context. |
|
| 1306 | + * @return bool |
|
| 1307 | + */ |
|
| 1308 | + public function get_template( $context = 'view' ) { |
|
| 1309 | + return $this->get_prop( 'template', $context ); |
|
| 1167 | 1310 | } |
| 1168 | 1311 | |
| 1169 | 1312 | /** |
| 1170 | - * Alias of self::get_company(). |
|
| 1171 | - * |
|
| 1172 | - * @since 1.0.19 |
|
| 1173 | - * @param string $context View or edit context. |
|
| 1174 | - * @return string |
|
| 1175 | - */ |
|
| 1176 | - public function get_customer_company( $context = 'view' ) { |
|
| 1177 | - return $this->get_company( $context ); |
|
| 1313 | + * Get invoice source. |
|
| 1314 | + * |
|
| 1315 | + * @since 1.0.19 |
|
| 1316 | + * @param string $context View or edit context. |
|
| 1317 | + * @return bool |
|
| 1318 | + */ |
|
| 1319 | + public function get_created_via( $context = 'view' ) { |
|
| 1320 | + return $this->get_prop( 'created_via', $context ); |
|
| 1178 | 1321 | } |
| 1179 | 1322 | |
| 1180 | 1323 | /** |
| 1181 | - * Get the customer's vat number. |
|
| 1182 | - * |
|
| 1183 | - * @since 1.0.19 |
|
| 1184 | - * @param string $context View or edit context. |
|
| 1185 | - * @return string |
|
| 1186 | - */ |
|
| 1187 | - public function get_vat_number( $context = 'view' ) { |
|
| 1188 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1324 | + * Get whether the customer has confirmed their address. |
|
| 1325 | + * |
|
| 1326 | + * @since 1.0.19 |
|
| 1327 | + * @param string $context View or edit context. |
|
| 1328 | + * @return bool |
|
| 1329 | + */ |
|
| 1330 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1331 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1189 | 1332 | } |
| 1190 | 1333 | |
| 1191 | 1334 | /** |
| 1192 | - * Alias of self::get_vat_number(). |
|
| 1193 | - * |
|
| 1194 | - * @since 1.0.19 |
|
| 1195 | - * @param string $context View or edit context. |
|
| 1196 | - * @return string |
|
| 1197 | - */ |
|
| 1198 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1199 | - return $this->get_vat_number( $context ); |
|
| 1335 | + * Alias of self::get_address_confirmed(). |
|
| 1336 | + * |
|
| 1337 | + * @since 1.0.19 |
|
| 1338 | + * @param string $context View or edit context. |
|
| 1339 | + * @return bool |
|
| 1340 | + */ |
|
| 1341 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1342 | + return $this->get_address_confirmed( $context ); |
|
| 1200 | 1343 | } |
| 1201 | 1344 | |
| 1202 | 1345 | /** |
| 1203 | - * Alias of self::get_vat_number(). |
|
| 1204 | - * |
|
| 1205 | - * @since 1.0.19 |
|
| 1206 | - * @param string $context View or edit context. |
|
| 1207 | - * @return string |
|
| 1208 | - */ |
|
| 1209 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1210 | - return $this->get_vat_number( $context ); |
|
| 1346 | + * Alias of self::get_address(). |
|
| 1347 | + * |
|
| 1348 | + * @since 1.0.19 |
|
| 1349 | + * @param string $context View or edit context. |
|
| 1350 | + * @return bool |
|
| 1351 | + */ |
|
| 1352 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1353 | + return $this->get_address_confirmed( $context ); |
|
| 1211 | 1354 | } |
| 1212 | 1355 | |
| 1213 | 1356 | /** |
| 1214 | - * Get the customer's vat rate. |
|
| 1215 | - * |
|
| 1216 | - * @since 1.0.19 |
|
| 1217 | - * @param string $context View or edit context. |
|
| 1218 | - * @return string |
|
| 1219 | - */ |
|
| 1220 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1221 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1222 | - } |
|
| 1223 | - |
|
| 1224 | - /** |
|
| 1225 | - * Alias of self::get_vat_rate(). |
|
| 1226 | - * |
|
| 1227 | - * @since 1.0.19 |
|
| 1228 | - * @param string $context View or edit context. |
|
| 1229 | - * @return string |
|
| 1230 | - */ |
|
| 1231 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1232 | - return $this->get_vat_rate( $context ); |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * Alias of self::get_vat_rate(). |
|
| 1237 | - * |
|
| 1238 | - * @since 1.0.19 |
|
| 1239 | - * @param string $context View or edit context. |
|
| 1240 | - * @return string |
|
| 1241 | - */ |
|
| 1242 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1243 | - return $this->get_vat_rate( $context ); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - /** |
|
| 1247 | - * Get the customer's address. |
|
| 1248 | - * |
|
| 1249 | - * @since 1.0.19 |
|
| 1250 | - * @param string $context View or edit context. |
|
| 1251 | - * @return string |
|
| 1252 | - */ |
|
| 1253 | - public function get_address( $context = 'view' ) { |
|
| 1254 | - return $this->get_prop( 'address', $context ); |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - /** |
|
| 1258 | - * Alias of self::get_address(). |
|
| 1259 | - * |
|
| 1260 | - * @since 1.0.19 |
|
| 1261 | - * @param string $context View or edit context. |
|
| 1262 | - * @return string |
|
| 1263 | - */ |
|
| 1264 | - public function get_user_address( $context = 'view' ) { |
|
| 1265 | - return $this->get_address( $context ); |
|
| 1266 | - } |
|
| 1267 | - |
|
| 1268 | - /** |
|
| 1269 | - * Alias of self::get_address(). |
|
| 1270 | - * |
|
| 1271 | - * @since 1.0.19 |
|
| 1272 | - * @param string $context View or edit context. |
|
| 1273 | - * @return string |
|
| 1274 | - */ |
|
| 1275 | - public function get_customer_address( $context = 'view' ) { |
|
| 1276 | - return $this->get_address( $context ); |
|
| 1277 | - } |
|
| 1278 | - |
|
| 1279 | - /** |
|
| 1280 | - * Get whether the customer has viewed the invoice or not. |
|
| 1281 | - * |
|
| 1282 | - * @since 1.0.19 |
|
| 1283 | - * @param string $context View or edit context. |
|
| 1284 | - * @return bool |
|
| 1285 | - */ |
|
| 1286 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1287 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1288 | - } |
|
| 1289 | - |
|
| 1290 | - /** |
|
| 1291 | - * Get other recipients for invoice communications. |
|
| 1292 | - * |
|
| 1293 | - * @since 1.0.19 |
|
| 1294 | - * @param string $context View or edit context. |
|
| 1295 | - * @return bool |
|
| 1296 | - */ |
|
| 1297 | - public function get_email_cc( $context = 'view' ) { |
|
| 1298 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1299 | - } |
|
| 1300 | - |
|
| 1301 | - /** |
|
| 1302 | - * Get invoice template. |
|
| 1303 | - * |
|
| 1304 | - * @since 1.0.19 |
|
| 1305 | - * @param string $context View or edit context. |
|
| 1306 | - * @return bool |
|
| 1307 | - */ |
|
| 1308 | - public function get_template( $context = 'view' ) { |
|
| 1309 | - return $this->get_prop( 'template', $context ); |
|
| 1310 | - } |
|
| 1311 | - |
|
| 1312 | - /** |
|
| 1313 | - * Get invoice source. |
|
| 1314 | - * |
|
| 1315 | - * @since 1.0.19 |
|
| 1316 | - * @param string $context View or edit context. |
|
| 1317 | - * @return bool |
|
| 1318 | - */ |
|
| 1319 | - public function get_created_via( $context = 'view' ) { |
|
| 1320 | - return $this->get_prop( 'created_via', $context ); |
|
| 1321 | - } |
|
| 1322 | - |
|
| 1323 | - /** |
|
| 1324 | - * Get whether the customer has confirmed their address. |
|
| 1325 | - * |
|
| 1326 | - * @since 1.0.19 |
|
| 1327 | - * @param string $context View or edit context. |
|
| 1328 | - * @return bool |
|
| 1329 | - */ |
|
| 1330 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1331 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - /** |
|
| 1335 | - * Alias of self::get_address_confirmed(). |
|
| 1336 | - * |
|
| 1337 | - * @since 1.0.19 |
|
| 1338 | - * @param string $context View or edit context. |
|
| 1339 | - * @return bool |
|
| 1340 | - */ |
|
| 1341 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1342 | - return $this->get_address_confirmed( $context ); |
|
| 1343 | - } |
|
| 1344 | - |
|
| 1345 | - /** |
|
| 1346 | - * Alias of self::get_address(). |
|
| 1347 | - * |
|
| 1348 | - * @since 1.0.19 |
|
| 1349 | - * @param string $context View or edit context. |
|
| 1350 | - * @return bool |
|
| 1351 | - */ |
|
| 1352 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1353 | - return $this->get_address_confirmed( $context ); |
|
| 1354 | - } |
|
| 1355 | - |
|
| 1356 | - /** |
|
| 1357 | - * Get the invoice subtotal. |
|
| 1358 | - * |
|
| 1359 | - * @since 1.0.19 |
|
| 1360 | - * @param string $context View or edit context. |
|
| 1361 | - * @return float |
|
| 1362 | - */ |
|
| 1363 | - public function get_subtotal( $context = 'view' ) { |
|
| 1357 | + * Get the invoice subtotal. |
|
| 1358 | + * |
|
| 1359 | + * @since 1.0.19 |
|
| 1360 | + * @param string $context View or edit context. |
|
| 1361 | + * @return float |
|
| 1362 | + */ |
|
| 1363 | + public function get_subtotal( $context = 'view' ) { |
|
| 1364 | 1364 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1365 | 1365 | |
| 1366 | 1366 | // Backwards compatibility. |
@@ -1372,192 +1372,192 @@ discard block |
||
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | /** |
| 1375 | - * Get the invoice discount total. |
|
| 1376 | - * |
|
| 1377 | - * @since 1.0.19 |
|
| 1378 | - * @param string $context View or edit context. |
|
| 1379 | - * @return float |
|
| 1380 | - */ |
|
| 1381 | - public function get_total_discount( $context = 'view' ) { |
|
| 1382 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
| 1375 | + * Get the invoice discount total. |
|
| 1376 | + * |
|
| 1377 | + * @since 1.0.19 |
|
| 1378 | + * @param string $context View or edit context. |
|
| 1379 | + * @return float |
|
| 1380 | + */ |
|
| 1381 | + public function get_total_discount( $context = 'view' ) { |
|
| 1382 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | 1385 | /** |
| 1386 | - * Get the invoice tax total. |
|
| 1387 | - * |
|
| 1388 | - * @since 1.0.19 |
|
| 1389 | - * @param string $context View or edit context. |
|
| 1390 | - * @return float |
|
| 1391 | - */ |
|
| 1392 | - public function get_total_tax( $context = 'view' ) { |
|
| 1393 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
| 1394 | - } |
|
| 1386 | + * Get the invoice tax total. |
|
| 1387 | + * |
|
| 1388 | + * @since 1.0.19 |
|
| 1389 | + * @param string $context View or edit context. |
|
| 1390 | + * @return float |
|
| 1391 | + */ |
|
| 1392 | + public function get_total_tax( $context = 'view' ) { |
|
| 1393 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
| 1394 | + } |
|
| 1395 | 1395 | |
| 1396 | - /** |
|
| 1397 | - * @deprecated |
|
| 1398 | - */ |
|
| 1399 | - public function get_final_tax( $currency = false ) { |
|
| 1400 | - $tax = $this->get_total_tax(); |
|
| 1396 | + /** |
|
| 1397 | + * @deprecated |
|
| 1398 | + */ |
|
| 1399 | + public function get_final_tax( $currency = false ) { |
|
| 1400 | + $tax = $this->get_total_tax(); |
|
| 1401 | 1401 | |
| 1402 | 1402 | if ( $currency ) { |
| 1403 | - return wpinv_price( $tax, $this->get_currency() ); |
|
| 1403 | + return wpinv_price( $tax, $this->get_currency() ); |
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | return $tax; |
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | 1409 | /** |
| 1410 | - * Get the invoice fees total. |
|
| 1411 | - * |
|
| 1412 | - * @since 1.0.19 |
|
| 1413 | - * @param string $context View or edit context. |
|
| 1414 | - * @return float |
|
| 1415 | - */ |
|
| 1416 | - public function get_total_fees( $context = 'view' ) { |
|
| 1417 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
| 1410 | + * Get the invoice fees total. |
|
| 1411 | + * |
|
| 1412 | + * @since 1.0.19 |
|
| 1413 | + * @param string $context View or edit context. |
|
| 1414 | + * @return float |
|
| 1415 | + */ |
|
| 1416 | + public function get_total_fees( $context = 'view' ) { |
|
| 1417 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
| 1418 | + } |
|
| 1419 | + |
|
| 1420 | + /** |
|
| 1421 | + * Alias for self::get_total_fees(). |
|
| 1422 | + * |
|
| 1423 | + * @since 1.0.19 |
|
| 1424 | + * @param string $context View or edit context. |
|
| 1425 | + * @return float |
|
| 1426 | + */ |
|
| 1427 | + public function get_fees_total( $context = 'view' ) { |
|
| 1428 | + return $this->get_total_fees( $context ); |
|
| 1418 | 1429 | } |
| 1419 | 1430 | |
| 1420 | 1431 | /** |
| 1421 | - * Alias for self::get_total_fees(). |
|
| 1422 | - * |
|
| 1423 | - * @since 1.0.19 |
|
| 1424 | - * @param string $context View or edit context. |
|
| 1425 | - * @return float |
|
| 1426 | - */ |
|
| 1427 | - public function get_fees_total( $context = 'view' ) { |
|
| 1428 | - return $this->get_total_fees( $context ); |
|
| 1432 | + * Get the invoice total. |
|
| 1433 | + * |
|
| 1434 | + * @since 1.0.19 |
|
| 1435 | + * @return float |
|
| 1436 | + */ |
|
| 1437 | + public function get_total( $context = 'view' ) { |
|
| 1438 | + return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) ); |
|
| 1429 | 1439 | } |
| 1430 | 1440 | |
| 1431 | 1441 | /** |
| 1432 | - * Get the invoice total. |
|
| 1433 | - * |
|
| 1434 | - * @since 1.0.19 |
|
| 1442 | + * Retrieves the non-recurring total of items. |
|
| 1443 | + * |
|
| 1444 | + * @since 2.3.0 |
|
| 1435 | 1445 | * @return float |
| 1436 | - */ |
|
| 1437 | - public function get_total( $context = 'view' ) { |
|
| 1438 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) ); |
|
| 1439 | - } |
|
| 1440 | - |
|
| 1441 | - /** |
|
| 1442 | - * Retrieves the non-recurring total of items. |
|
| 1443 | - * |
|
| 1444 | - * @since 2.3.0 |
|
| 1445 | - * @return float |
|
| 1446 | - */ |
|
| 1447 | - public function get_non_recurring_total() { |
|
| 1448 | - |
|
| 1449 | - $subtotal = 0; |
|
| 1450 | - foreach ( $this->get_items() as $item ) { |
|
| 1451 | - if ( ! $item->is_recurring() ) { |
|
| 1452 | - $subtotal += $item->get_sub_total(); |
|
| 1453 | - } |
|
| 1454 | - } |
|
| 1455 | - |
|
| 1456 | - foreach ( $this->get_fees() as $fee ) { |
|
| 1457 | - if ( empty( $fee['recurring_fee'] ) ) { |
|
| 1458 | - $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
| 1459 | - } |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
| 1446 | + */ |
|
| 1447 | + public function get_non_recurring_total() { |
|
| 1448 | + |
|
| 1449 | + $subtotal = 0; |
|
| 1450 | + foreach ( $this->get_items() as $item ) { |
|
| 1451 | + if ( ! $item->is_recurring() ) { |
|
| 1452 | + $subtotal += $item->get_sub_total(); |
|
| 1453 | + } |
|
| 1454 | + } |
|
| 1455 | + |
|
| 1456 | + foreach ( $this->get_fees() as $fee ) { |
|
| 1457 | + if ( empty( $fee['recurring_fee'] ) ) { |
|
| 1458 | + $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
| 1459 | + } |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
| 1463 | 1463 | return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this ); |
| 1464 | 1464 | |
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | - /** |
|
| 1468 | - * Get the invoice totals. |
|
| 1469 | - * |
|
| 1470 | - * @since 1.0.19 |
|
| 1467 | + /** |
|
| 1468 | + * Get the invoice totals. |
|
| 1469 | + * |
|
| 1470 | + * @since 1.0.19 |
|
| 1471 | 1471 | * @return array |
| 1472 | - */ |
|
| 1473 | - public function get_totals() { |
|
| 1474 | - return $this->totals; |
|
| 1472 | + */ |
|
| 1473 | + public function get_totals() { |
|
| 1474 | + return $this->totals; |
|
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | 1477 | /** |
| 1478 | - * Get the initial invoice total. |
|
| 1479 | - * |
|
| 1480 | - * @since 1.0.19 |
|
| 1478 | + * Get the initial invoice total. |
|
| 1479 | + * |
|
| 1480 | + * @since 1.0.19 |
|
| 1481 | 1481 | * @param string $context View or edit context. |
| 1482 | 1482 | * @return float |
| 1483 | - */ |
|
| 1483 | + */ |
|
| 1484 | 1484 | public function get_initial_total() { |
| 1485 | 1485 | |
| 1486 | - if ( empty( $this->totals ) ) { |
|
| 1487 | - $this->recalculate_total(); |
|
| 1488 | - } |
|
| 1486 | + if ( empty( $this->totals ) ) { |
|
| 1487 | + $this->recalculate_total(); |
|
| 1488 | + } |
|
| 1489 | 1489 | |
| 1490 | - $tax = $this->totals['tax']['initial']; |
|
| 1491 | - $fee = $this->totals['fee']['initial']; |
|
| 1492 | - $discount = $this->totals['discount']['initial']; |
|
| 1493 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1494 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1490 | + $tax = $this->totals['tax']['initial']; |
|
| 1491 | + $fee = $this->totals['fee']['initial']; |
|
| 1492 | + $discount = $this->totals['discount']['initial']; |
|
| 1493 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1494 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1495 | 1495 | |
| 1496 | - if ( 0 > $total ) { |
|
| 1497 | - $total = 0; |
|
| 1498 | - } |
|
| 1496 | + if ( 0 > $total ) { |
|
| 1497 | + $total = 0; |
|
| 1498 | + } |
|
| 1499 | 1499 | |
| 1500 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1500 | + $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1501 | 1501 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1502 | - } |
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | - /** |
|
| 1505 | - * Get the recurring invoice total. |
|
| 1506 | - * |
|
| 1507 | - * @since 1.0.19 |
|
| 1504 | + /** |
|
| 1505 | + * Get the recurring invoice total. |
|
| 1506 | + * |
|
| 1507 | + * @since 1.0.19 |
|
| 1508 | 1508 | * @param string $context View or edit context. |
| 1509 | 1509 | * @return float |
| 1510 | - */ |
|
| 1510 | + */ |
|
| 1511 | 1511 | public function get_recurring_total() { |
| 1512 | 1512 | |
| 1513 | - if ( empty( $this->totals ) ) { |
|
| 1514 | - $this->recalculate_total(); |
|
| 1515 | - } |
|
| 1513 | + if ( empty( $this->totals ) ) { |
|
| 1514 | + $this->recalculate_total(); |
|
| 1515 | + } |
|
| 1516 | 1516 | |
| 1517 | - $tax = $this->totals['tax']['recurring']; |
|
| 1518 | - $fee = $this->totals['fee']['recurring']; |
|
| 1519 | - $discount = $this->totals['discount']['recurring']; |
|
| 1520 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1521 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1517 | + $tax = $this->totals['tax']['recurring']; |
|
| 1518 | + $fee = $this->totals['fee']['recurring']; |
|
| 1519 | + $discount = $this->totals['discount']['recurring']; |
|
| 1520 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1521 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1522 | 1522 | |
| 1523 | - if ( 0 > $total ) { |
|
| 1524 | - $total = 0; |
|
| 1525 | - } |
|
| 1523 | + if ( 0 > $total ) { |
|
| 1524 | + $total = 0; |
|
| 1525 | + } |
|
| 1526 | 1526 | |
| 1527 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1527 | + $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1528 | 1528 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1529 | - } |
|
| 1529 | + } |
|
| 1530 | 1530 | |
| 1531 | - /** |
|
| 1532 | - * Returns recurring payment details. |
|
| 1533 | - * |
|
| 1534 | - * @since 1.0.19 |
|
| 1531 | + /** |
|
| 1532 | + * Returns recurring payment details. |
|
| 1533 | + * |
|
| 1534 | + * @since 1.0.19 |
|
| 1535 | 1535 | * @param string $field Optionally provide a field to return. |
| 1536 | - * @param string $currency Whether to include the currency. |
|
| 1536 | + * @param string $currency Whether to include the currency. |
|
| 1537 | 1537 | * @return float|string |
| 1538 | - */ |
|
| 1538 | + */ |
|
| 1539 | 1539 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1540 | 1540 | |
| 1541 | - // Maybe recalculate totals. |
|
| 1542 | - if ( empty( $this->totals ) ) { |
|
| 1543 | - $this->recalculate_total(); |
|
| 1544 | - } |
|
| 1541 | + // Maybe recalculate totals. |
|
| 1542 | + if ( empty( $this->totals ) ) { |
|
| 1543 | + $this->recalculate_total(); |
|
| 1544 | + } |
|
| 1545 | 1545 | |
| 1546 | - // Prepare recurring totals. |
|
| 1546 | + // Prepare recurring totals. |
|
| 1547 | 1547 | $data = apply_filters( |
| 1548 | - 'wpinv_get_invoice_recurring_details', |
|
| 1549 | - array( |
|
| 1550 | - 'cart_details' => $this->get_cart_details(), |
|
| 1551 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1552 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1553 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1554 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1555 | - 'total' => $this->get_recurring_total(), |
|
| 1556 | - ), |
|
| 1557 | - $this, |
|
| 1558 | - $field, |
|
| 1559 | - $currency |
|
| 1560 | - ); |
|
| 1548 | + 'wpinv_get_invoice_recurring_details', |
|
| 1549 | + array( |
|
| 1550 | + 'cart_details' => $this->get_cart_details(), |
|
| 1551 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1552 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1553 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1554 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1555 | + 'total' => $this->get_recurring_total(), |
|
| 1556 | + ), |
|
| 1557 | + $this, |
|
| 1558 | + $field, |
|
| 1559 | + $currency |
|
| 1560 | + ); |
|
| 1561 | 1561 | |
| 1562 | 1562 | if ( isset( $data[$field] ) ) { |
| 1563 | 1563 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1567,166 +1567,166 @@ discard block |
||
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | 1569 | /** |
| 1570 | - * Get the invoice fees. |
|
| 1571 | - * |
|
| 1572 | - * @since 1.0.19 |
|
| 1573 | - * @param string $context View or edit context. |
|
| 1574 | - * @return array |
|
| 1575 | - */ |
|
| 1576 | - public function get_fees( $context = 'view' ) { |
|
| 1577 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1570 | + * Get the invoice fees. |
|
| 1571 | + * |
|
| 1572 | + * @since 1.0.19 |
|
| 1573 | + * @param string $context View or edit context. |
|
| 1574 | + * @return array |
|
| 1575 | + */ |
|
| 1576 | + public function get_fees( $context = 'view' ) { |
|
| 1577 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | 1580 | /** |
| 1581 | - * Get the invoice discounts. |
|
| 1582 | - * |
|
| 1583 | - * @since 1.0.19 |
|
| 1584 | - * @param string $context View or edit context. |
|
| 1585 | - * @return array |
|
| 1586 | - */ |
|
| 1587 | - public function get_discounts( $context = 'view' ) { |
|
| 1588 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1581 | + * Get the invoice discounts. |
|
| 1582 | + * |
|
| 1583 | + * @since 1.0.19 |
|
| 1584 | + * @param string $context View or edit context. |
|
| 1585 | + * @return array |
|
| 1586 | + */ |
|
| 1587 | + public function get_discounts( $context = 'view' ) { |
|
| 1588 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | /** |
| 1592 | - * Get the invoice taxes. |
|
| 1593 | - * |
|
| 1594 | - * @since 1.0.19 |
|
| 1595 | - * @param string $context View or edit context. |
|
| 1596 | - * @return array |
|
| 1597 | - */ |
|
| 1598 | - public function get_taxes( $context = 'view' ) { |
|
| 1599 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1592 | + * Get the invoice taxes. |
|
| 1593 | + * |
|
| 1594 | + * @since 1.0.19 |
|
| 1595 | + * @param string $context View or edit context. |
|
| 1596 | + * @return array |
|
| 1597 | + */ |
|
| 1598 | + public function get_taxes( $context = 'view' ) { |
|
| 1599 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | 1602 | /** |
| 1603 | - * Get the invoice items. |
|
| 1604 | - * |
|
| 1605 | - * @since 1.0.19 |
|
| 1606 | - * @param string $context View or edit context. |
|
| 1607 | - * @return GetPaid_Form_Item[] |
|
| 1608 | - */ |
|
| 1609 | - public function get_items( $context = 'view' ) { |
|
| 1603 | + * Get the invoice items. |
|
| 1604 | + * |
|
| 1605 | + * @since 1.0.19 |
|
| 1606 | + * @param string $context View or edit context. |
|
| 1607 | + * @return GetPaid_Form_Item[] |
|
| 1608 | + */ |
|
| 1609 | + public function get_items( $context = 'view' ) { |
|
| 1610 | 1610 | return $this->get_prop( 'items', $context ); |
| 1611 | - } |
|
| 1611 | + } |
|
| 1612 | 1612 | |
| 1613 | - /** |
|
| 1614 | - * Get the invoice item ids. |
|
| 1615 | - * |
|
| 1616 | - * @since 1.0.19 |
|
| 1617 | - * @return string |
|
| 1618 | - */ |
|
| 1619 | - public function get_item_ids() { |
|
| 1620 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
| 1613 | + /** |
|
| 1614 | + * Get the invoice item ids. |
|
| 1615 | + * |
|
| 1616 | + * @since 1.0.19 |
|
| 1617 | + * @return string |
|
| 1618 | + */ |
|
| 1619 | + public function get_item_ids() { |
|
| 1620 | + return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | /** |
| 1624 | - * Get the invoice's payment form. |
|
| 1625 | - * |
|
| 1626 | - * @since 1.0.19 |
|
| 1627 | - * @param string $context View or edit context. |
|
| 1628 | - * @return int |
|
| 1629 | - */ |
|
| 1630 | - public function get_payment_form( $context = 'view' ) { |
|
| 1631 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1624 | + * Get the invoice's payment form. |
|
| 1625 | + * |
|
| 1626 | + * @since 1.0.19 |
|
| 1627 | + * @param string $context View or edit context. |
|
| 1628 | + * @return int |
|
| 1629 | + */ |
|
| 1630 | + public function get_payment_form( $context = 'view' ) { |
|
| 1631 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | /** |
| 1635 | - * Get the invoice's submission id. |
|
| 1636 | - * |
|
| 1637 | - * @since 1.0.19 |
|
| 1638 | - * @param string $context View or edit context. |
|
| 1639 | - * @return string |
|
| 1640 | - */ |
|
| 1641 | - public function get_submission_id( $context = 'view' ) { |
|
| 1642 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1635 | + * Get the invoice's submission id. |
|
| 1636 | + * |
|
| 1637 | + * @since 1.0.19 |
|
| 1638 | + * @param string $context View or edit context. |
|
| 1639 | + * @return string |
|
| 1640 | + */ |
|
| 1641 | + public function get_submission_id( $context = 'view' ) { |
|
| 1642 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | 1645 | /** |
| 1646 | - * Get the invoice's discount code. |
|
| 1647 | - * |
|
| 1648 | - * @since 1.0.19 |
|
| 1649 | - * @param string $context View or edit context. |
|
| 1650 | - * @return string |
|
| 1651 | - */ |
|
| 1652 | - public function get_discount_code( $context = 'view' ) { |
|
| 1653 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1646 | + * Get the invoice's discount code. |
|
| 1647 | + * |
|
| 1648 | + * @since 1.0.19 |
|
| 1649 | + * @param string $context View or edit context. |
|
| 1650 | + * @return string |
|
| 1651 | + */ |
|
| 1652 | + public function get_discount_code( $context = 'view' ) { |
|
| 1653 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | /** |
| 1657 | - * Get the invoice's gateway. |
|
| 1658 | - * |
|
| 1659 | - * @since 1.0.19 |
|
| 1660 | - * @param string $context View or edit context. |
|
| 1661 | - * @return string |
|
| 1662 | - */ |
|
| 1663 | - public function get_gateway( $context = 'view' ) { |
|
| 1664 | - return $this->get_prop( 'gateway', $context ); |
|
| 1657 | + * Get the invoice's gateway. |
|
| 1658 | + * |
|
| 1659 | + * @since 1.0.19 |
|
| 1660 | + * @param string $context View or edit context. |
|
| 1661 | + * @return string |
|
| 1662 | + */ |
|
| 1663 | + public function get_gateway( $context = 'view' ) { |
|
| 1664 | + return $this->get_prop( 'gateway', $context ); |
|
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | /** |
| 1668 | - * Get the invoice's gateway display title. |
|
| 1669 | - * |
|
| 1670 | - * @since 1.0.19 |
|
| 1671 | - * @return string |
|
| 1672 | - */ |
|
| 1668 | + * Get the invoice's gateway display title. |
|
| 1669 | + * |
|
| 1670 | + * @since 1.0.19 |
|
| 1671 | + * @return string |
|
| 1672 | + */ |
|
| 1673 | 1673 | public function get_gateway_title() { |
| 1674 | 1674 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1675 | 1675 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | 1678 | /** |
| 1679 | - * Get the invoice's transaction id. |
|
| 1680 | - * |
|
| 1681 | - * @since 1.0.19 |
|
| 1682 | - * @param string $context View or edit context. |
|
| 1683 | - * @return string |
|
| 1684 | - */ |
|
| 1685 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1686 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1679 | + * Get the invoice's transaction id. |
|
| 1680 | + * |
|
| 1681 | + * @since 1.0.19 |
|
| 1682 | + * @param string $context View or edit context. |
|
| 1683 | + * @return string |
|
| 1684 | + */ |
|
| 1685 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1686 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | 1689 | /** |
| 1690 | - * Get the invoice's currency. |
|
| 1691 | - * |
|
| 1692 | - * @since 1.0.19 |
|
| 1693 | - * @param string $context View or edit context. |
|
| 1694 | - * @return string |
|
| 1695 | - */ |
|
| 1696 | - public function get_currency( $context = 'view' ) { |
|
| 1690 | + * Get the invoice's currency. |
|
| 1691 | + * |
|
| 1692 | + * @since 1.0.19 |
|
| 1693 | + * @param string $context View or edit context. |
|
| 1694 | + * @return string |
|
| 1695 | + */ |
|
| 1696 | + public function get_currency( $context = 'view' ) { |
|
| 1697 | 1697 | $currency = $this->get_prop( 'currency', $context ); |
| 1698 | 1698 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | 1701 | /** |
| 1702 | - * Checks if we are charging taxes for this invoice. |
|
| 1703 | - * |
|
| 1704 | - * @since 1.0.19 |
|
| 1705 | - * @param string $context View or edit context. |
|
| 1706 | - * @return bool |
|
| 1707 | - */ |
|
| 1708 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1702 | + * Checks if we are charging taxes for this invoice. |
|
| 1703 | + * |
|
| 1704 | + * @since 1.0.19 |
|
| 1705 | + * @param string $context View or edit context. |
|
| 1706 | + * @return bool |
|
| 1707 | + */ |
|
| 1708 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1709 | 1709 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | /** |
| 1713 | - * Retrieves the subscription id for an invoice. |
|
| 1714 | - * |
|
| 1715 | - * @since 1.0.19 |
|
| 1716 | - * @param string $context View or edit context. |
|
| 1717 | - * @return int |
|
| 1718 | - */ |
|
| 1713 | + * Retrieves the subscription id for an invoice. |
|
| 1714 | + * |
|
| 1715 | + * @since 1.0.19 |
|
| 1716 | + * @param string $context View or edit context. |
|
| 1717 | + * @return int |
|
| 1718 | + */ |
|
| 1719 | 1719 | public function get_subscription_id( $context = 'view' ) { |
| 1720 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1721 | - } |
|
| 1722 | - |
|
| 1723 | - /** |
|
| 1724 | - * Retrieves the remote subscription id for an invoice. |
|
| 1725 | - * |
|
| 1726 | - * @since 1.0.19 |
|
| 1727 | - * @param string $context View or edit context. |
|
| 1728 | - * @return int |
|
| 1729 | - */ |
|
| 1720 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1721 | + } |
|
| 1722 | + |
|
| 1723 | + /** |
|
| 1724 | + * Retrieves the remote subscription id for an invoice. |
|
| 1725 | + * |
|
| 1726 | + * @since 1.0.19 |
|
| 1727 | + * @param string $context View or edit context. |
|
| 1728 | + * @return int |
|
| 1729 | + */ |
|
| 1730 | 1730 | public function get_remote_subscription_id( $context = 'view' ) { |
| 1731 | 1731 | $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
| 1732 | 1732 | |
@@ -1739,12 +1739,12 @@ discard block |
||
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | /** |
| 1742 | - * Retrieves the payment meta for an invoice. |
|
| 1743 | - * |
|
| 1744 | - * @since 1.0.19 |
|
| 1745 | - * @param string $context View or edit context. |
|
| 1746 | - * @return array |
|
| 1747 | - */ |
|
| 1742 | + * Retrieves the payment meta for an invoice. |
|
| 1743 | + * |
|
| 1744 | + * @since 1.0.19 |
|
| 1745 | + * @param string $context View or edit context. |
|
| 1746 | + * @return array |
|
| 1747 | + */ |
|
| 1748 | 1748 | public function get_payment_meta( $context = 'view' ) { |
| 1749 | 1749 | |
| 1750 | 1750 | return array( |
@@ -1764,31 +1764,31 @@ discard block |
||
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | 1766 | /** |
| 1767 | - * Retrieves the cart details for an invoice. |
|
| 1768 | - * |
|
| 1769 | - * @since 1.0.19 |
|
| 1770 | - * @return array |
|
| 1771 | - */ |
|
| 1767 | + * Retrieves the cart details for an invoice. |
|
| 1768 | + * |
|
| 1769 | + * @since 1.0.19 |
|
| 1770 | + * @return array |
|
| 1771 | + */ |
|
| 1772 | 1772 | public function get_cart_details() { |
| 1773 | 1773 | $items = $this->get_items(); |
| 1774 | 1774 | $cart_details = array(); |
| 1775 | 1775 | |
| 1776 | 1776 | foreach ( $items as $item ) { |
| 1777 | - $item->invoice_id = $this->get_id(); |
|
| 1777 | + $item->invoice_id = $this->get_id(); |
|
| 1778 | 1778 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1779 | 1779 | } |
| 1780 | 1780 | |
| 1781 | 1781 | return $cart_details; |
| 1782 | - } |
|
| 1782 | + } |
|
| 1783 | 1783 | |
| 1784 | - /** |
|
| 1785 | - * Retrieves the recurring item. |
|
| 1786 | - * |
|
| 1787 | - * @return null|GetPaid_Form_Item|int |
|
| 1788 | - */ |
|
| 1789 | - public function get_recurring( $object = false ) { |
|
| 1784 | + /** |
|
| 1785 | + * Retrieves the recurring item. |
|
| 1786 | + * |
|
| 1787 | + * @return null|GetPaid_Form_Item|int |
|
| 1788 | + */ |
|
| 1789 | + public function get_recurring( $object = false ) { |
|
| 1790 | 1790 | |
| 1791 | - // Are we returning an object? |
|
| 1791 | + // Are we returning an object? |
|
| 1792 | 1792 | if ( $object ) { |
| 1793 | 1793 | return $this->get_item( $this->recurring_item ); |
| 1794 | 1794 | } |
@@ -1796,114 +1796,114 @@ discard block |
||
| 1796 | 1796 | return $this->recurring_item; |
| 1797 | 1797 | } |
| 1798 | 1798 | |
| 1799 | - /** |
|
| 1800 | - * Retrieves the subscription name. |
|
| 1801 | - * |
|
| 1802 | - * @since 1.0.19 |
|
| 1803 | - * @return string |
|
| 1804 | - */ |
|
| 1805 | - public function get_subscription_name() { |
|
| 1799 | + /** |
|
| 1800 | + * Retrieves the subscription name. |
|
| 1801 | + * |
|
| 1802 | + * @since 1.0.19 |
|
| 1803 | + * @return string |
|
| 1804 | + */ |
|
| 1805 | + public function get_subscription_name() { |
|
| 1806 | 1806 | |
| 1807 | - // Retrieve the recurring name |
|
| 1807 | + // Retrieve the recurring name |
|
| 1808 | 1808 | $item = $this->get_recurring( true ); |
| 1809 | 1809 | |
| 1810 | - // Abort if it does not exist. |
|
| 1810 | + // Abort if it does not exist. |
|
| 1811 | 1811 | if ( empty( $item ) ) { |
| 1812 | 1812 | return ''; |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | - // Return the item name. |
|
| 1815 | + // Return the item name. |
|
| 1816 | 1816 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1817 | - } |
|
| 1818 | - |
|
| 1819 | - /** |
|
| 1820 | - * Retrieves the view url. |
|
| 1821 | - * |
|
| 1822 | - * @since 1.0.19 |
|
| 1823 | - * @return string |
|
| 1824 | - */ |
|
| 1825 | - public function get_view_url() { |
|
| 1817 | + } |
|
| 1818 | + |
|
| 1819 | + /** |
|
| 1820 | + * Retrieves the view url. |
|
| 1821 | + * |
|
| 1822 | + * @since 1.0.19 |
|
| 1823 | + * @return string |
|
| 1824 | + */ |
|
| 1825 | + public function get_view_url() { |
|
| 1826 | 1826 | $invoice_url = get_permalink( $this->get_id() ); |
| 1827 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1827 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1828 | 1828 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1829 | - } |
|
| 1829 | + } |
|
| 1830 | 1830 | |
| 1831 | - /** |
|
| 1832 | - * Retrieves the payment url. |
|
| 1833 | - * |
|
| 1834 | - * @since 1.0.19 |
|
| 1835 | - * @return string |
|
| 1836 | - */ |
|
| 1837 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1831 | + /** |
|
| 1832 | + * Retrieves the payment url. |
|
| 1833 | + * |
|
| 1834 | + * @since 1.0.19 |
|
| 1835 | + * @return string |
|
| 1836 | + */ |
|
| 1837 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1838 | 1838 | |
| 1839 | - // Retrieve the checkout url. |
|
| 1839 | + // Retrieve the checkout url. |
|
| 1840 | 1840 | $pay_url = wpinv_get_checkout_uri(); |
| 1841 | 1841 | |
| 1842 | - // Maybe force ssl. |
|
| 1842 | + // Maybe force ssl. |
|
| 1843 | 1843 | if ( is_ssl() ) { |
| 1844 | 1844 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | - // Add the invoice key. |
|
| 1848 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1847 | + // Add the invoice key. |
|
| 1848 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1849 | 1849 | |
| 1850 | - // (Maybe?) add a secret |
|
| 1850 | + // (Maybe?) add a secret |
|
| 1851 | 1851 | if ( $secret ) { |
| 1852 | 1852 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | 1855 | return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
| 1856 | - } |
|
| 1856 | + } |
|
| 1857 | 1857 | |
| 1858 | - /** |
|
| 1859 | - * Retrieves the receipt url. |
|
| 1860 | - * |
|
| 1861 | - * @since 1.0.19 |
|
| 1862 | - * @return string |
|
| 1863 | - */ |
|
| 1864 | - public function get_receipt_url() { |
|
| 1865 | - |
|
| 1866 | - // Retrieve the checkout url. |
|
| 1858 | + /** |
|
| 1859 | + * Retrieves the receipt url. |
|
| 1860 | + * |
|
| 1861 | + * @since 1.0.19 |
|
| 1862 | + * @return string |
|
| 1863 | + */ |
|
| 1864 | + public function get_receipt_url() { |
|
| 1865 | + |
|
| 1866 | + // Retrieve the checkout url. |
|
| 1867 | 1867 | $receipt_url = wpinv_get_success_page_uri(); |
| 1868 | 1868 | |
| 1869 | - // Maybe force ssl. |
|
| 1869 | + // Maybe force ssl. |
|
| 1870 | 1870 | if ( is_ssl() ) { |
| 1871 | 1871 | $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | - // Add the invoice key. |
|
| 1875 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1874 | + // Add the invoice key. |
|
| 1875 | + $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1876 | 1876 | |
| 1877 | 1877 | return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
| 1878 | - } |
|
| 1878 | + } |
|
| 1879 | 1879 | |
| 1880 | - /** |
|
| 1881 | - * Retrieves the default status. |
|
| 1882 | - * |
|
| 1883 | - * @since 1.0.19 |
|
| 1884 | - * @return string |
|
| 1885 | - */ |
|
| 1886 | - public function get_default_status() { |
|
| 1887 | - |
|
| 1888 | - $type = $this->get_type(); |
|
| 1889 | - $status = "wpi-$type-pending"; |
|
| 1890 | - return str_replace( '-invoice', '', $status ); |
|
| 1891 | - |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - /** |
|
| 1895 | - * Magic method for accessing invoice properties. |
|
| 1896 | - * |
|
| 1897 | - * @since 1.0.15 |
|
| 1898 | - * @access public |
|
| 1899 | - * |
|
| 1900 | - * @param string $key Discount data to retrieve |
|
| 1901 | - * @param string $context View or edit context. |
|
| 1902 | - * @return mixed Value of the given invoice property (if set). |
|
| 1903 | - */ |
|
| 1904 | - public function get( $key, $context = 'view' ) { |
|
| 1880 | + /** |
|
| 1881 | + * Retrieves the default status. |
|
| 1882 | + * |
|
| 1883 | + * @since 1.0.19 |
|
| 1884 | + * @return string |
|
| 1885 | + */ |
|
| 1886 | + public function get_default_status() { |
|
| 1887 | + |
|
| 1888 | + $type = $this->get_type(); |
|
| 1889 | + $status = "wpi-$type-pending"; |
|
| 1890 | + return str_replace( '-invoice', '', $status ); |
|
| 1891 | + |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + /** |
|
| 1895 | + * Magic method for accessing invoice properties. |
|
| 1896 | + * |
|
| 1897 | + * @since 1.0.15 |
|
| 1898 | + * @access public |
|
| 1899 | + * |
|
| 1900 | + * @param string $key Discount data to retrieve |
|
| 1901 | + * @param string $context View or edit context. |
|
| 1902 | + * @return mixed Value of the given invoice property (if set). |
|
| 1903 | + */ |
|
| 1904 | + public function get( $key, $context = 'view' ) { |
|
| 1905 | 1905 | return $this->get_prop( $key, $context ); |
| 1906 | - } |
|
| 1906 | + } |
|
| 1907 | 1907 | |
| 1908 | 1908 | /* |
| 1909 | 1909 | |-------------------------------------------------------------------------- |
@@ -1916,130 +1916,130 @@ discard block |
||
| 1916 | 1916 | */ |
| 1917 | 1917 | |
| 1918 | 1918 | /** |
| 1919 | - * Magic method for setting invoice properties. |
|
| 1920 | - * |
|
| 1921 | - * @since 1.0.19 |
|
| 1922 | - * @access public |
|
| 1923 | - * |
|
| 1924 | - * @param string $key Discount data to retrieve |
|
| 1925 | - * @param mixed $value new value. |
|
| 1926 | - * @return mixed Value of the given invoice property (if set). |
|
| 1927 | - */ |
|
| 1928 | - public function set( $key, $value ) { |
|
| 1919 | + * Magic method for setting invoice properties. |
|
| 1920 | + * |
|
| 1921 | + * @since 1.0.19 |
|
| 1922 | + * @access public |
|
| 1923 | + * |
|
| 1924 | + * @param string $key Discount data to retrieve |
|
| 1925 | + * @param mixed $value new value. |
|
| 1926 | + * @return mixed Value of the given invoice property (if set). |
|
| 1927 | + */ |
|
| 1928 | + public function set( $key, $value ) { |
|
| 1929 | 1929 | |
| 1930 | 1930 | $setter = "set_$key"; |
| 1931 | 1931 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1932 | 1932 | $this->{$setter}( $value ); |
| 1933 | 1933 | } |
| 1934 | 1934 | |
| 1935 | - } |
|
| 1935 | + } |
|
| 1936 | 1936 | |
| 1937 | - /** |
|
| 1938 | - * Sets item status. |
|
| 1939 | - * |
|
| 1940 | - * @since 1.0.19 |
|
| 1941 | - * @param string $new_status New status. |
|
| 1942 | - * @param string $note Optional note to add. |
|
| 1943 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1944 | - * @return array details of change. |
|
| 1945 | - */ |
|
| 1946 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1947 | - $old_status = $this->get_status(); |
|
| 1937 | + /** |
|
| 1938 | + * Sets item status. |
|
| 1939 | + * |
|
| 1940 | + * @since 1.0.19 |
|
| 1941 | + * @param string $new_status New status. |
|
| 1942 | + * @param string $note Optional note to add. |
|
| 1943 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1944 | + * @return array details of change. |
|
| 1945 | + */ |
|
| 1946 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1947 | + $old_status = $this->get_status(); |
|
| 1948 | 1948 | |
| 1949 | - $statuses = $this->get_all_statuses(); |
|
| 1949 | + $statuses = $this->get_all_statuses(); |
|
| 1950 | 1950 | |
| 1951 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1952 | - unset( $statuses[ 'draft' ] ); |
|
| 1953 | - } |
|
| 1951 | + if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1952 | + unset( $statuses[ 'draft' ] ); |
|
| 1953 | + } |
|
| 1954 | 1954 | |
| 1955 | - $this->set_prop( 'status', $new_status ); |
|
| 1955 | + $this->set_prop( 'status', $new_status ); |
|
| 1956 | 1956 | |
| 1957 | - // If setting the status, ensure it's set to a valid status. |
|
| 1958 | - if ( true === $this->object_read ) { |
|
| 1957 | + // If setting the status, ensure it's set to a valid status. |
|
| 1958 | + if ( true === $this->object_read ) { |
|
| 1959 | 1959 | |
| 1960 | - // Only allow valid new status. |
|
| 1961 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1962 | - $new_status = $this->get_default_status(); |
|
| 1963 | - } |
|
| 1960 | + // Only allow valid new status. |
|
| 1961 | + if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1962 | + $new_status = $this->get_default_status(); |
|
| 1963 | + } |
|
| 1964 | 1964 | |
| 1965 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1966 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1967 | - $old_status = $this->get_default_status(); |
|
| 1968 | - } |
|
| 1965 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1966 | + if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1967 | + $old_status = $this->get_default_status(); |
|
| 1968 | + } |
|
| 1969 | 1969 | |
| 1970 | - // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1971 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1972 | - $old_status = 'wpi-pending'; |
|
| 1973 | - } |
|
| 1970 | + // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1971 | + if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1972 | + $old_status = 'wpi-pending'; |
|
| 1973 | + } |
|
| 1974 | 1974 | |
| 1975 | - if ( $old_status !== $new_status ) { |
|
| 1976 | - $this->status_transition = array( |
|
| 1977 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1978 | - 'to' => $new_status, |
|
| 1979 | - 'note' => $note, |
|
| 1980 | - 'manual' => (bool) $manual_update, |
|
| 1981 | - ); |
|
| 1975 | + if ( $old_status !== $new_status ) { |
|
| 1976 | + $this->status_transition = array( |
|
| 1977 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1978 | + 'to' => $new_status, |
|
| 1979 | + 'note' => $note, |
|
| 1980 | + 'manual' => (bool) $manual_update, |
|
| 1981 | + ); |
|
| 1982 | 1982 | |
| 1983 | - if ( $manual_update ) { |
|
| 1984 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1985 | - } |
|
| 1983 | + if ( $manual_update ) { |
|
| 1984 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1985 | + } |
|
| 1986 | 1986 | |
| 1987 | - $this->maybe_set_date_paid(); |
|
| 1987 | + $this->maybe_set_date_paid(); |
|
| 1988 | 1988 | |
| 1989 | - } |
|
| 1989 | + } |
|
| 1990 | 1990 | |
| 1991 | - } |
|
| 1991 | + } |
|
| 1992 | 1992 | |
| 1993 | - return array( |
|
| 1994 | - 'from' => $old_status, |
|
| 1995 | - 'to' => $new_status, |
|
| 1996 | - ); |
|
| 1997 | - } |
|
| 1993 | + return array( |
|
| 1994 | + 'from' => $old_status, |
|
| 1995 | + 'to' => $new_status, |
|
| 1996 | + ); |
|
| 1997 | + } |
|
| 1998 | 1998 | |
| 1999 | - /** |
|
| 2000 | - * Maybe set date paid. |
|
| 2001 | - * |
|
| 2002 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 2003 | - * order status. |
|
| 2004 | - * |
|
| 2005 | - * @since 1.0.19 |
|
| 2006 | - */ |
|
| 2007 | - public function maybe_set_date_paid() { |
|
| 1999 | + /** |
|
| 2000 | + * Maybe set date paid. |
|
| 2001 | + * |
|
| 2002 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 2003 | + * order status. |
|
| 2004 | + * |
|
| 2005 | + * @since 1.0.19 |
|
| 2006 | + */ |
|
| 2007 | + public function maybe_set_date_paid() { |
|
| 2008 | 2008 | |
| 2009 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 2010 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 2011 | - } |
|
| 2012 | - } |
|
| 2009 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 2010 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 2011 | + } |
|
| 2012 | + } |
|
| 2013 | 2013 | |
| 2014 | 2014 | /** |
| 2015 | - * Set parent invoice ID. |
|
| 2016 | - * |
|
| 2017 | - * @since 1.0.19 |
|
| 2018 | - */ |
|
| 2019 | - public function set_parent_id( $value ) { |
|
| 2020 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 2021 | - return; |
|
| 2022 | - } |
|
| 2023 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 2015 | + * Set parent invoice ID. |
|
| 2016 | + * |
|
| 2017 | + * @since 1.0.19 |
|
| 2018 | + */ |
|
| 2019 | + public function set_parent_id( $value ) { |
|
| 2020 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 2021 | + return; |
|
| 2022 | + } |
|
| 2023 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 2024 | 2024 | } |
| 2025 | 2025 | |
| 2026 | 2026 | /** |
| 2027 | - * Set plugin version when the invoice was created. |
|
| 2028 | - * |
|
| 2029 | - * @since 1.0.19 |
|
| 2030 | - */ |
|
| 2031 | - public function set_version( $value ) { |
|
| 2032 | - $this->set_prop( 'version', $value ); |
|
| 2027 | + * Set plugin version when the invoice was created. |
|
| 2028 | + * |
|
| 2029 | + * @since 1.0.19 |
|
| 2030 | + */ |
|
| 2031 | + public function set_version( $value ) { |
|
| 2032 | + $this->set_prop( 'version', $value ); |
|
| 2033 | 2033 | } |
| 2034 | - |
|
| 2035 | - /** |
|
| 2036 | - * Set date when the invoice was created. |
|
| 2037 | - * |
|
| 2038 | - * @since 1.0.19 |
|
| 2039 | - * @param string $value Value to set. |
|
| 2034 | + |
|
| 2035 | + /** |
|
| 2036 | + * Set date when the invoice was created. |
|
| 2037 | + * |
|
| 2038 | + * @since 1.0.19 |
|
| 2039 | + * @param string $value Value to set. |
|
| 2040 | 2040 | * @return bool Whether or not the date was set. |
| 2041 | - */ |
|
| 2042 | - public function set_date_created( $value ) { |
|
| 2041 | + */ |
|
| 2042 | + public function set_date_created( $value ) { |
|
| 2043 | 2043 | $date = strtotime( $value ); |
| 2044 | 2044 | |
| 2045 | 2045 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2047,19 +2047,19 @@ discard block |
||
| 2047 | 2047 | return true; |
| 2048 | 2048 | } |
| 2049 | 2049 | |
| 2050 | - $this->set_prop( 'date_created', '' ); |
|
| 2051 | - return false; |
|
| 2050 | + $this->set_prop( 'date_created', '' ); |
|
| 2051 | + return false; |
|
| 2052 | 2052 | |
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | 2055 | /** |
| 2056 | - * Set date invoice due date. |
|
| 2057 | - * |
|
| 2058 | - * @since 1.0.19 |
|
| 2059 | - * @param string $value Value to set. |
|
| 2056 | + * Set date invoice due date. |
|
| 2057 | + * |
|
| 2058 | + * @since 1.0.19 |
|
| 2059 | + * @param string $value Value to set. |
|
| 2060 | 2060 | * @return bool Whether or not the date was set. |
| 2061 | - */ |
|
| 2062 | - public function set_due_date( $value ) { |
|
| 2061 | + */ |
|
| 2062 | + public function set_due_date( $value ) { |
|
| 2063 | 2063 | $date = strtotime( $value ); |
| 2064 | 2064 | |
| 2065 | 2065 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2067,29 +2067,29 @@ discard block |
||
| 2067 | 2067 | return true; |
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | - $this->set_prop( 'due_date', '' ); |
|
| 2070 | + $this->set_prop( 'due_date', '' ); |
|
| 2071 | 2071 | return false; |
| 2072 | 2072 | |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | 2075 | /** |
| 2076 | - * Alias of self::set_due_date(). |
|
| 2077 | - * |
|
| 2078 | - * @since 1.0.19 |
|
| 2079 | - * @param string $value New name. |
|
| 2080 | - */ |
|
| 2081 | - public function set_date_due( $value ) { |
|
| 2082 | - $this->set_due_date( $value ); |
|
| 2076 | + * Alias of self::set_due_date(). |
|
| 2077 | + * |
|
| 2078 | + * @since 1.0.19 |
|
| 2079 | + * @param string $value New name. |
|
| 2080 | + */ |
|
| 2081 | + public function set_date_due( $value ) { |
|
| 2082 | + $this->set_due_date( $value ); |
|
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | /** |
| 2086 | - * Set date invoice was completed. |
|
| 2087 | - * |
|
| 2088 | - * @since 1.0.19 |
|
| 2089 | - * @param string $value Value to set. |
|
| 2086 | + * Set date invoice was completed. |
|
| 2087 | + * |
|
| 2088 | + * @since 1.0.19 |
|
| 2089 | + * @param string $value Value to set. |
|
| 2090 | 2090 | * @return bool Whether or not the date was set. |
| 2091 | - */ |
|
| 2092 | - public function set_completed_date( $value ) { |
|
| 2091 | + */ |
|
| 2092 | + public function set_completed_date( $value ) { |
|
| 2093 | 2093 | $date = strtotime( $value ); |
| 2094 | 2094 | |
| 2095 | 2095 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2097,29 +2097,29 @@ discard block |
||
| 2097 | 2097 | return true; |
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | - $this->set_prop( 'completed_date', '' ); |
|
| 2100 | + $this->set_prop( 'completed_date', '' ); |
|
| 2101 | 2101 | return false; |
| 2102 | 2102 | |
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | 2105 | /** |
| 2106 | - * Alias of self::set_completed_date(). |
|
| 2107 | - * |
|
| 2108 | - * @since 1.0.19 |
|
| 2109 | - * @param string $value New name. |
|
| 2110 | - */ |
|
| 2111 | - public function set_date_completed( $value ) { |
|
| 2112 | - $this->set_completed_date( $value ); |
|
| 2106 | + * Alias of self::set_completed_date(). |
|
| 2107 | + * |
|
| 2108 | + * @since 1.0.19 |
|
| 2109 | + * @param string $value New name. |
|
| 2110 | + */ |
|
| 2111 | + public function set_date_completed( $value ) { |
|
| 2112 | + $this->set_completed_date( $value ); |
|
| 2113 | 2113 | } |
| 2114 | 2114 | |
| 2115 | 2115 | /** |
| 2116 | - * Set date when the invoice was last modified. |
|
| 2117 | - * |
|
| 2118 | - * @since 1.0.19 |
|
| 2119 | - * @param string $value Value to set. |
|
| 2116 | + * Set date when the invoice was last modified. |
|
| 2117 | + * |
|
| 2118 | + * @since 1.0.19 |
|
| 2119 | + * @param string $value Value to set. |
|
| 2120 | 2120 | * @return bool Whether or not the date was set. |
| 2121 | - */ |
|
| 2122 | - public function set_date_modified( $value ) { |
|
| 2121 | + */ |
|
| 2122 | + public function set_date_modified( $value ) { |
|
| 2123 | 2123 | $date = strtotime( $value ); |
| 2124 | 2124 | |
| 2125 | 2125 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2127,788 +2127,788 @@ discard block |
||
| 2127 | 2127 | return true; |
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | - $this->set_prop( 'date_modified', '' ); |
|
| 2130 | + $this->set_prop( 'date_modified', '' ); |
|
| 2131 | 2131 | return false; |
| 2132 | 2132 | |
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | 2135 | /** |
| 2136 | - * Set the invoice number. |
|
| 2137 | - * |
|
| 2138 | - * @since 1.0.19 |
|
| 2139 | - * @param string $value New number. |
|
| 2140 | - */ |
|
| 2141 | - public function set_number( $value ) { |
|
| 2136 | + * Set the invoice number. |
|
| 2137 | + * |
|
| 2138 | + * @since 1.0.19 |
|
| 2139 | + * @param string $value New number. |
|
| 2140 | + */ |
|
| 2141 | + public function set_number( $value ) { |
|
| 2142 | 2142 | $number = sanitize_text_field( $value ); |
| 2143 | - $this->set_prop( 'number', $number ); |
|
| 2143 | + $this->set_prop( 'number', $number ); |
|
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | /** |
| 2147 | - * Set the invoice type. |
|
| 2148 | - * |
|
| 2149 | - * @since 1.0.19 |
|
| 2150 | - * @param string $value Type. |
|
| 2151 | - */ |
|
| 2152 | - public function set_type( $value ) { |
|
| 2147 | + * Set the invoice type. |
|
| 2148 | + * |
|
| 2149 | + * @since 1.0.19 |
|
| 2150 | + * @param string $value Type. |
|
| 2151 | + */ |
|
| 2152 | + public function set_type( $value ) { |
|
| 2153 | 2153 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 2154 | - $this->set_prop( 'type', $type ); |
|
| 2155 | - } |
|
| 2154 | + $this->set_prop( 'type', $type ); |
|
| 2155 | + } |
|
| 2156 | 2156 | |
| 2157 | 2157 | /** |
| 2158 | - * Set the invoice post type. |
|
| 2159 | - * |
|
| 2160 | - * @since 1.0.19 |
|
| 2161 | - * @param string $value Post type. |
|
| 2162 | - */ |
|
| 2163 | - public function set_post_type( $value ) { |
|
| 2158 | + * Set the invoice post type. |
|
| 2159 | + * |
|
| 2160 | + * @since 1.0.19 |
|
| 2161 | + * @param string $value Post type. |
|
| 2162 | + */ |
|
| 2163 | + public function set_post_type( $value ) { |
|
| 2164 | 2164 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 2165 | - $this->set_type( $value ); |
|
| 2165 | + $this->set_type( $value ); |
|
| 2166 | 2166 | $this->set_prop( 'post_type', $value ); |
| 2167 | 2167 | } |
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | 2170 | /** |
| 2171 | - * Set the invoice key. |
|
| 2172 | - * |
|
| 2173 | - * @since 1.0.19 |
|
| 2174 | - * @param string $value New key. |
|
| 2175 | - */ |
|
| 2176 | - public function set_key( $value ) { |
|
| 2171 | + * Set the invoice key. |
|
| 2172 | + * |
|
| 2173 | + * @since 1.0.19 |
|
| 2174 | + * @param string $value New key. |
|
| 2175 | + */ |
|
| 2176 | + public function set_key( $value ) { |
|
| 2177 | 2177 | $key = sanitize_text_field( $value ); |
| 2178 | - $this->set_prop( 'key', $key ); |
|
| 2178 | + $this->set_prop( 'key', $key ); |
|
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | 2181 | /** |
| 2182 | - * Set the invoice mode. |
|
| 2183 | - * |
|
| 2184 | - * @since 1.0.19 |
|
| 2185 | - * @param string $value mode. |
|
| 2186 | - */ |
|
| 2187 | - public function set_mode( $value ) { |
|
| 2182 | + * Set the invoice mode. |
|
| 2183 | + * |
|
| 2184 | + * @since 1.0.19 |
|
| 2185 | + * @param string $value mode. |
|
| 2186 | + */ |
|
| 2187 | + public function set_mode( $value ) { |
|
| 2188 | 2188 | if ( in_array( $value, array( 'live', 'test' ) ) ) { |
| 2189 | 2189 | $this->set_prop( 'mode', $value ); |
| 2190 | 2190 | } |
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | /** |
| 2194 | - * Set the invoice path. |
|
| 2195 | - * |
|
| 2196 | - * @since 1.0.19 |
|
| 2197 | - * @param string $value path. |
|
| 2198 | - */ |
|
| 2199 | - public function set_path( $value ) { |
|
| 2194 | + * Set the invoice path. |
|
| 2195 | + * |
|
| 2196 | + * @since 1.0.19 |
|
| 2197 | + * @param string $value path. |
|
| 2198 | + */ |
|
| 2199 | + public function set_path( $value ) { |
|
| 2200 | 2200 | $this->set_prop( 'path', $value ); |
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | 2203 | /** |
| 2204 | - * Set the invoice name. |
|
| 2205 | - * |
|
| 2206 | - * @since 1.0.19 |
|
| 2207 | - * @param string $value New name. |
|
| 2208 | - */ |
|
| 2209 | - public function set_name( $value ) { |
|
| 2204 | + * Set the invoice name. |
|
| 2205 | + * |
|
| 2206 | + * @since 1.0.19 |
|
| 2207 | + * @param string $value New name. |
|
| 2208 | + */ |
|
| 2209 | + public function set_name( $value ) { |
|
| 2210 | 2210 | $name = sanitize_text_field( $value ); |
| 2211 | - $this->set_prop( 'name', $name ); |
|
| 2211 | + $this->set_prop( 'name', $name ); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | |
| 2214 | 2214 | /** |
| 2215 | - * Alias of self::set_name(). |
|
| 2216 | - * |
|
| 2217 | - * @since 1.0.19 |
|
| 2218 | - * @param string $value New name. |
|
| 2219 | - */ |
|
| 2220 | - public function set_title( $value ) { |
|
| 2221 | - $this->set_name( $value ); |
|
| 2215 | + * Alias of self::set_name(). |
|
| 2216 | + * |
|
| 2217 | + * @since 1.0.19 |
|
| 2218 | + * @param string $value New name. |
|
| 2219 | + */ |
|
| 2220 | + public function set_title( $value ) { |
|
| 2221 | + $this->set_name( $value ); |
|
| 2222 | 2222 | } |
| 2223 | 2223 | |
| 2224 | 2224 | /** |
| 2225 | - * Set the invoice description. |
|
| 2226 | - * |
|
| 2227 | - * @since 1.0.19 |
|
| 2228 | - * @param string $value New description. |
|
| 2229 | - */ |
|
| 2230 | - public function set_description( $value ) { |
|
| 2225 | + * Set the invoice description. |
|
| 2226 | + * |
|
| 2227 | + * @since 1.0.19 |
|
| 2228 | + * @param string $value New description. |
|
| 2229 | + */ |
|
| 2230 | + public function set_description( $value ) { |
|
| 2231 | 2231 | $description = wp_kses_post( $value ); |
| 2232 | - $this->set_prop( 'description', $description ); |
|
| 2232 | + $this->set_prop( 'description', $description ); |
|
| 2233 | + } |
|
| 2234 | + |
|
| 2235 | + /** |
|
| 2236 | + * Alias of self::set_description(). |
|
| 2237 | + * |
|
| 2238 | + * @since 1.0.19 |
|
| 2239 | + * @param string $value New description. |
|
| 2240 | + */ |
|
| 2241 | + public function set_excerpt( $value ) { |
|
| 2242 | + $this->set_description( $value ); |
|
| 2243 | + } |
|
| 2244 | + |
|
| 2245 | + /** |
|
| 2246 | + * Alias of self::set_description(). |
|
| 2247 | + * |
|
| 2248 | + * @since 1.0.19 |
|
| 2249 | + * @param string $value New description. |
|
| 2250 | + */ |
|
| 2251 | + public function set_summary( $value ) { |
|
| 2252 | + $this->set_description( $value ); |
|
| 2253 | + } |
|
| 2254 | + |
|
| 2255 | + /** |
|
| 2256 | + * Set the receiver of the invoice. |
|
| 2257 | + * |
|
| 2258 | + * @since 1.0.19 |
|
| 2259 | + * @param int $value New author. |
|
| 2260 | + */ |
|
| 2261 | + public function set_author( $value ) { |
|
| 2262 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2263 | + |
|
| 2264 | + if ( $user && $user->ID ) { |
|
| 2265 | + $this->set_prop( 'author', $user->ID ); |
|
| 2266 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2267 | + } |
|
| 2268 | + |
|
| 2269 | + } |
|
| 2270 | + |
|
| 2271 | + /** |
|
| 2272 | + * Alias of self::set_author(). |
|
| 2273 | + * |
|
| 2274 | + * @since 1.0.19 |
|
| 2275 | + * @param int $value New user id. |
|
| 2276 | + */ |
|
| 2277 | + public function set_user_id( $value ) { |
|
| 2278 | + $this->set_author( $value ); |
|
| 2279 | + } |
|
| 2280 | + |
|
| 2281 | + /** |
|
| 2282 | + * Alias of self::set_author(). |
|
| 2283 | + * |
|
| 2284 | + * @since 1.0.19 |
|
| 2285 | + * @param int $value New user id. |
|
| 2286 | + */ |
|
| 2287 | + public function set_customer_id( $value ) { |
|
| 2288 | + $this->set_author( $value ); |
|
| 2289 | + } |
|
| 2290 | + |
|
| 2291 | + /** |
|
| 2292 | + * Set the customer's ip. |
|
| 2293 | + * |
|
| 2294 | + * @since 1.0.19 |
|
| 2295 | + * @param string $value ip address. |
|
| 2296 | + */ |
|
| 2297 | + public function set_ip( $value ) { |
|
| 2298 | + $this->set_prop( 'ip', $value ); |
|
| 2299 | + } |
|
| 2300 | + |
|
| 2301 | + /** |
|
| 2302 | + * Alias of self::set_ip(). |
|
| 2303 | + * |
|
| 2304 | + * @since 1.0.19 |
|
| 2305 | + * @param string $value ip address. |
|
| 2306 | + */ |
|
| 2307 | + public function set_user_ip( $value ) { |
|
| 2308 | + $this->set_ip( $value ); |
|
| 2309 | + } |
|
| 2310 | + |
|
| 2311 | + /** |
|
| 2312 | + * Set the customer's first name. |
|
| 2313 | + * |
|
| 2314 | + * @since 1.0.19 |
|
| 2315 | + * @param string $value first name. |
|
| 2316 | + */ |
|
| 2317 | + public function set_first_name( $value ) { |
|
| 2318 | + $this->set_prop( 'first_name', $value ); |
|
| 2233 | 2319 | } |
| 2234 | 2320 | |
| 2235 | 2321 | /** |
| 2236 | - * Alias of self::set_description(). |
|
| 2237 | - * |
|
| 2238 | - * @since 1.0.19 |
|
| 2239 | - * @param string $value New description. |
|
| 2240 | - */ |
|
| 2241 | - public function set_excerpt( $value ) { |
|
| 2242 | - $this->set_description( $value ); |
|
| 2322 | + * Alias of self::set_first_name(). |
|
| 2323 | + * |
|
| 2324 | + * @since 1.0.19 |
|
| 2325 | + * @param string $value first name. |
|
| 2326 | + */ |
|
| 2327 | + public function set_user_first_name( $value ) { |
|
| 2328 | + $this->set_first_name( $value ); |
|
| 2243 | 2329 | } |
| 2244 | 2330 | |
| 2245 | 2331 | /** |
| 2246 | - * Alias of self::set_description(). |
|
| 2247 | - * |
|
| 2248 | - * @since 1.0.19 |
|
| 2249 | - * @param string $value New description. |
|
| 2250 | - */ |
|
| 2251 | - public function set_summary( $value ) { |
|
| 2252 | - $this->set_description( $value ); |
|
| 2332 | + * Alias of self::set_first_name(). |
|
| 2333 | + * |
|
| 2334 | + * @since 1.0.19 |
|
| 2335 | + * @param string $value first name. |
|
| 2336 | + */ |
|
| 2337 | + public function set_customer_first_name( $value ) { |
|
| 2338 | + $this->set_first_name( $value ); |
|
| 2253 | 2339 | } |
| 2254 | 2340 | |
| 2255 | 2341 | /** |
| 2256 | - * Set the receiver of the invoice. |
|
| 2257 | - * |
|
| 2258 | - * @since 1.0.19 |
|
| 2259 | - * @param int $value New author. |
|
| 2260 | - */ |
|
| 2261 | - public function set_author( $value ) { |
|
| 2262 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2342 | + * Set the customer's last name. |
|
| 2343 | + * |
|
| 2344 | + * @since 1.0.19 |
|
| 2345 | + * @param string $value last name. |
|
| 2346 | + */ |
|
| 2347 | + public function set_last_name( $value ) { |
|
| 2348 | + $this->set_prop( 'last_name', $value ); |
|
| 2349 | + } |
|
| 2263 | 2350 | |
| 2264 | - if ( $user && $user->ID ) { |
|
| 2265 | - $this->set_prop( 'author', $user->ID ); |
|
| 2266 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2267 | - } |
|
| 2351 | + /** |
|
| 2352 | + * Alias of self::set_last_name(). |
|
| 2353 | + * |
|
| 2354 | + * @since 1.0.19 |
|
| 2355 | + * @param string $value last name. |
|
| 2356 | + */ |
|
| 2357 | + public function set_user_last_name( $value ) { |
|
| 2358 | + $this->set_last_name( $value ); |
|
| 2359 | + } |
|
| 2268 | 2360 | |
| 2361 | + /** |
|
| 2362 | + * Alias of self::set_last_name(). |
|
| 2363 | + * |
|
| 2364 | + * @since 1.0.19 |
|
| 2365 | + * @param string $value last name. |
|
| 2366 | + */ |
|
| 2367 | + public function set_customer_last_name( $value ) { |
|
| 2368 | + $this->set_last_name( $value ); |
|
| 2269 | 2369 | } |
| 2270 | 2370 | |
| 2271 | 2371 | /** |
| 2272 | - * Alias of self::set_author(). |
|
| 2273 | - * |
|
| 2274 | - * @since 1.0.19 |
|
| 2275 | - * @param int $value New user id. |
|
| 2276 | - */ |
|
| 2277 | - public function set_user_id( $value ) { |
|
| 2278 | - $this->set_author( $value ); |
|
| 2372 | + * Set the customer's phone number. |
|
| 2373 | + * |
|
| 2374 | + * @since 1.0.19 |
|
| 2375 | + * @param string $value phone. |
|
| 2376 | + */ |
|
| 2377 | + public function set_phone( $value ) { |
|
| 2378 | + $this->set_prop( 'phone', $value ); |
|
| 2279 | 2379 | } |
| 2280 | 2380 | |
| 2281 | 2381 | /** |
| 2282 | - * Alias of self::set_author(). |
|
| 2283 | - * |
|
| 2284 | - * @since 1.0.19 |
|
| 2285 | - * @param int $value New user id. |
|
| 2286 | - */ |
|
| 2287 | - public function set_customer_id( $value ) { |
|
| 2288 | - $this->set_author( $value ); |
|
| 2382 | + * Alias of self::set_phone(). |
|
| 2383 | + * |
|
| 2384 | + * @since 1.0.19 |
|
| 2385 | + * @param string $value phone. |
|
| 2386 | + */ |
|
| 2387 | + public function set_user_phone( $value ) { |
|
| 2388 | + $this->set_phone( $value ); |
|
| 2289 | 2389 | } |
| 2290 | 2390 | |
| 2291 | 2391 | /** |
| 2292 | - * Set the customer's ip. |
|
| 2293 | - * |
|
| 2294 | - * @since 1.0.19 |
|
| 2295 | - * @param string $value ip address. |
|
| 2296 | - */ |
|
| 2297 | - public function set_ip( $value ) { |
|
| 2298 | - $this->set_prop( 'ip', $value ); |
|
| 2392 | + * Alias of self::set_phone(). |
|
| 2393 | + * |
|
| 2394 | + * @since 1.0.19 |
|
| 2395 | + * @param string $value phone. |
|
| 2396 | + */ |
|
| 2397 | + public function set_customer_phone( $value ) { |
|
| 2398 | + $this->set_phone( $value ); |
|
| 2299 | 2399 | } |
| 2300 | 2400 | |
| 2301 | 2401 | /** |
| 2302 | - * Alias of self::set_ip(). |
|
| 2303 | - * |
|
| 2304 | - * @since 1.0.19 |
|
| 2305 | - * @param string $value ip address. |
|
| 2306 | - */ |
|
| 2307 | - public function set_user_ip( $value ) { |
|
| 2308 | - $this->set_ip( $value ); |
|
| 2402 | + * Alias of self::set_phone(). |
|
| 2403 | + * |
|
| 2404 | + * @since 1.0.19 |
|
| 2405 | + * @param string $value phone. |
|
| 2406 | + */ |
|
| 2407 | + public function set_phone_number( $value ) { |
|
| 2408 | + $this->set_phone( $value ); |
|
| 2309 | 2409 | } |
| 2310 | 2410 | |
| 2311 | 2411 | /** |
| 2312 | - * Set the customer's first name. |
|
| 2313 | - * |
|
| 2314 | - * @since 1.0.19 |
|
| 2315 | - * @param string $value first name. |
|
| 2316 | - */ |
|
| 2317 | - public function set_first_name( $value ) { |
|
| 2318 | - $this->set_prop( 'first_name', $value ); |
|
| 2412 | + * Set the customer's email address. |
|
| 2413 | + * |
|
| 2414 | + * @since 1.0.19 |
|
| 2415 | + * @param string $value email address. |
|
| 2416 | + */ |
|
| 2417 | + public function set_email( $value ) { |
|
| 2418 | + $this->set_prop( 'email', $value ); |
|
| 2319 | 2419 | } |
| 2320 | 2420 | |
| 2321 | 2421 | /** |
| 2322 | - * Alias of self::set_first_name(). |
|
| 2323 | - * |
|
| 2324 | - * @since 1.0.19 |
|
| 2325 | - * @param string $value first name. |
|
| 2326 | - */ |
|
| 2327 | - public function set_user_first_name( $value ) { |
|
| 2328 | - $this->set_first_name( $value ); |
|
| 2422 | + * Alias of self::set_email(). |
|
| 2423 | + * |
|
| 2424 | + * @since 1.0.19 |
|
| 2425 | + * @param string $value email address. |
|
| 2426 | + */ |
|
| 2427 | + public function set_user_email( $value ) { |
|
| 2428 | + $this->set_email( $value ); |
|
| 2329 | 2429 | } |
| 2330 | 2430 | |
| 2331 | 2431 | /** |
| 2332 | - * Alias of self::set_first_name(). |
|
| 2333 | - * |
|
| 2334 | - * @since 1.0.19 |
|
| 2335 | - * @param string $value first name. |
|
| 2336 | - */ |
|
| 2337 | - public function set_customer_first_name( $value ) { |
|
| 2338 | - $this->set_first_name( $value ); |
|
| 2432 | + * Alias of self::set_email(). |
|
| 2433 | + * |
|
| 2434 | + * @since 1.0.19 |
|
| 2435 | + * @param string $value email address. |
|
| 2436 | + */ |
|
| 2437 | + public function set_email_address( $value ) { |
|
| 2438 | + $this->set_email( $value ); |
|
| 2339 | 2439 | } |
| 2340 | 2440 | |
| 2341 | 2441 | /** |
| 2342 | - * Set the customer's last name. |
|
| 2343 | - * |
|
| 2344 | - * @since 1.0.19 |
|
| 2345 | - * @param string $value last name. |
|
| 2346 | - */ |
|
| 2347 | - public function set_last_name( $value ) { |
|
| 2348 | - $this->set_prop( 'last_name', $value ); |
|
| 2442 | + * Alias of self::set_email(). |
|
| 2443 | + * |
|
| 2444 | + * @since 1.0.19 |
|
| 2445 | + * @param string $value email address. |
|
| 2446 | + */ |
|
| 2447 | + public function set_customer_email( $value ) { |
|
| 2448 | + $this->set_email( $value ); |
|
| 2449 | + } |
|
| 2450 | + |
|
| 2451 | + /** |
|
| 2452 | + * Set the customer's country. |
|
| 2453 | + * |
|
| 2454 | + * @since 1.0.19 |
|
| 2455 | + * @param string $value country. |
|
| 2456 | + */ |
|
| 2457 | + public function set_country( $value ) { |
|
| 2458 | + $this->set_prop( 'country', $value ); |
|
| 2459 | + } |
|
| 2460 | + |
|
| 2461 | + /** |
|
| 2462 | + * Alias of self::set_country(). |
|
| 2463 | + * |
|
| 2464 | + * @since 1.0.19 |
|
| 2465 | + * @param string $value country. |
|
| 2466 | + */ |
|
| 2467 | + public function set_user_country( $value ) { |
|
| 2468 | + $this->set_country( $value ); |
|
| 2349 | 2469 | } |
| 2350 | 2470 | |
| 2351 | 2471 | /** |
| 2352 | - * Alias of self::set_last_name(). |
|
| 2353 | - * |
|
| 2354 | - * @since 1.0.19 |
|
| 2355 | - * @param string $value last name. |
|
| 2356 | - */ |
|
| 2357 | - public function set_user_last_name( $value ) { |
|
| 2358 | - $this->set_last_name( $value ); |
|
| 2472 | + * Alias of self::set_country(). |
|
| 2473 | + * |
|
| 2474 | + * @since 1.0.19 |
|
| 2475 | + * @param string $value country. |
|
| 2476 | + */ |
|
| 2477 | + public function set_customer_country( $value ) { |
|
| 2478 | + $this->set_country( $value ); |
|
| 2359 | 2479 | } |
| 2360 | 2480 | |
| 2361 | 2481 | /** |
| 2362 | - * Alias of self::set_last_name(). |
|
| 2363 | - * |
|
| 2364 | - * @since 1.0.19 |
|
| 2365 | - * @param string $value last name. |
|
| 2366 | - */ |
|
| 2367 | - public function set_customer_last_name( $value ) { |
|
| 2368 | - $this->set_last_name( $value ); |
|
| 2482 | + * Set the customer's state. |
|
| 2483 | + * |
|
| 2484 | + * @since 1.0.19 |
|
| 2485 | + * @param string $value state. |
|
| 2486 | + */ |
|
| 2487 | + public function set_state( $value ) { |
|
| 2488 | + $this->set_prop( 'state', $value ); |
|
| 2489 | + } |
|
| 2490 | + |
|
| 2491 | + /** |
|
| 2492 | + * Alias of self::set_state(). |
|
| 2493 | + * |
|
| 2494 | + * @since 1.0.19 |
|
| 2495 | + * @param string $value state. |
|
| 2496 | + */ |
|
| 2497 | + public function set_user_state( $value ) { |
|
| 2498 | + $this->set_state( $value ); |
|
| 2499 | + } |
|
| 2500 | + |
|
| 2501 | + /** |
|
| 2502 | + * Alias of self::set_state(). |
|
| 2503 | + * |
|
| 2504 | + * @since 1.0.19 |
|
| 2505 | + * @param string $value state. |
|
| 2506 | + */ |
|
| 2507 | + public function set_customer_state( $value ) { |
|
| 2508 | + $this->set_state( $value ); |
|
| 2509 | + } |
|
| 2510 | + |
|
| 2511 | + /** |
|
| 2512 | + * Set the customer's city. |
|
| 2513 | + * |
|
| 2514 | + * @since 1.0.19 |
|
| 2515 | + * @param string $value city. |
|
| 2516 | + */ |
|
| 2517 | + public function set_city( $value ) { |
|
| 2518 | + $this->set_prop( 'city', $value ); |
|
| 2369 | 2519 | } |
| 2370 | 2520 | |
| 2371 | 2521 | /** |
| 2372 | - * Set the customer's phone number. |
|
| 2373 | - * |
|
| 2374 | - * @since 1.0.19 |
|
| 2375 | - * @param string $value phone. |
|
| 2376 | - */ |
|
| 2377 | - public function set_phone( $value ) { |
|
| 2378 | - $this->set_prop( 'phone', $value ); |
|
| 2522 | + * Alias of self::set_city(). |
|
| 2523 | + * |
|
| 2524 | + * @since 1.0.19 |
|
| 2525 | + * @param string $value city. |
|
| 2526 | + */ |
|
| 2527 | + public function set_user_city( $value ) { |
|
| 2528 | + $this->set_city( $value ); |
|
| 2379 | 2529 | } |
| 2380 | 2530 | |
| 2381 | 2531 | /** |
| 2382 | - * Alias of self::set_phone(). |
|
| 2383 | - * |
|
| 2384 | - * @since 1.0.19 |
|
| 2385 | - * @param string $value phone. |
|
| 2386 | - */ |
|
| 2387 | - public function set_user_phone( $value ) { |
|
| 2388 | - $this->set_phone( $value ); |
|
| 2532 | + * Alias of self::set_city(). |
|
| 2533 | + * |
|
| 2534 | + * @since 1.0.19 |
|
| 2535 | + * @param string $value city. |
|
| 2536 | + */ |
|
| 2537 | + public function set_customer_city( $value ) { |
|
| 2538 | + $this->set_city( $value ); |
|
| 2389 | 2539 | } |
| 2390 | 2540 | |
| 2391 | 2541 | /** |
| 2392 | - * Alias of self::set_phone(). |
|
| 2393 | - * |
|
| 2394 | - * @since 1.0.19 |
|
| 2395 | - * @param string $value phone. |
|
| 2396 | - */ |
|
| 2397 | - public function set_customer_phone( $value ) { |
|
| 2398 | - $this->set_phone( $value ); |
|
| 2542 | + * Set the customer's zip code. |
|
| 2543 | + * |
|
| 2544 | + * @since 1.0.19 |
|
| 2545 | + * @param string $value zip. |
|
| 2546 | + */ |
|
| 2547 | + public function set_zip( $value ) { |
|
| 2548 | + $this->set_prop( 'zip', $value ); |
|
| 2399 | 2549 | } |
| 2400 | 2550 | |
| 2401 | 2551 | /** |
| 2402 | - * Alias of self::set_phone(). |
|
| 2403 | - * |
|
| 2404 | - * @since 1.0.19 |
|
| 2405 | - * @param string $value phone. |
|
| 2406 | - */ |
|
| 2407 | - public function set_phone_number( $value ) { |
|
| 2408 | - $this->set_phone( $value ); |
|
| 2552 | + * Alias of self::set_zip(). |
|
| 2553 | + * |
|
| 2554 | + * @since 1.0.19 |
|
| 2555 | + * @param string $value zip. |
|
| 2556 | + */ |
|
| 2557 | + public function set_user_zip( $value ) { |
|
| 2558 | + $this->set_zip( $value ); |
|
| 2409 | 2559 | } |
| 2410 | 2560 | |
| 2411 | 2561 | /** |
| 2412 | - * Set the customer's email address. |
|
| 2413 | - * |
|
| 2414 | - * @since 1.0.19 |
|
| 2415 | - * @param string $value email address. |
|
| 2416 | - */ |
|
| 2417 | - public function set_email( $value ) { |
|
| 2418 | - $this->set_prop( 'email', $value ); |
|
| 2562 | + * Alias of self::set_zip(). |
|
| 2563 | + * |
|
| 2564 | + * @since 1.0.19 |
|
| 2565 | + * @param string $value zip. |
|
| 2566 | + */ |
|
| 2567 | + public function set_customer_zip( $value ) { |
|
| 2568 | + $this->set_zip( $value ); |
|
| 2419 | 2569 | } |
| 2420 | 2570 | |
| 2421 | 2571 | /** |
| 2422 | - * Alias of self::set_email(). |
|
| 2423 | - * |
|
| 2424 | - * @since 1.0.19 |
|
| 2425 | - * @param string $value email address. |
|
| 2426 | - */ |
|
| 2427 | - public function set_user_email( $value ) { |
|
| 2428 | - $this->set_email( $value ); |
|
| 2572 | + * Set the customer's company. |
|
| 2573 | + * |
|
| 2574 | + * @since 1.0.19 |
|
| 2575 | + * @param string $value company. |
|
| 2576 | + */ |
|
| 2577 | + public function set_company( $value ) { |
|
| 2578 | + $this->set_prop( 'company', $value ); |
|
| 2429 | 2579 | } |
| 2430 | 2580 | |
| 2431 | 2581 | /** |
| 2432 | - * Alias of self::set_email(). |
|
| 2433 | - * |
|
| 2434 | - * @since 1.0.19 |
|
| 2435 | - * @param string $value email address. |
|
| 2436 | - */ |
|
| 2437 | - public function set_email_address( $value ) { |
|
| 2438 | - $this->set_email( $value ); |
|
| 2582 | + * Alias of self::set_company(). |
|
| 2583 | + * |
|
| 2584 | + * @since 1.0.19 |
|
| 2585 | + * @param string $value company. |
|
| 2586 | + */ |
|
| 2587 | + public function set_user_company( $value ) { |
|
| 2588 | + $this->set_company( $value ); |
|
| 2439 | 2589 | } |
| 2440 | 2590 | |
| 2441 | 2591 | /** |
| 2442 | - * Alias of self::set_email(). |
|
| 2443 | - * |
|
| 2444 | - * @since 1.0.19 |
|
| 2445 | - * @param string $value email address. |
|
| 2446 | - */ |
|
| 2447 | - public function set_customer_email( $value ) { |
|
| 2448 | - $this->set_email( $value ); |
|
| 2592 | + * Alias of self::set_company(). |
|
| 2593 | + * |
|
| 2594 | + * @since 1.0.19 |
|
| 2595 | + * @param string $value company. |
|
| 2596 | + */ |
|
| 2597 | + public function set_customer_company( $value ) { |
|
| 2598 | + $this->set_company( $value ); |
|
| 2449 | 2599 | } |
| 2450 | 2600 | |
| 2451 | 2601 | /** |
| 2452 | - * Set the customer's country. |
|
| 2453 | - * |
|
| 2454 | - * @since 1.0.19 |
|
| 2455 | - * @param string $value country. |
|
| 2456 | - */ |
|
| 2457 | - public function set_country( $value ) { |
|
| 2458 | - $this->set_prop( 'country', $value ); |
|
| 2602 | + * Set the customer's var number. |
|
| 2603 | + * |
|
| 2604 | + * @since 1.0.19 |
|
| 2605 | + * @param string $value var number. |
|
| 2606 | + */ |
|
| 2607 | + public function set_vat_number( $value ) { |
|
| 2608 | + $this->set_prop( 'vat_number', $value ); |
|
| 2459 | 2609 | } |
| 2460 | 2610 | |
| 2461 | 2611 | /** |
| 2462 | - * Alias of self::set_country(). |
|
| 2463 | - * |
|
| 2464 | - * @since 1.0.19 |
|
| 2465 | - * @param string $value country. |
|
| 2466 | - */ |
|
| 2467 | - public function set_user_country( $value ) { |
|
| 2468 | - $this->set_country( $value ); |
|
| 2612 | + * Alias of self::set_vat_number(). |
|
| 2613 | + * |
|
| 2614 | + * @since 1.0.19 |
|
| 2615 | + * @param string $value var number. |
|
| 2616 | + */ |
|
| 2617 | + public function set_user_vat_number( $value ) { |
|
| 2618 | + $this->set_vat_number( $value ); |
|
| 2469 | 2619 | } |
| 2470 | 2620 | |
| 2471 | 2621 | /** |
| 2472 | - * Alias of self::set_country(). |
|
| 2473 | - * |
|
| 2474 | - * @since 1.0.19 |
|
| 2475 | - * @param string $value country. |
|
| 2476 | - */ |
|
| 2477 | - public function set_customer_country( $value ) { |
|
| 2478 | - $this->set_country( $value ); |
|
| 2622 | + * Alias of self::set_vat_number(). |
|
| 2623 | + * |
|
| 2624 | + * @since 1.0.19 |
|
| 2625 | + * @param string $value var number. |
|
| 2626 | + */ |
|
| 2627 | + public function set_customer_vat_number( $value ) { |
|
| 2628 | + $this->set_vat_number( $value ); |
|
| 2479 | 2629 | } |
| 2480 | 2630 | |
| 2481 | 2631 | /** |
| 2482 | - * Set the customer's state. |
|
| 2483 | - * |
|
| 2484 | - * @since 1.0.19 |
|
| 2485 | - * @param string $value state. |
|
| 2486 | - */ |
|
| 2487 | - public function set_state( $value ) { |
|
| 2488 | - $this->set_prop( 'state', $value ); |
|
| 2632 | + * Set the customer's vat rate. |
|
| 2633 | + * |
|
| 2634 | + * @since 1.0.19 |
|
| 2635 | + * @param string $value var rate. |
|
| 2636 | + */ |
|
| 2637 | + public function set_vat_rate( $value ) { |
|
| 2638 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2489 | 2639 | } |
| 2490 | 2640 | |
| 2491 | 2641 | /** |
| 2492 | - * Alias of self::set_state(). |
|
| 2493 | - * |
|
| 2494 | - * @since 1.0.19 |
|
| 2495 | - * @param string $value state. |
|
| 2496 | - */ |
|
| 2497 | - public function set_user_state( $value ) { |
|
| 2498 | - $this->set_state( $value ); |
|
| 2642 | + * Alias of self::set_vat_rate(). |
|
| 2643 | + * |
|
| 2644 | + * @since 1.0.19 |
|
| 2645 | + * @param string $value var number. |
|
| 2646 | + */ |
|
| 2647 | + public function set_user_vat_rate( $value ) { |
|
| 2648 | + $this->set_vat_rate( $value ); |
|
| 2499 | 2649 | } |
| 2500 | 2650 | |
| 2501 | 2651 | /** |
| 2502 | - * Alias of self::set_state(). |
|
| 2503 | - * |
|
| 2504 | - * @since 1.0.19 |
|
| 2505 | - * @param string $value state. |
|
| 2506 | - */ |
|
| 2507 | - public function set_customer_state( $value ) { |
|
| 2508 | - $this->set_state( $value ); |
|
| 2652 | + * Alias of self::set_vat_rate(). |
|
| 2653 | + * |
|
| 2654 | + * @since 1.0.19 |
|
| 2655 | + * @param string $value var number. |
|
| 2656 | + */ |
|
| 2657 | + public function set_customer_vat_rate( $value ) { |
|
| 2658 | + $this->set_vat_rate( $value ); |
|
| 2509 | 2659 | } |
| 2510 | 2660 | |
| 2511 | 2661 | /** |
| 2512 | - * Set the customer's city. |
|
| 2513 | - * |
|
| 2514 | - * @since 1.0.19 |
|
| 2515 | - * @param string $value city. |
|
| 2516 | - */ |
|
| 2517 | - public function set_city( $value ) { |
|
| 2518 | - $this->set_prop( 'city', $value ); |
|
| 2662 | + * Set the customer's address. |
|
| 2663 | + * |
|
| 2664 | + * @since 1.0.19 |
|
| 2665 | + * @param string $value address. |
|
| 2666 | + */ |
|
| 2667 | + public function set_address( $value ) { |
|
| 2668 | + $this->set_prop( 'address', $value ); |
|
| 2519 | 2669 | } |
| 2520 | 2670 | |
| 2521 | 2671 | /** |
| 2522 | - * Alias of self::set_city(). |
|
| 2523 | - * |
|
| 2524 | - * @since 1.0.19 |
|
| 2525 | - * @param string $value city. |
|
| 2526 | - */ |
|
| 2527 | - public function set_user_city( $value ) { |
|
| 2528 | - $this->set_city( $value ); |
|
| 2672 | + * Alias of self::set_address(). |
|
| 2673 | + * |
|
| 2674 | + * @since 1.0.19 |
|
| 2675 | + * @param string $value address. |
|
| 2676 | + */ |
|
| 2677 | + public function set_user_address( $value ) { |
|
| 2678 | + $this->set_address( $value ); |
|
| 2529 | 2679 | } |
| 2530 | 2680 | |
| 2531 | 2681 | /** |
| 2532 | - * Alias of self::set_city(). |
|
| 2533 | - * |
|
| 2534 | - * @since 1.0.19 |
|
| 2535 | - * @param string $value city. |
|
| 2536 | - */ |
|
| 2537 | - public function set_customer_city( $value ) { |
|
| 2538 | - $this->set_city( $value ); |
|
| 2682 | + * Alias of self::set_address(). |
|
| 2683 | + * |
|
| 2684 | + * @since 1.0.19 |
|
| 2685 | + * @param string $value address. |
|
| 2686 | + */ |
|
| 2687 | + public function set_customer_address( $value ) { |
|
| 2688 | + $this->set_address( $value ); |
|
| 2539 | 2689 | } |
| 2540 | 2690 | |
| 2541 | 2691 | /** |
| 2542 | - * Set the customer's zip code. |
|
| 2543 | - * |
|
| 2544 | - * @since 1.0.19 |
|
| 2545 | - * @param string $value zip. |
|
| 2546 | - */ |
|
| 2547 | - public function set_zip( $value ) { |
|
| 2548 | - $this->set_prop( 'zip', $value ); |
|
| 2692 | + * Set whether the customer has viewed the invoice or not. |
|
| 2693 | + * |
|
| 2694 | + * @since 1.0.19 |
|
| 2695 | + * @param int|bool $value confirmed. |
|
| 2696 | + */ |
|
| 2697 | + public function set_is_viewed( $value ) { |
|
| 2698 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2549 | 2699 | } |
| 2550 | 2700 | |
| 2551 | 2701 | /** |
| 2552 | - * Alias of self::set_zip(). |
|
| 2553 | - * |
|
| 2554 | - * @since 1.0.19 |
|
| 2555 | - * @param string $value zip. |
|
| 2556 | - */ |
|
| 2557 | - public function set_user_zip( $value ) { |
|
| 2558 | - $this->set_zip( $value ); |
|
| 2702 | + * Set extra email recipients. |
|
| 2703 | + * |
|
| 2704 | + * @since 1.0.19 |
|
| 2705 | + * @param string $value email recipients. |
|
| 2706 | + */ |
|
| 2707 | + public function set_email_cc( $value ) { |
|
| 2708 | + $this->set_prop( 'email_cc', $value ); |
|
| 2559 | 2709 | } |
| 2560 | 2710 | |
| 2561 | 2711 | /** |
| 2562 | - * Alias of self::set_zip(). |
|
| 2563 | - * |
|
| 2564 | - * @since 1.0.19 |
|
| 2565 | - * @param string $value zip. |
|
| 2566 | - */ |
|
| 2567 | - public function set_customer_zip( $value ) { |
|
| 2568 | - $this->set_zip( $value ); |
|
| 2712 | + * Set the invoice template. |
|
| 2713 | + * |
|
| 2714 | + * @since 1.0.19 |
|
| 2715 | + * @param string $value template. |
|
| 2716 | + */ |
|
| 2717 | + public function set_template( $value ) { |
|
| 2718 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2719 | + $this->set_prop( 'template', $value ); |
|
| 2720 | + } |
|
| 2569 | 2721 | } |
| 2570 | 2722 | |
| 2571 | 2723 | /** |
| 2572 | - * Set the customer's company. |
|
| 2573 | - * |
|
| 2574 | - * @since 1.0.19 |
|
| 2575 | - * @param string $value company. |
|
| 2576 | - */ |
|
| 2577 | - public function set_company( $value ) { |
|
| 2578 | - $this->set_prop( 'company', $value ); |
|
| 2724 | + * Set the invoice source. |
|
| 2725 | + * |
|
| 2726 | + * @since 1.0.19 |
|
| 2727 | + * @param string $value source. |
|
| 2728 | + * @deprecated |
|
| 2729 | + */ |
|
| 2730 | + public function created_via( $value ) { |
|
| 2731 | + $this->set_created_via( sanitize_text_field( $value ) ); |
|
| 2579 | 2732 | } |
| 2580 | 2733 | |
| 2581 | 2734 | /** |
| 2582 | - * Alias of self::set_company(). |
|
| 2583 | - * |
|
| 2584 | - * @since 1.0.19 |
|
| 2585 | - * @param string $value company. |
|
| 2586 | - */ |
|
| 2587 | - public function set_user_company( $value ) { |
|
| 2588 | - $this->set_company( $value ); |
|
| 2735 | + * Set the invoice source. |
|
| 2736 | + * |
|
| 2737 | + * @since 1.0.19 |
|
| 2738 | + * @param string $value source. |
|
| 2739 | + */ |
|
| 2740 | + public function set_created_via( $value ) { |
|
| 2741 | + $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2589 | 2742 | } |
| 2590 | 2743 | |
| 2591 | 2744 | /** |
| 2592 | - * Alias of self::set_company(). |
|
| 2593 | - * |
|
| 2594 | - * @since 1.0.19 |
|
| 2595 | - * @param string $value company. |
|
| 2596 | - */ |
|
| 2597 | - public function set_customer_company( $value ) { |
|
| 2598 | - $this->set_company( $value ); |
|
| 2745 | + * Set the customer's address confirmed status. |
|
| 2746 | + * |
|
| 2747 | + * @since 1.0.19 |
|
| 2748 | + * @param int|bool $value confirmed. |
|
| 2749 | + */ |
|
| 2750 | + public function set_address_confirmed( $value ) { |
|
| 2751 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2599 | 2752 | } |
| 2600 | 2753 | |
| 2601 | 2754 | /** |
| 2602 | - * Set the customer's var number. |
|
| 2603 | - * |
|
| 2604 | - * @since 1.0.19 |
|
| 2605 | - * @param string $value var number. |
|
| 2606 | - */ |
|
| 2607 | - public function set_vat_number( $value ) { |
|
| 2608 | - $this->set_prop( 'vat_number', $value ); |
|
| 2755 | + * Alias of self::set_address_confirmed(). |
|
| 2756 | + * |
|
| 2757 | + * @since 1.0.19 |
|
| 2758 | + * @param int|bool $value confirmed. |
|
| 2759 | + */ |
|
| 2760 | + public function set_user_address_confirmed( $value ) { |
|
| 2761 | + $this->set_address_confirmed( $value ); |
|
| 2609 | 2762 | } |
| 2610 | 2763 | |
| 2611 | 2764 | /** |
| 2612 | - * Alias of self::set_vat_number(). |
|
| 2613 | - * |
|
| 2614 | - * @since 1.0.19 |
|
| 2615 | - * @param string $value var number. |
|
| 2616 | - */ |
|
| 2617 | - public function set_user_vat_number( $value ) { |
|
| 2618 | - $this->set_vat_number( $value ); |
|
| 2765 | + * Alias of self::set_address_confirmed(). |
|
| 2766 | + * |
|
| 2767 | + * @since 1.0.19 |
|
| 2768 | + * @param int|bool $value confirmed. |
|
| 2769 | + */ |
|
| 2770 | + public function set_customer_address_confirmed( $value ) { |
|
| 2771 | + $this->set_address_confirmed( $value ); |
|
| 2619 | 2772 | } |
| 2620 | 2773 | |
| 2621 | 2774 | /** |
| 2622 | - * Alias of self::set_vat_number(). |
|
| 2623 | - * |
|
| 2624 | - * @since 1.0.19 |
|
| 2625 | - * @param string $value var number. |
|
| 2626 | - */ |
|
| 2627 | - public function set_customer_vat_number( $value ) { |
|
| 2628 | - $this->set_vat_number( $value ); |
|
| 2775 | + * Set the invoice sub total. |
|
| 2776 | + * |
|
| 2777 | + * @since 1.0.19 |
|
| 2778 | + * @param float $value sub total. |
|
| 2779 | + */ |
|
| 2780 | + public function set_subtotal( $value ) { |
|
| 2781 | + $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
| 2629 | 2782 | } |
| 2630 | 2783 | |
| 2631 | 2784 | /** |
| 2632 | - * Set the customer's vat rate. |
|
| 2633 | - * |
|
| 2634 | - * @since 1.0.19 |
|
| 2635 | - * @param string $value var rate. |
|
| 2636 | - */ |
|
| 2637 | - public function set_vat_rate( $value ) { |
|
| 2638 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2785 | + * Set the invoice total. |
|
| 2786 | + * |
|
| 2787 | + * @since 1.0.19 |
|
| 2788 | + * @param float $value sub total. |
|
| 2789 | + */ |
|
| 2790 | + public function set_total( $value ) { |
|
| 2791 | + $this->set_prop( 'total', max( 0, $value ) ); |
|
| 2639 | 2792 | } |
| 2640 | 2793 | |
| 2641 | 2794 | /** |
| 2642 | - * Alias of self::set_vat_rate(). |
|
| 2643 | - * |
|
| 2644 | - * @since 1.0.19 |
|
| 2645 | - * @param string $value var number. |
|
| 2646 | - */ |
|
| 2647 | - public function set_user_vat_rate( $value ) { |
|
| 2648 | - $this->set_vat_rate( $value ); |
|
| 2649 | - } |
|
| 2650 | - |
|
| 2651 | - /** |
|
| 2652 | - * Alias of self::set_vat_rate(). |
|
| 2653 | - * |
|
| 2654 | - * @since 1.0.19 |
|
| 2655 | - * @param string $value var number. |
|
| 2656 | - */ |
|
| 2657 | - public function set_customer_vat_rate( $value ) { |
|
| 2658 | - $this->set_vat_rate( $value ); |
|
| 2659 | - } |
|
| 2660 | - |
|
| 2661 | - /** |
|
| 2662 | - * Set the customer's address. |
|
| 2663 | - * |
|
| 2664 | - * @since 1.0.19 |
|
| 2665 | - * @param string $value address. |
|
| 2666 | - */ |
|
| 2667 | - public function set_address( $value ) { |
|
| 2668 | - $this->set_prop( 'address', $value ); |
|
| 2669 | - } |
|
| 2670 | - |
|
| 2671 | - /** |
|
| 2672 | - * Alias of self::set_address(). |
|
| 2673 | - * |
|
| 2674 | - * @since 1.0.19 |
|
| 2675 | - * @param string $value address. |
|
| 2676 | - */ |
|
| 2677 | - public function set_user_address( $value ) { |
|
| 2678 | - $this->set_address( $value ); |
|
| 2679 | - } |
|
| 2680 | - |
|
| 2681 | - /** |
|
| 2682 | - * Alias of self::set_address(). |
|
| 2683 | - * |
|
| 2684 | - * @since 1.0.19 |
|
| 2685 | - * @param string $value address. |
|
| 2686 | - */ |
|
| 2687 | - public function set_customer_address( $value ) { |
|
| 2688 | - $this->set_address( $value ); |
|
| 2689 | - } |
|
| 2690 | - |
|
| 2691 | - /** |
|
| 2692 | - * Set whether the customer has viewed the invoice or not. |
|
| 2693 | - * |
|
| 2694 | - * @since 1.0.19 |
|
| 2695 | - * @param int|bool $value confirmed. |
|
| 2696 | - */ |
|
| 2697 | - public function set_is_viewed( $value ) { |
|
| 2698 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2699 | - } |
|
| 2700 | - |
|
| 2701 | - /** |
|
| 2702 | - * Set extra email recipients. |
|
| 2703 | - * |
|
| 2704 | - * @since 1.0.19 |
|
| 2705 | - * @param string $value email recipients. |
|
| 2706 | - */ |
|
| 2707 | - public function set_email_cc( $value ) { |
|
| 2708 | - $this->set_prop( 'email_cc', $value ); |
|
| 2709 | - } |
|
| 2710 | - |
|
| 2711 | - /** |
|
| 2712 | - * Set the invoice template. |
|
| 2713 | - * |
|
| 2714 | - * @since 1.0.19 |
|
| 2715 | - * @param string $value template. |
|
| 2716 | - */ |
|
| 2717 | - public function set_template( $value ) { |
|
| 2718 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2719 | - $this->set_prop( 'template', $value ); |
|
| 2720 | - } |
|
| 2721 | - } |
|
| 2722 | - |
|
| 2723 | - /** |
|
| 2724 | - * Set the invoice source. |
|
| 2725 | - * |
|
| 2726 | - * @since 1.0.19 |
|
| 2727 | - * @param string $value source. |
|
| 2728 | - * @deprecated |
|
| 2729 | - */ |
|
| 2730 | - public function created_via( $value ) { |
|
| 2731 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
| 2732 | - } |
|
| 2733 | - |
|
| 2734 | - /** |
|
| 2735 | - * Set the invoice source. |
|
| 2736 | - * |
|
| 2737 | - * @since 1.0.19 |
|
| 2738 | - * @param string $value source. |
|
| 2739 | - */ |
|
| 2740 | - public function set_created_via( $value ) { |
|
| 2741 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2742 | - } |
|
| 2743 | - |
|
| 2744 | - /** |
|
| 2745 | - * Set the customer's address confirmed status. |
|
| 2746 | - * |
|
| 2747 | - * @since 1.0.19 |
|
| 2748 | - * @param int|bool $value confirmed. |
|
| 2749 | - */ |
|
| 2750 | - public function set_address_confirmed( $value ) { |
|
| 2751 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2752 | - } |
|
| 2753 | - |
|
| 2754 | - /** |
|
| 2755 | - * Alias of self::set_address_confirmed(). |
|
| 2756 | - * |
|
| 2757 | - * @since 1.0.19 |
|
| 2758 | - * @param int|bool $value confirmed. |
|
| 2759 | - */ |
|
| 2760 | - public function set_user_address_confirmed( $value ) { |
|
| 2761 | - $this->set_address_confirmed( $value ); |
|
| 2762 | - } |
|
| 2763 | - |
|
| 2764 | - /** |
|
| 2765 | - * Alias of self::set_address_confirmed(). |
|
| 2766 | - * |
|
| 2767 | - * @since 1.0.19 |
|
| 2768 | - * @param int|bool $value confirmed. |
|
| 2769 | - */ |
|
| 2770 | - public function set_customer_address_confirmed( $value ) { |
|
| 2771 | - $this->set_address_confirmed( $value ); |
|
| 2772 | - } |
|
| 2773 | - |
|
| 2774 | - /** |
|
| 2775 | - * Set the invoice sub total. |
|
| 2776 | - * |
|
| 2777 | - * @since 1.0.19 |
|
| 2778 | - * @param float $value sub total. |
|
| 2779 | - */ |
|
| 2780 | - public function set_subtotal( $value ) { |
|
| 2781 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
| 2782 | - } |
|
| 2783 | - |
|
| 2784 | - /** |
|
| 2785 | - * Set the invoice total. |
|
| 2786 | - * |
|
| 2787 | - * @since 1.0.19 |
|
| 2788 | - * @param float $value sub total. |
|
| 2789 | - */ |
|
| 2790 | - public function set_total( $value ) { |
|
| 2791 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
| 2792 | - } |
|
| 2793 | - |
|
| 2794 | - /** |
|
| 2795 | - * Set the invoice discount amount. |
|
| 2796 | - * |
|
| 2797 | - * @since 1.0.19 |
|
| 2798 | - * @param float $value discount total. |
|
| 2799 | - */ |
|
| 2800 | - public function set_total_discount( $value ) { |
|
| 2801 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
| 2795 | + * Set the invoice discount amount. |
|
| 2796 | + * |
|
| 2797 | + * @since 1.0.19 |
|
| 2798 | + * @param float $value discount total. |
|
| 2799 | + */ |
|
| 2800 | + public function set_total_discount( $value ) { |
|
| 2801 | + $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
| 2802 | 2802 | } |
| 2803 | 2803 | |
| 2804 | 2804 | /** |
| 2805 | - * Alias of self::set_total_discount(). |
|
| 2806 | - * |
|
| 2807 | - * @since 1.0.19 |
|
| 2808 | - * @param float $value discount total. |
|
| 2809 | - */ |
|
| 2810 | - public function set_discount( $value ) { |
|
| 2811 | - $this->set_total_discount( $value ); |
|
| 2805 | + * Alias of self::set_total_discount(). |
|
| 2806 | + * |
|
| 2807 | + * @since 1.0.19 |
|
| 2808 | + * @param float $value discount total. |
|
| 2809 | + */ |
|
| 2810 | + public function set_discount( $value ) { |
|
| 2811 | + $this->set_total_discount( $value ); |
|
| 2812 | 2812 | } |
| 2813 | 2813 | |
| 2814 | 2814 | /** |
| 2815 | - * Set the invoice tax amount. |
|
| 2816 | - * |
|
| 2817 | - * @since 1.0.19 |
|
| 2818 | - * @param float $value tax total. |
|
| 2819 | - */ |
|
| 2820 | - public function set_total_tax( $value ) { |
|
| 2821 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
| 2815 | + * Set the invoice tax amount. |
|
| 2816 | + * |
|
| 2817 | + * @since 1.0.19 |
|
| 2818 | + * @param float $value tax total. |
|
| 2819 | + */ |
|
| 2820 | + public function set_total_tax( $value ) { |
|
| 2821 | + $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | 2824 | /** |
| 2825 | - * Alias of self::set_total_tax(). |
|
| 2826 | - * |
|
| 2827 | - * @since 1.0.19 |
|
| 2828 | - * @param float $value tax total. |
|
| 2829 | - */ |
|
| 2830 | - public function set_tax_total( $value ) { |
|
| 2831 | - $this->set_total_tax( $value ); |
|
| 2825 | + * Alias of self::set_total_tax(). |
|
| 2826 | + * |
|
| 2827 | + * @since 1.0.19 |
|
| 2828 | + * @param float $value tax total. |
|
| 2829 | + */ |
|
| 2830 | + public function set_tax_total( $value ) { |
|
| 2831 | + $this->set_total_tax( $value ); |
|
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | 2834 | /** |
| 2835 | - * Set the invoice fees amount. |
|
| 2836 | - * |
|
| 2837 | - * @since 1.0.19 |
|
| 2838 | - * @param float $value fees total. |
|
| 2839 | - */ |
|
| 2840 | - public function set_total_fees( $value ) { |
|
| 2841 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
| 2835 | + * Set the invoice fees amount. |
|
| 2836 | + * |
|
| 2837 | + * @since 1.0.19 |
|
| 2838 | + * @param float $value fees total. |
|
| 2839 | + */ |
|
| 2840 | + public function set_total_fees( $value ) { |
|
| 2841 | + $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
| 2842 | 2842 | } |
| 2843 | 2843 | |
| 2844 | 2844 | /** |
| 2845 | - * Alias of self::set_total_fees(). |
|
| 2846 | - * |
|
| 2847 | - * @since 1.0.19 |
|
| 2848 | - * @param float $value fees total. |
|
| 2849 | - */ |
|
| 2850 | - public function set_fees_total( $value ) { |
|
| 2851 | - $this->set_total_fees( $value ); |
|
| 2845 | + * Alias of self::set_total_fees(). |
|
| 2846 | + * |
|
| 2847 | + * @since 1.0.19 |
|
| 2848 | + * @param float $value fees total. |
|
| 2849 | + */ |
|
| 2850 | + public function set_fees_total( $value ) { |
|
| 2851 | + $this->set_total_fees( $value ); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | /** |
| 2855 | - * Set the invoice fees. |
|
| 2856 | - * |
|
| 2857 | - * @since 1.0.19 |
|
| 2858 | - * @param array $value fees. |
|
| 2859 | - */ |
|
| 2860 | - public function set_fees( $value ) { |
|
| 2855 | + * Set the invoice fees. |
|
| 2856 | + * |
|
| 2857 | + * @since 1.0.19 |
|
| 2858 | + * @param array $value fees. |
|
| 2859 | + */ |
|
| 2860 | + public function set_fees( $value ) { |
|
| 2861 | 2861 | |
| 2862 | - if ( ! is_array( $value ) ) { |
|
| 2863 | - $value = array(); |
|
| 2864 | - } |
|
| 2862 | + if ( ! is_array( $value ) ) { |
|
| 2863 | + $value = array(); |
|
| 2864 | + } |
|
| 2865 | 2865 | |
| 2866 | - $this->set_prop( 'fees', $value ); |
|
| 2866 | + $this->set_prop( 'fees', $value ); |
|
| 2867 | 2867 | |
| 2868 | 2868 | } |
| 2869 | 2869 | |
| 2870 | 2870 | /** |
| 2871 | - * Set the invoice taxes. |
|
| 2872 | - * |
|
| 2873 | - * @since 1.0.19 |
|
| 2874 | - * @param array $value taxes. |
|
| 2875 | - */ |
|
| 2876 | - public function set_taxes( $value ) { |
|
| 2871 | + * Set the invoice taxes. |
|
| 2872 | + * |
|
| 2873 | + * @since 1.0.19 |
|
| 2874 | + * @param array $value taxes. |
|
| 2875 | + */ |
|
| 2876 | + public function set_taxes( $value ) { |
|
| 2877 | 2877 | |
| 2878 | - if ( ! is_array( $value ) ) { |
|
| 2879 | - $value = array(); |
|
| 2880 | - } |
|
| 2878 | + if ( ! is_array( $value ) ) { |
|
| 2879 | + $value = array(); |
|
| 2880 | + } |
|
| 2881 | 2881 | |
| 2882 | - $this->set_prop( 'taxes', $value ); |
|
| 2882 | + $this->set_prop( 'taxes', $value ); |
|
| 2883 | 2883 | |
| 2884 | 2884 | } |
| 2885 | 2885 | |
| 2886 | 2886 | /** |
| 2887 | - * Set the invoice discounts. |
|
| 2888 | - * |
|
| 2889 | - * @since 1.0.19 |
|
| 2890 | - * @param array $value discounts. |
|
| 2891 | - */ |
|
| 2892 | - public function set_discounts( $value ) { |
|
| 2887 | + * Set the invoice discounts. |
|
| 2888 | + * |
|
| 2889 | + * @since 1.0.19 |
|
| 2890 | + * @param array $value discounts. |
|
| 2891 | + */ |
|
| 2892 | + public function set_discounts( $value ) { |
|
| 2893 | 2893 | |
| 2894 | - if ( ! is_array( $value ) ) { |
|
| 2895 | - $value = array(); |
|
| 2896 | - } |
|
| 2894 | + if ( ! is_array( $value ) ) { |
|
| 2895 | + $value = array(); |
|
| 2896 | + } |
|
| 2897 | 2897 | |
| 2898 | - $this->set_prop( 'discounts', $value ); |
|
| 2898 | + $this->set_prop( 'discounts', $value ); |
|
| 2899 | 2899 | } |
| 2900 | 2900 | |
| 2901 | 2901 | /** |
| 2902 | - * Set the invoice items. |
|
| 2903 | - * |
|
| 2904 | - * @since 1.0.19 |
|
| 2905 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2906 | - */ |
|
| 2907 | - public function set_items( $value ) { |
|
| 2902 | + * Set the invoice items. |
|
| 2903 | + * |
|
| 2904 | + * @since 1.0.19 |
|
| 2905 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2906 | + */ |
|
| 2907 | + public function set_items( $value ) { |
|
| 2908 | 2908 | |
| 2909 | 2909 | // Remove existing items. |
| 2910 | 2910 | $this->set_prop( 'items', array() ); |
| 2911 | - $this->recurring_item = null; |
|
| 2911 | + $this->recurring_item = null; |
|
| 2912 | 2912 | |
| 2913 | 2913 | // Ensure that we have an array. |
| 2914 | 2914 | if ( ! is_array( $value ) ) { |
@@ -2922,95 +2922,95 @@ discard block |
||
| 2922 | 2922 | } |
| 2923 | 2923 | |
| 2924 | 2924 | /** |
| 2925 | - * Set the payment form. |
|
| 2926 | - * |
|
| 2927 | - * @since 1.0.19 |
|
| 2928 | - * @param int $value payment form. |
|
| 2929 | - */ |
|
| 2930 | - public function set_payment_form( $value ) { |
|
| 2931 | - $this->set_prop( 'payment_form', $value ); |
|
| 2925 | + * Set the payment form. |
|
| 2926 | + * |
|
| 2927 | + * @since 1.0.19 |
|
| 2928 | + * @param int $value payment form. |
|
| 2929 | + */ |
|
| 2930 | + public function set_payment_form( $value ) { |
|
| 2931 | + $this->set_prop( 'payment_form', $value ); |
|
| 2932 | 2932 | } |
| 2933 | 2933 | |
| 2934 | 2934 | /** |
| 2935 | - * Set the submission id. |
|
| 2936 | - * |
|
| 2937 | - * @since 1.0.19 |
|
| 2938 | - * @param string $value submission id. |
|
| 2939 | - */ |
|
| 2940 | - public function set_submission_id( $value ) { |
|
| 2941 | - $this->set_prop( 'submission_id', $value ); |
|
| 2935 | + * Set the submission id. |
|
| 2936 | + * |
|
| 2937 | + * @since 1.0.19 |
|
| 2938 | + * @param string $value submission id. |
|
| 2939 | + */ |
|
| 2940 | + public function set_submission_id( $value ) { |
|
| 2941 | + $this->set_prop( 'submission_id', $value ); |
|
| 2942 | 2942 | } |
| 2943 | 2943 | |
| 2944 | 2944 | /** |
| 2945 | - * Set the discount code. |
|
| 2946 | - * |
|
| 2947 | - * @since 1.0.19 |
|
| 2948 | - * @param string $value discount code. |
|
| 2949 | - */ |
|
| 2950 | - public function set_discount_code( $value ) { |
|
| 2951 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
| 2945 | + * Set the discount code. |
|
| 2946 | + * |
|
| 2947 | + * @since 1.0.19 |
|
| 2948 | + * @param string $value discount code. |
|
| 2949 | + */ |
|
| 2950 | + public function set_discount_code( $value ) { |
|
| 2951 | + $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
| 2952 | 2952 | } |
| 2953 | 2953 | |
| 2954 | 2954 | /** |
| 2955 | - * Set the gateway. |
|
| 2956 | - * |
|
| 2957 | - * @since 1.0.19 |
|
| 2958 | - * @param string $value gateway. |
|
| 2959 | - */ |
|
| 2960 | - public function set_gateway( $value ) { |
|
| 2961 | - $this->set_prop( 'gateway', $value ); |
|
| 2955 | + * Set the gateway. |
|
| 2956 | + * |
|
| 2957 | + * @since 1.0.19 |
|
| 2958 | + * @param string $value gateway. |
|
| 2959 | + */ |
|
| 2960 | + public function set_gateway( $value ) { |
|
| 2961 | + $this->set_prop( 'gateway', $value ); |
|
| 2962 | 2962 | } |
| 2963 | 2963 | |
| 2964 | 2964 | /** |
| 2965 | - * Set the transaction id. |
|
| 2966 | - * |
|
| 2967 | - * @since 1.0.19 |
|
| 2968 | - * @param string $value transaction id. |
|
| 2969 | - */ |
|
| 2970 | - public function set_transaction_id( $value ) { |
|
| 2971 | - if ( ! empty( $value ) ) { |
|
| 2972 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2973 | - } |
|
| 2965 | + * Set the transaction id. |
|
| 2966 | + * |
|
| 2967 | + * @since 1.0.19 |
|
| 2968 | + * @param string $value transaction id. |
|
| 2969 | + */ |
|
| 2970 | + public function set_transaction_id( $value ) { |
|
| 2971 | + if ( ! empty( $value ) ) { |
|
| 2972 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2973 | + } |
|
| 2974 | 2974 | } |
| 2975 | 2975 | |
| 2976 | 2976 | /** |
| 2977 | - * Set the currency id. |
|
| 2978 | - * |
|
| 2979 | - * @since 1.0.19 |
|
| 2980 | - * @param string $value currency id. |
|
| 2981 | - */ |
|
| 2982 | - public function set_currency( $value ) { |
|
| 2983 | - $this->set_prop( 'currency', $value ); |
|
| 2977 | + * Set the currency id. |
|
| 2978 | + * |
|
| 2979 | + * @since 1.0.19 |
|
| 2980 | + * @param string $value currency id. |
|
| 2981 | + */ |
|
| 2982 | + public function set_currency( $value ) { |
|
| 2983 | + $this->set_prop( 'currency', $value ); |
|
| 2984 | 2984 | } |
| 2985 | 2985 | |
| 2986 | - /** |
|
| 2987 | - * Set whether to disable taxes. |
|
| 2988 | - * |
|
| 2989 | - * @since 1.0.19 |
|
| 2990 | - * @param bool $value value. |
|
| 2991 | - */ |
|
| 2992 | - public function set_disable_taxes( $value ) { |
|
| 2993 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2994 | - } |
|
| 2986 | + /** |
|
| 2987 | + * Set whether to disable taxes. |
|
| 2988 | + * |
|
| 2989 | + * @since 1.0.19 |
|
| 2990 | + * @param bool $value value. |
|
| 2991 | + */ |
|
| 2992 | + public function set_disable_taxes( $value ) { |
|
| 2993 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2994 | + } |
|
| 2995 | 2995 | |
| 2996 | 2996 | /** |
| 2997 | - * Set the subscription id. |
|
| 2998 | - * |
|
| 2999 | - * @since 1.0.19 |
|
| 3000 | - * @param string $value subscription id. |
|
| 3001 | - */ |
|
| 3002 | - public function set_subscription_id( $value ) { |
|
| 3003 | - $this->set_prop( 'subscription_id', $value ); |
|
| 3004 | - } |
|
| 2997 | + * Set the subscription id. |
|
| 2998 | + * |
|
| 2999 | + * @since 1.0.19 |
|
| 3000 | + * @param string $value subscription id. |
|
| 3001 | + */ |
|
| 3002 | + public function set_subscription_id( $value ) { |
|
| 3003 | + $this->set_prop( 'subscription_id', $value ); |
|
| 3004 | + } |
|
| 3005 | 3005 | |
| 3006 | - /** |
|
| 3007 | - * Set the remote subscription id. |
|
| 3008 | - * |
|
| 3009 | - * @since 1.0.19 |
|
| 3010 | - * @param string $value subscription id. |
|
| 3011 | - */ |
|
| 3012 | - public function set_remote_subscription_id( $value ) { |
|
| 3013 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 3006 | + /** |
|
| 3007 | + * Set the remote subscription id. |
|
| 3008 | + * |
|
| 3009 | + * @since 1.0.19 |
|
| 3010 | + * @param string $value subscription id. |
|
| 3011 | + */ |
|
| 3012 | + public function set_remote_subscription_id( $value ) { |
|
| 3013 | + $this->set_prop( 'remote_subscription_id', $value ); |
|
| 3014 | 3014 | } |
| 3015 | 3015 | |
| 3016 | 3016 | /* |
@@ -3049,24 +3049,24 @@ discard block |
||
| 3049 | 3049 | */ |
| 3050 | 3050 | public function is_taxable() { |
| 3051 | 3051 | return ! $this->get_disable_taxes(); |
| 3052 | - } |
|
| 3052 | + } |
|
| 3053 | 3053 | |
| 3054 | - /** |
|
| 3055 | - * @deprecated |
|
| 3056 | - */ |
|
| 3057 | - public function has_vat() { |
|
| 3054 | + /** |
|
| 3055 | + * @deprecated |
|
| 3056 | + */ |
|
| 3057 | + public function has_vat() { |
|
| 3058 | 3058 | return $this->is_taxable(); |
| 3059 | - } |
|
| 3059 | + } |
|
| 3060 | 3060 | |
| 3061 | - /** |
|
| 3062 | - * Checks to see if the invoice requires payment. |
|
| 3063 | - */ |
|
| 3064 | - public function is_free() { |
|
| 3061 | + /** |
|
| 3062 | + * Checks to see if the invoice requires payment. |
|
| 3063 | + */ |
|
| 3064 | + public function is_free() { |
|
| 3065 | 3065 | $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
| 3066 | 3066 | |
| 3067 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 3068 | - $is_free = false; |
|
| 3069 | - } |
|
| 3067 | + if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 3068 | + $is_free = false; |
|
| 3069 | + } |
|
| 3070 | 3070 | |
| 3071 | 3071 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 3072 | 3072 | } |
@@ -3077,46 +3077,46 @@ discard block |
||
| 3077 | 3077 | public function is_paid() { |
| 3078 | 3078 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 3079 | 3079 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 3080 | - } |
|
| 3080 | + } |
|
| 3081 | 3081 | |
| 3082 | - /** |
|
| 3082 | + /** |
|
| 3083 | 3083 | * Checks if the invoice needs payment. |
| 3084 | 3084 | */ |
| 3085 | - public function needs_payment() { |
|
| 3086 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3085 | + public function needs_payment() { |
|
| 3086 | + $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3087 | 3087 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 3088 | 3088 | } |
| 3089 | 3089 | |
| 3090 | - /** |
|
| 3090 | + /** |
|
| 3091 | 3091 | * Checks if the invoice is refunded. |
| 3092 | 3092 | */ |
| 3093 | - public function is_refunded() { |
|
| 3093 | + public function is_refunded() { |
|
| 3094 | 3094 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 3095 | 3095 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 3096 | - } |
|
| 3096 | + } |
|
| 3097 | 3097 | |
| 3098 | - /** |
|
| 3098 | + /** |
|
| 3099 | 3099 | * Checks if the invoice is held. |
| 3100 | 3100 | */ |
| 3101 | - public function is_held() { |
|
| 3101 | + public function is_held() { |
|
| 3102 | 3102 | $is_held = $this->has_status( 'wpi-onhold' ); |
| 3103 | 3103 | return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
| 3104 | - } |
|
| 3104 | + } |
|
| 3105 | 3105 | |
| 3106 | - /** |
|
| 3106 | + /** |
|
| 3107 | 3107 | * Checks if the invoice is due. |
| 3108 | 3108 | */ |
| 3109 | - public function is_due() { |
|
| 3110 | - $due_date = $this->get_due_date(); |
|
| 3111 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3112 | - } |
|
| 3109 | + public function is_due() { |
|
| 3110 | + $due_date = $this->get_due_date(); |
|
| 3111 | + return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3112 | + } |
|
| 3113 | 3113 | |
| 3114 | - /** |
|
| 3114 | + /** |
|
| 3115 | 3115 | * Checks if the invoice is draft. |
| 3116 | 3116 | */ |
| 3117 | - public function is_draft() { |
|
| 3117 | + public function is_draft() { |
|
| 3118 | 3118 | return $this->has_status( 'draft, auto-draft' ); |
| 3119 | - } |
|
| 3119 | + } |
|
| 3120 | 3120 | |
| 3121 | 3121 | /** |
| 3122 | 3122 | * Checks if the invoice has a given status. |
@@ -3124,9 +3124,9 @@ discard block |
||
| 3124 | 3124 | public function has_status( $status ) { |
| 3125 | 3125 | $status = wpinv_parse_list( $status ); |
| 3126 | 3126 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 3127 | - } |
|
| 3127 | + } |
|
| 3128 | 3128 | |
| 3129 | - /** |
|
| 3129 | + /** |
|
| 3130 | 3130 | * Checks if the invoice is of a given type. |
| 3131 | 3131 | */ |
| 3132 | 3132 | public function is_type( $type ) { |
@@ -3149,25 +3149,25 @@ discard block |
||
| 3149 | 3149 | */ |
| 3150 | 3150 | public function has_free_trial() { |
| 3151 | 3151 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 3152 | - } |
|
| 3152 | + } |
|
| 3153 | 3153 | |
| 3154 | - /** |
|
| 3154 | + /** |
|
| 3155 | 3155 | * @deprecated |
| 3156 | 3156 | */ |
| 3157 | 3157 | public function is_free_trial() { |
| 3158 | 3158 | $this->has_free_trial(); |
| 3159 | 3159 | } |
| 3160 | 3160 | |
| 3161 | - /** |
|
| 3161 | + /** |
|
| 3162 | 3162 | * Check if the initial payment if 0. |
| 3163 | 3163 | * |
| 3164 | 3164 | */ |
| 3165 | - public function is_initial_free() { |
|
| 3165 | + public function is_initial_free() { |
|
| 3166 | 3166 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 3167 | 3167 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 3168 | 3168 | } |
| 3169 | 3169 | |
| 3170 | - /** |
|
| 3170 | + /** |
|
| 3171 | 3171 | * Check if the recurring item has a free trial. |
| 3172 | 3172 | * |
| 3173 | 3173 | */ |
@@ -3180,21 +3180,21 @@ discard block |
||
| 3180 | 3180 | |
| 3181 | 3181 | $item = $this->get_recurring( true ); |
| 3182 | 3182 | return $item->has_free_trial(); |
| 3183 | - } |
|
| 3183 | + } |
|
| 3184 | 3184 | |
| 3185 | - /** |
|
| 3185 | + /** |
|
| 3186 | 3186 | * Check if the free trial is a result of a discount. |
| 3187 | 3187 | */ |
| 3188 | 3188 | public function is_free_trial_from_discount() { |
| 3189 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3190 | - } |
|
| 3189 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3190 | + } |
|
| 3191 | 3191 | |
| 3192 | - /** |
|
| 3192 | + /** |
|
| 3193 | 3193 | * @deprecated |
| 3194 | 3194 | */ |
| 3195 | 3195 | public function discount_first_payment_only() { |
| 3196 | 3196 | |
| 3197 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3197 | + $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3198 | 3198 | if ( ! $discount->exists() || ! $this->is_recurring() ) { |
| 3199 | 3199 | return true; |
| 3200 | 3200 | } |
@@ -3219,143 +3219,143 @@ discard block |
||
| 3219 | 3219 | */ |
| 3220 | 3220 | public function add_item( $item ) { |
| 3221 | 3221 | |
| 3222 | - if ( is_array( $item ) ) { |
|
| 3223 | - $item = $this->process_array_item( $item ); |
|
| 3224 | - } |
|
| 3222 | + if ( is_array( $item ) ) { |
|
| 3223 | + $item = $this->process_array_item( $item ); |
|
| 3224 | + } |
|
| 3225 | 3225 | |
| 3226 | - if ( is_numeric( $item ) ) { |
|
| 3227 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3228 | - } |
|
| 3226 | + if ( is_numeric( $item ) ) { |
|
| 3227 | + $item = new GetPaid_Form_Item( $item ); |
|
| 3228 | + } |
|
| 3229 | 3229 | |
| 3230 | 3230 | // Make sure that it is available for purchase. |
| 3231 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3232 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3231 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3232 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3233 | 3233 | } |
| 3234 | 3234 | |
| 3235 | 3235 | // Do we have a recurring item? |
| 3236 | - if ( $item->is_recurring() ) { |
|
| 3237 | - $this->recurring_item = $item->get_id(); |
|
| 3236 | + if ( $item->is_recurring() ) { |
|
| 3237 | + $this->recurring_item = $item->get_id(); |
|
| 3238 | 3238 | } |
| 3239 | 3239 | |
| 3240 | 3240 | // Invoice id. |
| 3241 | 3241 | $item->invoice_id = (int) $this->get_id(); |
| 3242 | 3242 | |
| 3243 | - // Remove duplicates. |
|
| 3244 | - $this->remove_item( $item->get_id() ); |
|
| 3243 | + // Remove duplicates. |
|
| 3244 | + $this->remove_item( $item->get_id() ); |
|
| 3245 | 3245 | |
| 3246 | - // Retrieve all items. |
|
| 3246 | + // Retrieve all items. |
|
| 3247 | 3247 | $items = $this->get_items(); |
| 3248 | 3248 | |
| 3249 | - // Add new item. |
|
| 3249 | + // Add new item. |
|
| 3250 | 3250 | $items[] = $item; |
| 3251 | 3251 | |
| 3252 | 3252 | $this->set_prop( 'items', $items ); |
| 3253 | 3253 | |
| 3254 | - return true; |
|
| 3255 | - } |
|
| 3254 | + return true; |
|
| 3255 | + } |
|
| 3256 | 3256 | |
| 3257 | - /** |
|
| 3258 | - * Converts an array to an item. |
|
| 3259 | - * |
|
| 3260 | - * @since 1.0.19 |
|
| 3261 | - * @return GetPaid_Form_Item |
|
| 3262 | - */ |
|
| 3263 | - protected function process_array_item( $array ) { |
|
| 3257 | + /** |
|
| 3258 | + * Converts an array to an item. |
|
| 3259 | + * |
|
| 3260 | + * @since 1.0.19 |
|
| 3261 | + * @return GetPaid_Form_Item |
|
| 3262 | + */ |
|
| 3263 | + protected function process_array_item( $array ) { |
|
| 3264 | 3264 | |
| 3265 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3266 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3265 | + $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3266 | + $item = new GetPaid_Form_Item( $item_id ); |
|
| 3267 | 3267 | |
| 3268 | - // Set item data. |
|
| 3269 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3270 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3271 | - $method = "set_$key"; |
|
| 3272 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3273 | - } |
|
| 3274 | - } |
|
| 3268 | + // Set item data. |
|
| 3269 | + foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3270 | + if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3271 | + $method = "set_$key"; |
|
| 3272 | + $item->$method( $array[ "item_$key" ] ); |
|
| 3273 | + } |
|
| 3274 | + } |
|
| 3275 | 3275 | |
| 3276 | - if ( isset( $array['quantity'] ) ) { |
|
| 3277 | - $item->set_quantity( $array['quantity'] ); |
|
| 3278 | - } |
|
| 3276 | + if ( isset( $array['quantity'] ) ) { |
|
| 3277 | + $item->set_quantity( $array['quantity'] ); |
|
| 3278 | + } |
|
| 3279 | 3279 | |
| 3280 | - // Set item meta. |
|
| 3281 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3282 | - $item->set_item_meta( $array['meta'] ); |
|
| 3283 | - } |
|
| 3280 | + // Set item meta. |
|
| 3281 | + if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3282 | + $item->set_item_meta( $array['meta'] ); |
|
| 3283 | + } |
|
| 3284 | 3284 | |
| 3285 | - return $item; |
|
| 3285 | + return $item; |
|
| 3286 | 3286 | |
| 3287 | - } |
|
| 3287 | + } |
|
| 3288 | 3288 | |
| 3289 | 3289 | /** |
| 3290 | - * Retrieves a specific item. |
|
| 3291 | - * |
|
| 3292 | - * @since 1.0.19 |
|
| 3293 | - * @return GetPaid_Form_Item|null |
|
| 3294 | - */ |
|
| 3295 | - public function get_item( $item_id ) { |
|
| 3290 | + * Retrieves a specific item. |
|
| 3291 | + * |
|
| 3292 | + * @since 1.0.19 |
|
| 3293 | + * @return GetPaid_Form_Item|null |
|
| 3294 | + */ |
|
| 3295 | + public function get_item( $item_id ) { |
|
| 3296 | 3296 | |
| 3297 | - foreach ( $this->get_items() as $item ) { |
|
| 3298 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3299 | - return $item; |
|
| 3300 | - } |
|
| 3301 | - } |
|
| 3297 | + foreach ( $this->get_items() as $item ) { |
|
| 3298 | + if ( (int) $item_id == $item->get_id() ) { |
|
| 3299 | + return $item; |
|
| 3300 | + } |
|
| 3301 | + } |
|
| 3302 | 3302 | |
| 3303 | - return null; |
|
| 3303 | + return null; |
|
| 3304 | 3304 | } |
| 3305 | 3305 | |
| 3306 | 3306 | /** |
| 3307 | - * Removes a specific item. |
|
| 3308 | - * |
|
| 3309 | - * @since 1.0.19 |
|
| 3310 | - */ |
|
| 3311 | - public function remove_item( $item_id ) { |
|
| 3312 | - $items = $this->get_items(); |
|
| 3313 | - $item_id = (int) $item_id; |
|
| 3307 | + * Removes a specific item. |
|
| 3308 | + * |
|
| 3309 | + * @since 1.0.19 |
|
| 3310 | + */ |
|
| 3311 | + public function remove_item( $item_id ) { |
|
| 3312 | + $items = $this->get_items(); |
|
| 3313 | + $item_id = (int) $item_id; |
|
| 3314 | 3314 | |
| 3315 | - foreach ( $items as $index => $item ) { |
|
| 3316 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3317 | - unset( $items[ $index ] ); |
|
| 3318 | - $this->set_prop( 'items', $items ); |
|
| 3315 | + foreach ( $items as $index => $item ) { |
|
| 3316 | + if ( (int) $item_id == $item->get_id() ) { |
|
| 3317 | + unset( $items[ $index ] ); |
|
| 3318 | + $this->set_prop( 'items', $items ); |
|
| 3319 | 3319 | |
| 3320 | - if ( $item_id == $this->recurring_item ) { |
|
| 3321 | - $this->recurring_item = null; |
|
| 3322 | - } |
|
| 3320 | + if ( $item_id == $this->recurring_item ) { |
|
| 3321 | + $this->recurring_item = null; |
|
| 3322 | + } |
|
| 3323 | 3323 | |
| 3324 | - } |
|
| 3325 | - } |
|
| 3324 | + } |
|
| 3325 | + } |
|
| 3326 | 3326 | |
| 3327 | 3327 | } |
| 3328 | 3328 | |
| 3329 | 3329 | /** |
| 3330 | - * Adds a fee to the invoice. |
|
| 3331 | - * |
|
| 3332 | - * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3333 | - * @since 1.0.19 |
|
| 3334 | - */ |
|
| 3330 | + * Adds a fee to the invoice. |
|
| 3331 | + * |
|
| 3332 | + * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3333 | + * @since 1.0.19 |
|
| 3334 | + */ |
|
| 3335 | 3335 | public function add_fee( $fee ) { |
| 3336 | 3336 | |
| 3337 | - $fees = $this->get_fees(); |
|
| 3338 | - $fees[ $fee['name'] ] = $fee; |
|
| 3339 | - $this->set_prop( 'fees', $fees ); |
|
| 3337 | + $fees = $this->get_fees(); |
|
| 3338 | + $fees[ $fee['name'] ] = $fee; |
|
| 3339 | + $this->set_prop( 'fees', $fees ); |
|
| 3340 | 3340 | |
| 3341 | 3341 | } |
| 3342 | 3342 | |
| 3343 | 3343 | /** |
| 3344 | - * Retrieves a specific fee. |
|
| 3345 | - * |
|
| 3346 | - * @since 1.0.19 |
|
| 3347 | - */ |
|
| 3348 | - public function get_fee( $fee ) { |
|
| 3344 | + * Retrieves a specific fee. |
|
| 3345 | + * |
|
| 3346 | + * @since 1.0.19 |
|
| 3347 | + */ |
|
| 3348 | + public function get_fee( $fee ) { |
|
| 3349 | 3349 | $fees = $this->get_fees(); |
| 3350 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3350 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3351 | 3351 | } |
| 3352 | 3352 | |
| 3353 | 3353 | /** |
| 3354 | - * Removes a specific fee. |
|
| 3355 | - * |
|
| 3356 | - * @since 1.0.19 |
|
| 3357 | - */ |
|
| 3358 | - public function remove_fee( $fee ) { |
|
| 3354 | + * Removes a specific fee. |
|
| 3355 | + * |
|
| 3356 | + * @since 1.0.19 |
|
| 3357 | + */ |
|
| 3358 | + public function remove_fee( $fee ) { |
|
| 3359 | 3359 | $fees = $this->get_fees(); |
| 3360 | 3360 | if ( isset( $fees[ $fee ] ) ) { |
| 3361 | 3361 | unset( $fees[ $fee ] ); |
@@ -3363,55 +3363,55 @@ discard block |
||
| 3363 | 3363 | } |
| 3364 | 3364 | } |
| 3365 | 3365 | |
| 3366 | - /** |
|
| 3367 | - * Adds a discount to the invoice. |
|
| 3368 | - * |
|
| 3369 | - * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3370 | - * @since 1.0.19 |
|
| 3371 | - */ |
|
| 3372 | - public function add_discount( $discount ) { |
|
| 3366 | + /** |
|
| 3367 | + * Adds a discount to the invoice. |
|
| 3368 | + * |
|
| 3369 | + * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3370 | + * @since 1.0.19 |
|
| 3371 | + */ |
|
| 3372 | + public function add_discount( $discount ) { |
|
| 3373 | 3373 | |
| 3374 | - $discounts = $this->get_discounts(); |
|
| 3375 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3376 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3374 | + $discounts = $this->get_discounts(); |
|
| 3375 | + $discounts[ $discount['name'] ] = $discount; |
|
| 3376 | + $this->set_prop( 'discounts', $discounts ); |
|
| 3377 | 3377 | |
| 3378 | - } |
|
| 3378 | + } |
|
| 3379 | 3379 | |
| 3380 | 3380 | /** |
| 3381 | - * Retrieves a specific discount. |
|
| 3382 | - * |
|
| 3383 | - * @since 1.0.19 |
|
| 3384 | - * @return float |
|
| 3385 | - */ |
|
| 3386 | - public function get_discount( $discount = false ) { |
|
| 3381 | + * Retrieves a specific discount. |
|
| 3382 | + * |
|
| 3383 | + * @since 1.0.19 |
|
| 3384 | + * @return float |
|
| 3385 | + */ |
|
| 3386 | + public function get_discount( $discount = false ) { |
|
| 3387 | 3387 | |
| 3388 | - // Backwards compatibilty. |
|
| 3389 | - if ( empty( $discount ) ) { |
|
| 3390 | - return $this->get_total_discount(); |
|
| 3391 | - } |
|
| 3388 | + // Backwards compatibilty. |
|
| 3389 | + if ( empty( $discount ) ) { |
|
| 3390 | + return $this->get_total_discount(); |
|
| 3391 | + } |
|
| 3392 | 3392 | |
| 3393 | 3393 | $discounts = $this->get_discounts(); |
| 3394 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3394 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3395 | 3395 | } |
| 3396 | 3396 | |
| 3397 | 3397 | /** |
| 3398 | - * Removes a specific discount. |
|
| 3399 | - * |
|
| 3400 | - * @since 1.0.19 |
|
| 3401 | - */ |
|
| 3402 | - public function remove_discount( $discount ) { |
|
| 3398 | + * Removes a specific discount. |
|
| 3399 | + * |
|
| 3400 | + * @since 1.0.19 |
|
| 3401 | + */ |
|
| 3402 | + public function remove_discount( $discount ) { |
|
| 3403 | 3403 | $discounts = $this->get_discounts(); |
| 3404 | 3404 | if ( isset( $discounts[ $discount ] ) ) { |
| 3405 | 3405 | unset( $discounts[ $discount ] ); |
| 3406 | 3406 | $this->set_prop( 'discounts', $discounts ); |
| 3407 | 3407 | } |
| 3408 | 3408 | |
| 3409 | - if ( 'discount_code' == $discount ) { |
|
| 3410 | - foreach ( $this->get_items() as $item ) { |
|
| 3411 | - $item->item_discount = 0; |
|
| 3412 | - $item->recurring_item_discount = 0; |
|
| 3413 | - } |
|
| 3414 | - } |
|
| 3409 | + if ( 'discount_code' == $discount ) { |
|
| 3410 | + foreach ( $this->get_items() as $item ) { |
|
| 3411 | + $item->item_discount = 0; |
|
| 3412 | + $item->recurring_item_discount = 0; |
|
| 3413 | + } |
|
| 3414 | + } |
|
| 3415 | 3415 | |
| 3416 | 3416 | } |
| 3417 | 3417 | |
@@ -3424,34 +3424,34 @@ discard block |
||
| 3424 | 3424 | if ( $this->is_taxable() ) { |
| 3425 | 3425 | |
| 3426 | 3426 | $taxes = $this->get_taxes(); |
| 3427 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3428 | - $this->set_prop( 'taxes', $tax ); |
|
| 3427 | + $taxes[ $tax['name'] ] = $tax; |
|
| 3428 | + $this->set_prop( 'taxes', $tax ); |
|
| 3429 | 3429 | |
| 3430 | 3430 | } |
| 3431 | 3431 | } |
| 3432 | 3432 | |
| 3433 | 3433 | /** |
| 3434 | - * Retrieves a specific tax. |
|
| 3435 | - * |
|
| 3436 | - * @since 1.0.19 |
|
| 3437 | - */ |
|
| 3438 | - public function get_tax( $tax = null ) { |
|
| 3434 | + * Retrieves a specific tax. |
|
| 3435 | + * |
|
| 3436 | + * @since 1.0.19 |
|
| 3437 | + */ |
|
| 3438 | + public function get_tax( $tax = null ) { |
|
| 3439 | 3439 | |
| 3440 | - // Backwards compatility. |
|
| 3441 | - if ( empty( $tax ) ) { |
|
| 3442 | - return $this->get_total_tax(); |
|
| 3443 | - } |
|
| 3440 | + // Backwards compatility. |
|
| 3441 | + if ( empty( $tax ) ) { |
|
| 3442 | + return $this->get_total_tax(); |
|
| 3443 | + } |
|
| 3444 | 3444 | |
| 3445 | 3445 | $taxes = $this->get_taxes(); |
| 3446 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3446 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3447 | 3447 | } |
| 3448 | 3448 | |
| 3449 | 3449 | /** |
| 3450 | - * Removes a specific tax. |
|
| 3451 | - * |
|
| 3452 | - * @since 1.0.19 |
|
| 3453 | - */ |
|
| 3454 | - public function remove_tax( $tax ) { |
|
| 3450 | + * Removes a specific tax. |
|
| 3451 | + * |
|
| 3452 | + * @since 1.0.19 |
|
| 3453 | + */ |
|
| 3454 | + public function remove_tax( $tax ) { |
|
| 3455 | 3455 | $taxes = $this->get_taxes(); |
| 3456 | 3456 | if ( isset( $taxes[ $tax ] ) ) { |
| 3457 | 3457 | unset( $taxes[ $tax ] ); |
@@ -3460,185 +3460,185 @@ discard block |
||
| 3460 | 3460 | } |
| 3461 | 3461 | |
| 3462 | 3462 | /** |
| 3463 | - * Recalculates the invoice subtotal. |
|
| 3464 | - * |
|
| 3465 | - * @since 1.0.19 |
|
| 3466 | - * @return float The recalculated subtotal |
|
| 3467 | - */ |
|
| 3468 | - public function recalculate_subtotal() { |
|
| 3463 | + * Recalculates the invoice subtotal. |
|
| 3464 | + * |
|
| 3465 | + * @since 1.0.19 |
|
| 3466 | + * @return float The recalculated subtotal |
|
| 3467 | + */ |
|
| 3468 | + public function recalculate_subtotal() { |
|
| 3469 | 3469 | $items = $this->get_items(); |
| 3470 | - $subtotal = 0; |
|
| 3471 | - $recurring = 0; |
|
| 3470 | + $subtotal = 0; |
|
| 3471 | + $recurring = 0; |
|
| 3472 | 3472 | |
| 3473 | 3473 | foreach ( $items as $item ) { |
| 3474 | - $subtotal += $item->get_sub_total(); |
|
| 3475 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3474 | + $subtotal += $item->get_sub_total(); |
|
| 3475 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3476 | 3476 | } |
| 3477 | 3477 | |
| 3478 | - if ( wpinv_prices_include_tax() ) { |
|
| 3479 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
| 3480 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
| 3481 | - } |
|
| 3478 | + if ( wpinv_prices_include_tax() ) { |
|
| 3479 | + $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
| 3480 | + $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
| 3481 | + } |
|
| 3482 | 3482 | |
| 3483 | - $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3484 | - $this->set_subtotal( $current ); |
|
| 3483 | + $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3484 | + $this->set_subtotal( $current ); |
|
| 3485 | 3485 | |
| 3486 | - $this->totals['subtotal'] = array( |
|
| 3487 | - 'initial' => $subtotal, |
|
| 3488 | - 'recurring' => $recurring, |
|
| 3489 | - ); |
|
| 3486 | + $this->totals['subtotal'] = array( |
|
| 3487 | + 'initial' => $subtotal, |
|
| 3488 | + 'recurring' => $recurring, |
|
| 3489 | + ); |
|
| 3490 | 3490 | |
| 3491 | 3491 | return $current; |
| 3492 | 3492 | } |
| 3493 | 3493 | |
| 3494 | 3494 | /** |
| 3495 | - * Recalculates the invoice discount total. |
|
| 3496 | - * |
|
| 3497 | - * @since 1.0.19 |
|
| 3498 | - * @return float The recalculated discount |
|
| 3499 | - */ |
|
| 3500 | - public function recalculate_total_discount() { |
|
| 3495 | + * Recalculates the invoice discount total. |
|
| 3496 | + * |
|
| 3497 | + * @since 1.0.19 |
|
| 3498 | + * @return float The recalculated discount |
|
| 3499 | + */ |
|
| 3500 | + public function recalculate_total_discount() { |
|
| 3501 | 3501 | $discounts = $this->get_discounts(); |
| 3502 | - $discount = 0; |
|
| 3503 | - $recurring = 0; |
|
| 3502 | + $discount = 0; |
|
| 3503 | + $recurring = 0; |
|
| 3504 | 3504 | |
| 3505 | 3505 | foreach ( $discounts as $data ) { |
| 3506 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3507 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3508 | - } |
|
| 3506 | + $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3507 | + $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3508 | + } |
|
| 3509 | 3509 | |
| 3510 | - $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3510 | + $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3511 | 3511 | |
| 3512 | - $this->set_total_discount( $current ); |
|
| 3512 | + $this->set_total_discount( $current ); |
|
| 3513 | 3513 | |
| 3514 | - $this->totals['discount'] = array( |
|
| 3515 | - 'initial' => $discount, |
|
| 3516 | - 'recurring' => $recurring, |
|
| 3517 | - ); |
|
| 3514 | + $this->totals['discount'] = array( |
|
| 3515 | + 'initial' => $discount, |
|
| 3516 | + 'recurring' => $recurring, |
|
| 3517 | + ); |
|
| 3518 | 3518 | |
| 3519 | - return $current; |
|
| 3519 | + return $current; |
|
| 3520 | 3520 | |
| 3521 | 3521 | } |
| 3522 | 3522 | |
| 3523 | 3523 | /** |
| 3524 | - * Recalculates the invoice tax total. |
|
| 3525 | - * |
|
| 3526 | - * @since 1.0.19 |
|
| 3527 | - * @return float The recalculated tax |
|
| 3528 | - */ |
|
| 3529 | - public function recalculate_total_tax() { |
|
| 3524 | + * Recalculates the invoice tax total. |
|
| 3525 | + * |
|
| 3526 | + * @since 1.0.19 |
|
| 3527 | + * @return float The recalculated tax |
|
| 3528 | + */ |
|
| 3529 | + public function recalculate_total_tax() { |
|
| 3530 | 3530 | |
| 3531 | - // Maybe disable taxes. |
|
| 3532 | - $vat_number = $this->get_vat_number(); |
|
| 3533 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
| 3531 | + // Maybe disable taxes. |
|
| 3532 | + $vat_number = $this->get_vat_number(); |
|
| 3533 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
| 3534 | 3534 | |
| 3535 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 3536 | - $skip_tax = false; |
|
| 3537 | - } |
|
| 3535 | + if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 3536 | + $skip_tax = false; |
|
| 3537 | + } |
|
| 3538 | 3538 | |
| 3539 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
| 3539 | + if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
| 3540 | 3540 | |
| 3541 | - $this->totals['tax'] = array( |
|
| 3542 | - 'initial' => 0, |
|
| 3543 | - 'recurring' => 0, |
|
| 3544 | - ); |
|
| 3541 | + $this->totals['tax'] = array( |
|
| 3542 | + 'initial' => 0, |
|
| 3543 | + 'recurring' => 0, |
|
| 3544 | + ); |
|
| 3545 | 3545 | |
| 3546 | - $this->tax_rate = 0; |
|
| 3546 | + $this->tax_rate = 0; |
|
| 3547 | 3547 | |
| 3548 | - $this->set_taxes( array() ); |
|
| 3549 | - $current = 0; |
|
| 3550 | - } else { |
|
| 3548 | + $this->set_taxes( array() ); |
|
| 3549 | + $current = 0; |
|
| 3550 | + } else { |
|
| 3551 | 3551 | |
| 3552 | - $item_taxes = array(); |
|
| 3552 | + $item_taxes = array(); |
|
| 3553 | 3553 | |
| 3554 | - foreach ( $this->get_items() as $item ) { |
|
| 3555 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
| 3556 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 3557 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 3558 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 3559 | - foreach ( $taxes as $name => $amount ) { |
|
| 3560 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 3561 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 3554 | + foreach ( $this->get_items() as $item ) { |
|
| 3555 | + $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
| 3556 | + $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 3557 | + $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 3558 | + $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 3559 | + foreach ( $taxes as $name => $amount ) { |
|
| 3560 | + $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 3561 | + $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 3562 | 3562 | |
| 3563 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
| 3564 | - $item_taxes[ $name ] = $tax; |
|
| 3565 | - continue; |
|
| 3566 | - } |
|
| 3563 | + if ( ! isset( $item_taxes[ $name ] ) ) { |
|
| 3564 | + $item_taxes[ $name ] = $tax; |
|
| 3565 | + continue; |
|
| 3566 | + } |
|
| 3567 | 3567 | |
| 3568 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 3569 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3568 | + $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 3569 | + $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3570 | 3570 | |
| 3571 | - } |
|
| 3571 | + } |
|
| 3572 | 3572 | |
| 3573 | - } |
|
| 3573 | + } |
|
| 3574 | 3574 | |
| 3575 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
| 3576 | - $this->set_taxes( $item_taxes ); |
|
| 3575 | + $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
| 3576 | + $this->set_taxes( $item_taxes ); |
|
| 3577 | 3577 | |
| 3578 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
| 3579 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
| 3578 | + $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
| 3579 | + $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
| 3580 | 3580 | |
| 3581 | - $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
|
| 3581 | + $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
|
| 3582 | 3582 | |
| 3583 | - $this->totals['tax'] = array( |
|
| 3584 | - 'initial' => $initial_tax, |
|
| 3585 | - 'recurring' => $recurring_tax, |
|
| 3586 | - ); |
|
| 3583 | + $this->totals['tax'] = array( |
|
| 3584 | + 'initial' => $initial_tax, |
|
| 3585 | + 'recurring' => $recurring_tax, |
|
| 3586 | + ); |
|
| 3587 | 3587 | |
| 3588 | - } |
|
| 3588 | + } |
|
| 3589 | 3589 | |
| 3590 | - $this->set_total_tax( $current ); |
|
| 3590 | + $this->set_total_tax( $current ); |
|
| 3591 | 3591 | |
| 3592 | - return $current; |
|
| 3592 | + return $current; |
|
| 3593 | 3593 | |
| 3594 | 3594 | } |
| 3595 | 3595 | |
| 3596 | 3596 | /** |
| 3597 | - * Recalculates the invoice fees total. |
|
| 3598 | - * |
|
| 3599 | - * @since 1.0.19 |
|
| 3600 | - * @return float The recalculated fee |
|
| 3601 | - */ |
|
| 3602 | - public function recalculate_total_fees() { |
|
| 3603 | - $fees = $this->get_fees(); |
|
| 3604 | - $fee = 0; |
|
| 3605 | - $recurring = 0; |
|
| 3597 | + * Recalculates the invoice fees total. |
|
| 3598 | + * |
|
| 3599 | + * @since 1.0.19 |
|
| 3600 | + * @return float The recalculated fee |
|
| 3601 | + */ |
|
| 3602 | + public function recalculate_total_fees() { |
|
| 3603 | + $fees = $this->get_fees(); |
|
| 3604 | + $fee = 0; |
|
| 3605 | + $recurring = 0; |
|
| 3606 | 3606 | |
| 3607 | 3607 | foreach ( $fees as $data ) { |
| 3608 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3609 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3610 | - } |
|
| 3608 | + $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3609 | + $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3610 | + } |
|
| 3611 | 3611 | |
| 3612 | - $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3613 | - $this->set_total_fees( $current ); |
|
| 3612 | + $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3613 | + $this->set_total_fees( $current ); |
|
| 3614 | 3614 | |
| 3615 | - $this->totals['fee'] = array( |
|
| 3616 | - 'initial' => $fee, |
|
| 3617 | - 'recurring' => $recurring, |
|
| 3618 | - ); |
|
| 3615 | + $this->totals['fee'] = array( |
|
| 3616 | + 'initial' => $fee, |
|
| 3617 | + 'recurring' => $recurring, |
|
| 3618 | + ); |
|
| 3619 | 3619 | |
| 3620 | 3620 | $this->set_total_fees( $fee ); |
| 3621 | 3621 | return $current; |
| 3622 | 3622 | } |
| 3623 | 3623 | |
| 3624 | 3624 | /** |
| 3625 | - * Recalculates the invoice total. |
|
| 3626 | - * |
|
| 3627 | - * @since 1.0.19 |
|
| 3625 | + * Recalculates the invoice total. |
|
| 3626 | + * |
|
| 3627 | + * @since 1.0.19 |
|
| 3628 | 3628 | * @return float The invoice total |
| 3629 | - */ |
|
| 3630 | - public function recalculate_total() { |
|
| 3629 | + */ |
|
| 3630 | + public function recalculate_total() { |
|
| 3631 | 3631 | $this->recalculate_total_fees(); |
| 3632 | 3632 | $this->recalculate_total_discount(); |
| 3633 | - $this->recalculate_total_tax(); |
|
| 3634 | - $this->recalculate_subtotal(); |
|
| 3635 | - $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() ); |
|
| 3636 | - return $this->get_total(); |
|
| 3637 | - } |
|
| 3638 | - |
|
| 3639 | - /** |
|
| 3640 | - * @deprecated |
|
| 3641 | - */ |
|
| 3633 | + $this->recalculate_total_tax(); |
|
| 3634 | + $this->recalculate_subtotal(); |
|
| 3635 | + $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() ); |
|
| 3636 | + return $this->get_total(); |
|
| 3637 | + } |
|
| 3638 | + |
|
| 3639 | + /** |
|
| 3640 | + * @deprecated |
|
| 3641 | + */ |
|
| 3642 | 3642 | public function recalculate_totals() { |
| 3643 | 3643 | $this->recalculate_total(); |
| 3644 | 3644 | $this->save( true ); |
@@ -3656,7 +3656,7 @@ discard block |
||
| 3656 | 3656 | * Adds a note to an invoice. |
| 3657 | 3657 | * |
| 3658 | 3658 | * @param string $note The note being added. |
| 3659 | - * @return int|false The new note's ID on success, false on failure. |
|
| 3659 | + * @return int|false The new note's ID on success, false on failure. |
|
| 3660 | 3660 | * |
| 3661 | 3661 | */ |
| 3662 | 3662 | public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
@@ -3666,21 +3666,21 @@ discard block |
||
| 3666 | 3666 | return false; |
| 3667 | 3667 | } |
| 3668 | 3668 | |
| 3669 | - $author = 'System'; |
|
| 3670 | - $author_email = '[email protected]'; |
|
| 3669 | + $author = 'System'; |
|
| 3670 | + $author_email = '[email protected]'; |
|
| 3671 | 3671 | |
| 3672 | - // If this is an admin comment or it has been added by the user. |
|
| 3673 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3674 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3672 | + // If this is an admin comment or it has been added by the user. |
|
| 3673 | + if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3674 | + $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3675 | 3675 | $author = $user->display_name; |
| 3676 | 3676 | $author_email = $user->user_email; |
| 3677 | - } |
|
| 3677 | + } |
|
| 3678 | 3678 | |
| 3679 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3679 | + return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3680 | 3680 | |
| 3681 | - } |
|
| 3681 | + } |
|
| 3682 | 3682 | |
| 3683 | - /** |
|
| 3683 | + /** |
|
| 3684 | 3684 | * Generates a unique key for the invoice. |
| 3685 | 3685 | */ |
| 3686 | 3686 | public function generate_key( $string = '' ) { |
@@ -3700,113 +3700,113 @@ discard block |
||
| 3700 | 3700 | $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
| 3701 | 3701 | } |
| 3702 | 3702 | |
| 3703 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3704 | - |
|
| 3705 | - } |
|
| 3706 | - |
|
| 3707 | - /** |
|
| 3708 | - * Handle the status transition. |
|
| 3709 | - */ |
|
| 3710 | - protected function status_transition() { |
|
| 3711 | - $status_transition = $this->status_transition; |
|
| 3712 | - |
|
| 3713 | - // Reset status transition variable. |
|
| 3714 | - $this->status_transition = false; |
|
| 3703 | + return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3715 | 3704 | |
| 3716 | - if ( $status_transition ) { |
|
| 3717 | - try { |
|
| 3718 | - |
|
| 3719 | - // Fire a hook for the status change. |
|
| 3720 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3721 | - |
|
| 3722 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3723 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3724 | - |
|
| 3725 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3726 | - |
|
| 3727 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3728 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3729 | - |
|
| 3730 | - // Fire another hook. |
|
| 3731 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3732 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3733 | - |
|
| 3734 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3735 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3736 | - |
|
| 3737 | - // Note the transition occurred. |
|
| 3738 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3739 | - |
|
| 3740 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3741 | - if ( |
|
| 3742 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3743 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3744 | - ) { |
|
| 3745 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3746 | - } |
|
| 3747 | - |
|
| 3748 | - // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3749 | - if ( |
|
| 3750 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3751 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3752 | - ) { |
|
| 3753 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3754 | - } |
|
| 3755 | - } else { |
|
| 3756 | - /* translators: %s: new invoice status */ |
|
| 3757 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3758 | - |
|
| 3759 | - // Note the transition occurred. |
|
| 3760 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3705 | + } |
|
| 3761 | 3706 | |
| 3762 | - } |
|
| 3763 | - } catch ( Exception $e ) { |
|
| 3764 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3765 | - } |
|
| 3766 | - } |
|
| 3767 | - } |
|
| 3707 | + /** |
|
| 3708 | + * Handle the status transition. |
|
| 3709 | + */ |
|
| 3710 | + protected function status_transition() { |
|
| 3711 | + $status_transition = $this->status_transition; |
|
| 3712 | + |
|
| 3713 | + // Reset status transition variable. |
|
| 3714 | + $this->status_transition = false; |
|
| 3715 | + |
|
| 3716 | + if ( $status_transition ) { |
|
| 3717 | + try { |
|
| 3718 | + |
|
| 3719 | + // Fire a hook for the status change. |
|
| 3720 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3721 | + |
|
| 3722 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3723 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3724 | + |
|
| 3725 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3726 | + |
|
| 3727 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3728 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3729 | + |
|
| 3730 | + // Fire another hook. |
|
| 3731 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3732 | + do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3733 | + |
|
| 3734 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3735 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3736 | + |
|
| 3737 | + // Note the transition occurred. |
|
| 3738 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3739 | + |
|
| 3740 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3741 | + if ( |
|
| 3742 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3743 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3744 | + ) { |
|
| 3745 | + do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3746 | + } |
|
| 3747 | + |
|
| 3748 | + // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3749 | + if ( |
|
| 3750 | + in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3751 | + && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3752 | + ) { |
|
| 3753 | + do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3754 | + } |
|
| 3755 | + } else { |
|
| 3756 | + /* translators: %s: new invoice status */ |
|
| 3757 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3758 | + |
|
| 3759 | + // Note the transition occurred. |
|
| 3760 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3761 | + |
|
| 3762 | + } |
|
| 3763 | + } catch ( Exception $e ) { |
|
| 3764 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3765 | + } |
|
| 3766 | + } |
|
| 3767 | + } |
|
| 3768 | 3768 | |
| 3769 | - /** |
|
| 3770 | - * Updates an invoice status. |
|
| 3771 | - */ |
|
| 3772 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3769 | + /** |
|
| 3770 | + * Updates an invoice status. |
|
| 3771 | + */ |
|
| 3772 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3773 | 3773 | |
| 3774 | - // Fires before updating a status. |
|
| 3775 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3774 | + // Fires before updating a status. |
|
| 3775 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3776 | 3776 | |
| 3777 | - // Update the status. |
|
| 3778 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3777 | + // Update the status. |
|
| 3778 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3779 | 3779 | |
| 3780 | - // Save the order. |
|
| 3781 | - return $this->save(); |
|
| 3780 | + // Save the order. |
|
| 3781 | + return $this->save(); |
|
| 3782 | 3782 | |
| 3783 | - } |
|
| 3783 | + } |
|
| 3784 | 3784 | |
| 3785 | - /** |
|
| 3786 | - * @deprecated |
|
| 3787 | - */ |
|
| 3788 | - public function refresh_item_ids() { |
|
| 3785 | + /** |
|
| 3786 | + * @deprecated |
|
| 3787 | + */ |
|
| 3788 | + public function refresh_item_ids() { |
|
| 3789 | 3789 | $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
| 3790 | 3790 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3791 | - } |
|
| 3791 | + } |
|
| 3792 | 3792 | |
| 3793 | - /** |
|
| 3794 | - * @deprecated |
|
| 3795 | - */ |
|
| 3796 | - public function update_items( $temp = false ) { |
|
| 3793 | + /** |
|
| 3794 | + * @deprecated |
|
| 3795 | + */ |
|
| 3796 | + public function update_items( $temp = false ) { |
|
| 3797 | 3797 | |
| 3798 | - $this->set_items( $this->get_items() ); |
|
| 3798 | + $this->set_items( $this->get_items() ); |
|
| 3799 | 3799 | |
| 3800 | - if ( ! $temp ) { |
|
| 3801 | - $this->save(); |
|
| 3802 | - } |
|
| 3800 | + if ( ! $temp ) { |
|
| 3801 | + $this->save(); |
|
| 3802 | + } |
|
| 3803 | 3803 | |
| 3804 | 3804 | return $this; |
| 3805 | - } |
|
| 3805 | + } |
|
| 3806 | 3806 | |
| 3807 | - /** |
|
| 3808 | - * @deprecated |
|
| 3809 | - */ |
|
| 3807 | + /** |
|
| 3808 | + * @deprecated |
|
| 3809 | + */ |
|
| 3810 | 3810 | public function validate_discount() { |
| 3811 | 3811 | |
| 3812 | 3812 | $discount_code = $this->get_discount_code(); |
@@ -3822,93 +3822,93 @@ discard block |
||
| 3822 | 3822 | |
| 3823 | 3823 | } |
| 3824 | 3824 | |
| 3825 | - /** |
|
| 3826 | - * Refunds an invoice. |
|
| 3827 | - */ |
|
| 3825 | + /** |
|
| 3826 | + * Refunds an invoice. |
|
| 3827 | + */ |
|
| 3828 | 3828 | public function refund() { |
| 3829 | - $this->set_status( 'wpi-refunded' ); |
|
| 3829 | + $this->set_status( 'wpi-refunded' ); |
|
| 3830 | 3830 | $this->save(); |
| 3831 | - } |
|
| 3831 | + } |
|
| 3832 | 3832 | |
| 3833 | - /** |
|
| 3834 | - * Marks an invoice as paid. |
|
| 3835 | - * |
|
| 3836 | - * @param string $transaction_id |
|
| 3837 | - */ |
|
| 3833 | + /** |
|
| 3834 | + * Marks an invoice as paid. |
|
| 3835 | + * |
|
| 3836 | + * @param string $transaction_id |
|
| 3837 | + */ |
|
| 3838 | 3838 | public function mark_paid( $transaction_id = null, $note = '' ) { |
| 3839 | 3839 | |
| 3840 | - // Set the transaction id. |
|
| 3841 | - if ( empty( $transaction_id ) ) { |
|
| 3842 | - $transaction_id = $this->generate_key('trans_'); |
|
| 3843 | - } |
|
| 3840 | + // Set the transaction id. |
|
| 3841 | + if ( empty( $transaction_id ) ) { |
|
| 3842 | + $transaction_id = $this->generate_key('trans_'); |
|
| 3843 | + } |
|
| 3844 | 3844 | |
| 3845 | - if ( ! $this->get_transaction_id() ) { |
|
| 3846 | - $this->set_transaction_id( $transaction_id ); |
|
| 3847 | - } |
|
| 3845 | + if ( ! $this->get_transaction_id() ) { |
|
| 3846 | + $this->set_transaction_id( $transaction_id ); |
|
| 3847 | + } |
|
| 3848 | 3848 | |
| 3849 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3850 | - return $this->save(); |
|
| 3851 | - } |
|
| 3849 | + if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3850 | + return $this->save(); |
|
| 3851 | + } |
|
| 3852 | 3852 | |
| 3853 | - // Set the completed date. |
|
| 3854 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3853 | + // Set the completed date. |
|
| 3854 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3855 | 3855 | |
| 3856 | - // Set the new status. |
|
| 3857 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
| 3858 | - if ( $this->is_renewal() ) { |
|
| 3856 | + // Set the new status. |
|
| 3857 | + $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
| 3858 | + if ( $this->is_renewal() ) { |
|
| 3859 | 3859 | |
| 3860 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
| 3861 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3860 | + $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
| 3861 | + $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3862 | 3862 | |
| 3863 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3864 | - $_note = $note; |
|
| 3865 | - } |
|
| 3863 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3864 | + $_note = $note; |
|
| 3865 | + } |
|
| 3866 | 3866 | |
| 3867 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3867 | + $this->set_status( 'wpi-renewal', $_note ); |
|
| 3868 | 3868 | |
| 3869 | - } else { |
|
| 3869 | + } else { |
|
| 3870 | 3870 | |
| 3871 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 3872 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3871 | + $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 3872 | + $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3873 | 3873 | |
| 3874 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3875 | - $_note = $note; |
|
| 3876 | - } |
|
| 3874 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3875 | + $_note = $note; |
|
| 3876 | + } |
|
| 3877 | 3877 | |
| 3878 | - $this->set_status( 'publish', $_note ); |
|
| 3878 | + $this->set_status( 'publish', $_note ); |
|
| 3879 | 3879 | |
| 3880 | - } |
|
| 3880 | + } |
|
| 3881 | 3881 | |
| 3882 | - // Set checkout mode. |
|
| 3883 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3884 | - $this->set_mode( $mode ); |
|
| 3882 | + // Set checkout mode. |
|
| 3883 | + $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3884 | + $this->set_mode( $mode ); |
|
| 3885 | 3885 | |
| 3886 | - // Save the invoice. |
|
| 3886 | + // Save the invoice. |
|
| 3887 | 3887 | $this->save(); |
| 3888 | - } |
|
| 3889 | - |
|
| 3890 | - /** |
|
| 3891 | - * Save data to the database. |
|
| 3892 | - * |
|
| 3893 | - * @since 1.0.19 |
|
| 3894 | - * @return int invoice ID |
|
| 3895 | - */ |
|
| 3896 | - public function save() { |
|
| 3897 | - $this->maybe_set_date_paid(); |
|
| 3898 | - $this->maybe_set_key(); |
|
| 3899 | - parent::save(); |
|
| 3900 | - $this->clear_cache(); |
|
| 3901 | - $this->status_transition(); |
|
| 3902 | - return $this->get_id(); |
|
| 3903 | - } |
|
| 3904 | - |
|
| 3905 | - /** |
|
| 3888 | + } |
|
| 3889 | + |
|
| 3890 | + /** |
|
| 3891 | + * Save data to the database. |
|
| 3892 | + * |
|
| 3893 | + * @since 1.0.19 |
|
| 3894 | + * @return int invoice ID |
|
| 3895 | + */ |
|
| 3896 | + public function save() { |
|
| 3897 | + $this->maybe_set_date_paid(); |
|
| 3898 | + $this->maybe_set_key(); |
|
| 3899 | + parent::save(); |
|
| 3900 | + $this->clear_cache(); |
|
| 3901 | + $this->status_transition(); |
|
| 3902 | + return $this->get_id(); |
|
| 3903 | + } |
|
| 3904 | + |
|
| 3905 | + /** |
|
| 3906 | 3906 | * Clears the subscription's cache. |
| 3907 | 3907 | */ |
| 3908 | 3908 | public function clear_cache() { |
| 3909 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3910 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3911 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3912 | - } |
|
| 3909 | + wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3910 | + wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3911 | + wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3912 | + } |
|
| 3913 | 3913 | |
| 3914 | 3914 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Invoice class. |
@@ -143,40 +143,40 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
| 145 | 145 | */ |
| 146 | - public function __construct( $invoice = 0 ) { |
|
| 146 | + public function __construct($invoice = 0) { |
|
| 147 | 147 | |
| 148 | - parent::__construct( $invoice ); |
|
| 148 | + parent::__construct($invoice); |
|
| 149 | 149 | |
| 150 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 151 | - $this->set_id( (int) $invoice ); |
|
| 152 | - } elseif ( $invoice instanceof self ) { |
|
| 153 | - $this->set_id( $invoice->get_id() ); |
|
| 154 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 155 | - $this->set_id( $invoice->ID ); |
|
| 156 | - } elseif ( is_array( $invoice ) ) { |
|
| 157 | - $this->set_props( $invoice ); |
|
| 150 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
| 151 | + $this->set_id((int) $invoice); |
|
| 152 | + } elseif ($invoice instanceof self) { |
|
| 153 | + $this->set_id($invoice->get_id()); |
|
| 154 | + } elseif (!empty($invoice->ID)) { |
|
| 155 | + $this->set_id($invoice->ID); |
|
| 156 | + } elseif (is_array($invoice)) { |
|
| 157 | + $this->set_props($invoice); |
|
| 158 | 158 | |
| 159 | - if ( isset( $invoice['ID'] ) ) { |
|
| 160 | - $this->set_id( $invoice['ID'] ); |
|
| 159 | + if (isset($invoice['ID'])) { |
|
| 160 | + $this->set_id($invoice['ID']); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 164 | - $this->set_id( $invoice_id ); |
|
| 165 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 166 | - $this->set_id( $invoice_id ); |
|
| 167 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 168 | - $this->set_id( $invoice_id ); |
|
| 163 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
| 164 | + $this->set_id($invoice_id); |
|
| 165 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
| 166 | + $this->set_id($invoice_id); |
|
| 167 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
| 168 | + $this->set_id($invoice_id); |
|
| 169 | 169 | } else { |
| 170 | - $this->set_object_read( true ); |
|
| 170 | + $this->set_object_read(true); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Load the datastore. |
| 174 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 174 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 175 | 175 | |
| 176 | - if ( $this->get_id() > 0 ) { |
|
| 177 | - $this->post = get_post( $this->get_id() ); |
|
| 176 | + if ($this->get_id() > 0) { |
|
| 177 | + $this->post = get_post($this->get_id()); |
|
| 178 | 178 | $this->ID = $this->get_id(); |
| 179 | - $this->data_store->read( $this ); |
|
| 179 | + $this->data_store->read($this); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | } |
@@ -191,38 +191,38 @@ discard block |
||
| 191 | 191 | * @since 1.0.15 |
| 192 | 192 | * @return int |
| 193 | 193 | */ |
| 194 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 194 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
| 195 | 195 | global $wpdb; |
| 196 | 196 | |
| 197 | 197 | // Trim the value. |
| 198 | - $value = trim( $value ); |
|
| 198 | + $value = trim($value); |
|
| 199 | 199 | |
| 200 | - if ( empty( $value ) ) { |
|
| 200 | + if (empty($value)) { |
|
| 201 | 201 | return 0; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Valid fields. |
| 205 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
| 205 | + $fields = array('key', 'number', 'transaction_id'); |
|
| 206 | 206 | |
| 207 | 207 | // Ensure a field has been passed. |
| 208 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 208 | + if (empty($field) || !in_array($field, $fields)) { |
|
| 209 | 209 | return 0; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // Maybe retrieve from the cache. |
| 213 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 214 | - if ( false !== $invoice_id ) { |
|
| 213 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 214 | + if (false !== $invoice_id) { |
|
| 215 | 215 | return $invoice_id; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Fetch from the db. |
| 219 | 219 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 220 | 220 | $invoice_id = (int) $wpdb->get_var( |
| 221 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
| 221 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | 224 | // Update the cache with our data |
| 225 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 225 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 226 | 226 | |
| 227 | 227 | return $invoice_id; |
| 228 | 228 | } |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | /** |
| 231 | 231 | * Checks if an invoice key is set. |
| 232 | 232 | */ |
| 233 | - public function _isset( $key ) { |
|
| 234 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 233 | + public function _isset($key) { |
|
| 234 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /* |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | * @param string $context View or edit context. |
| 257 | 257 | * @return int |
| 258 | 258 | */ |
| 259 | - public function get_parent_id( $context = 'view' ) { |
|
| 260 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 259 | + public function get_parent_id($context = 'view') { |
|
| 260 | + return (int) $this->get_prop('parent_id', $context); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @return WPInv_Invoice |
| 268 | 268 | */ |
| 269 | 269 | public function get_parent_payment() { |
| 270 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 270 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | * @param string $context View or edit context. |
| 288 | 288 | * @return string |
| 289 | 289 | */ |
| 290 | - public function get_status( $context = 'view' ) { |
|
| 291 | - return $this->get_prop( 'status', $context ); |
|
| 290 | + public function get_status($context = 'view') { |
|
| 291 | + return $this->get_prop('status', $context); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * @return array |
| 299 | 299 | */ |
| 300 | 300 | public function get_all_statuses() { |
| 301 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 301 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -310,9 +310,9 @@ discard block |
||
| 310 | 310 | public function get_status_nicename() { |
| 311 | 311 | $statuses = $this->get_all_statuses(); |
| 312 | 312 | |
| 313 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 313 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 314 | 314 | |
| 315 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
| 315 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | public function get_status_class() { |
| 325 | 325 | $statuses = getpaid_get_invoice_status_classes(); |
| 326 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
| 326 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function get_status_label_html() { |
| 336 | 336 | |
| 337 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 338 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 339 | - $class = esc_attr( $this->get_status_class() ); |
|
| 337 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
| 338 | + $status = sanitize_html_class($this->get_status()); |
|
| 339 | + $class = esc_attr($this->get_status_class()); |
|
| 340 | 340 | |
| 341 | 341 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
| 342 | 342 | } |
@@ -348,23 +348,23 @@ discard block |
||
| 348 | 348 | * @param string $context View or edit context. |
| 349 | 349 | * @return string |
| 350 | 350 | */ |
| 351 | - public function get_version( $context = 'view' ) { |
|
| 352 | - return $this->get_prop( 'version', $context ); |
|
| 351 | + public function get_version($context = 'view') { |
|
| 352 | + return $this->get_prop('version', $context); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | 356 | * @deprecated |
| 357 | 357 | */ |
| 358 | - public function get_invoice_date( $format = true ) { |
|
| 359 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 360 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 361 | - $formatted = getpaid_format_date( $date ); |
|
| 358 | + public function get_invoice_date($format = true) { |
|
| 359 | + $date = getpaid_format_date($this->get_date_completed()); |
|
| 360 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 361 | + $formatted = getpaid_format_date($date); |
|
| 362 | 362 | |
| 363 | - if ( $format ) { |
|
| 363 | + if ($format) { |
|
| 364 | 364 | return $formatted; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - return empty( $formatted ) ? '' : $date; |
|
| 367 | + return empty($formatted) ? '' : $date; |
|
| 368 | 368 | |
| 369 | 369 | } |
| 370 | 370 | |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | * @param string $context View or edit context. |
| 376 | 376 | * @return string |
| 377 | 377 | */ |
| 378 | - public function get_date_created( $context = 'view' ) { |
|
| 379 | - return $this->get_prop( 'date_created', $context ); |
|
| 378 | + public function get_date_created($context = 'view') { |
|
| 379 | + return $this->get_prop('date_created', $context); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | * @param string $context View or edit context. |
| 387 | 387 | * @return string |
| 388 | 388 | */ |
| 389 | - public function get_created_date( $context = 'view' ) { |
|
| 390 | - return $this->get_date_created( $context ); |
|
| 389 | + public function get_created_date($context = 'view') { |
|
| 390 | + return $this->get_date_created($context); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | * @param string $context View or edit context. |
| 398 | 398 | * @return string |
| 399 | 399 | */ |
| 400 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 401 | - $date = $this->get_date_created( $context ); |
|
| 400 | + public function get_date_created_gmt($context = 'view') { |
|
| 401 | + $date = $this->get_date_created($context); |
|
| 402 | 402 | |
| 403 | - if ( $date ) { |
|
| 404 | - $date = get_gmt_from_date( $date ); |
|
| 403 | + if ($date) { |
|
| 404 | + $date = get_gmt_from_date($date); |
|
| 405 | 405 | } |
| 406 | 406 | return $date; |
| 407 | 407 | } |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | * @param string $context View or edit context. |
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | - public function get_date_modified( $context = 'view' ) { |
|
| 417 | - return $this->get_prop( 'date_modified', $context ); |
|
| 416 | + public function get_date_modified($context = 'view') { |
|
| 417 | + return $this->get_prop('date_modified', $context); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -424,8 +424,8 @@ discard block |
||
| 424 | 424 | * @param string $context View or edit context. |
| 425 | 425 | * @return string |
| 426 | 426 | */ |
| 427 | - public function get_modified_date( $context = 'view' ) { |
|
| 428 | - return $this->get_date_modified( $context ); |
|
| 427 | + public function get_modified_date($context = 'view') { |
|
| 428 | + return $this->get_date_modified($context); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -435,11 +435,11 @@ discard block |
||
| 435 | 435 | * @param string $context View or edit context. |
| 436 | 436 | * @return string |
| 437 | 437 | */ |
| 438 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 439 | - $date = $this->get_date_modified( $context ); |
|
| 438 | + public function get_date_modified_gmt($context = 'view') { |
|
| 439 | + $date = $this->get_date_modified($context); |
|
| 440 | 440 | |
| 441 | - if ( $date ) { |
|
| 442 | - $date = get_gmt_from_date( $date ); |
|
| 441 | + if ($date) { |
|
| 442 | + $date = get_gmt_from_date($date); |
|
| 443 | 443 | } |
| 444 | 444 | return $date; |
| 445 | 445 | } |
@@ -451,8 +451,8 @@ discard block |
||
| 451 | 451 | * @param string $context View or edit context. |
| 452 | 452 | * @return string |
| 453 | 453 | */ |
| 454 | - public function get_due_date( $context = 'view' ) { |
|
| 455 | - return $this->get_prop( 'due_date', $context ); |
|
| 454 | + public function get_due_date($context = 'view') { |
|
| 455 | + return $this->get_prop('due_date', $context); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -462,8 +462,8 @@ discard block |
||
| 462 | 462 | * @param string $context View or edit context. |
| 463 | 463 | * @return string |
| 464 | 464 | */ |
| 465 | - public function get_date_due( $context = 'view' ) { |
|
| 466 | - return $this->get_due_date( $context ); |
|
| 465 | + public function get_date_due($context = 'view') { |
|
| 466 | + return $this->get_due_date($context); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -473,11 +473,11 @@ discard block |
||
| 473 | 473 | * @param string $context View or edit context. |
| 474 | 474 | * @return string |
| 475 | 475 | */ |
| 476 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 477 | - $date = $this->get_due_date( $context ); |
|
| 476 | + public function get_due_date_gmt($context = 'view') { |
|
| 477 | + $date = $this->get_due_date($context); |
|
| 478 | 478 | |
| 479 | - if ( $date ) { |
|
| 480 | - $date = get_gmt_from_date( $date ); |
|
| 479 | + if ($date) { |
|
| 480 | + $date = get_gmt_from_date($date); |
|
| 481 | 481 | } |
| 482 | 482 | return $date; |
| 483 | 483 | } |
@@ -489,8 +489,8 @@ discard block |
||
| 489 | 489 | * @param string $context View or edit context. |
| 490 | 490 | * @return string |
| 491 | 491 | */ |
| 492 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 493 | - return $this->get_due_date_gmt( $context ); |
|
| 492 | + public function get_gmt_date_due($context = 'view') { |
|
| 493 | + return $this->get_due_date_gmt($context); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | * @param string $context View or edit context. |
| 501 | 501 | * @return string |
| 502 | 502 | */ |
| 503 | - public function get_completed_date( $context = 'view' ) { |
|
| 504 | - return $this->get_prop( 'completed_date', $context ); |
|
| 503 | + public function get_completed_date($context = 'view') { |
|
| 504 | + return $this->get_prop('completed_date', $context); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /** |
@@ -511,8 +511,8 @@ discard block |
||
| 511 | 511 | * @param string $context View or edit context. |
| 512 | 512 | * @return string |
| 513 | 513 | */ |
| 514 | - public function get_date_completed( $context = 'view' ) { |
|
| 515 | - return $this->get_completed_date( $context ); |
|
| 514 | + public function get_date_completed($context = 'view') { |
|
| 515 | + return $this->get_completed_date($context); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -522,11 +522,11 @@ discard block |
||
| 522 | 522 | * @param string $context View or edit context. |
| 523 | 523 | * @return string |
| 524 | 524 | */ |
| 525 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 526 | - $date = $this->get_completed_date( $context ); |
|
| 525 | + public function get_completed_date_gmt($context = 'view') { |
|
| 526 | + $date = $this->get_completed_date($context); |
|
| 527 | 527 | |
| 528 | - if ( $date ) { |
|
| 529 | - $date = get_gmt_from_date( $date ); |
|
| 528 | + if ($date) { |
|
| 529 | + $date = get_gmt_from_date($date); |
|
| 530 | 530 | } |
| 531 | 531 | return $date; |
| 532 | 532 | } |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | * @param string $context View or edit context. |
| 539 | 539 | * @return string |
| 540 | 540 | */ |
| 541 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 542 | - return $this->get_completed_date_gmt( $context ); |
|
| 541 | + public function get_gmt_completed_date($context = 'view') { |
|
| 542 | + return $this->get_completed_date_gmt($context); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -549,12 +549,12 @@ discard block |
||
| 549 | 549 | * @param string $context View or edit context. |
| 550 | 550 | * @return string |
| 551 | 551 | */ |
| 552 | - public function get_number( $context = 'view' ) { |
|
| 553 | - $number = $this->get_prop( 'number', $context ); |
|
| 552 | + public function get_number($context = 'view') { |
|
| 553 | + $number = $this->get_prop('number', $context); |
|
| 554 | 554 | |
| 555 | - if ( empty( $number ) ) { |
|
| 555 | + if (empty($number)) { |
|
| 556 | 556 | $number = $this->generate_number(); |
| 557 | - $this->set_number( $this->generate_number() ); |
|
| 557 | + $this->set_number($this->generate_number()); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | return $number; |
@@ -568,8 +568,8 @@ discard block |
||
| 568 | 568 | public function maybe_set_number() { |
| 569 | 569 | $number = $this->get_number(); |
| 570 | 570 | |
| 571 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
| 572 | - $this->set_number( $this->generate_number() ); |
|
| 571 | + if (empty($number) || $this->get_id() == $number) { |
|
| 572 | + $this->set_number($this->generate_number()); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | } |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | * @param string $context View or edit context. |
| 582 | 582 | * @return string |
| 583 | 583 | */ |
| 584 | - public function get_key( $context = 'view' ) { |
|
| 585 | - return $this->get_prop( 'key', $context ); |
|
| 584 | + public function get_key($context = 'view') { |
|
| 585 | + return $this->get_prop('key', $context); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -593,9 +593,9 @@ discard block |
||
| 593 | 593 | public function maybe_set_key() { |
| 594 | 594 | $key = $this->get_key(); |
| 595 | 595 | |
| 596 | - if ( empty( $key ) ) { |
|
| 597 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
| 598 | - $this->set_key( $key ); |
|
| 596 | + if (empty($key)) { |
|
| 597 | + $key = $this->generate_key($this->get_type() . '_'); |
|
| 598 | + $this->set_key($key); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | } |
@@ -607,8 +607,8 @@ discard block |
||
| 607 | 607 | * @param string $context View or edit context. |
| 608 | 608 | * @return string |
| 609 | 609 | */ |
| 610 | - public function get_type( $context = 'view' ) { |
|
| 611 | - return $this->get_prop( 'type', $context ); |
|
| 610 | + public function get_type($context = 'view') { |
|
| 611 | + return $this->get_prop('type', $context); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | * @return string |
| 619 | 619 | */ |
| 620 | 620 | public function get_invoice_quote_type() { |
| 621 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
| 621 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
@@ -628,8 +628,8 @@ discard block |
||
| 628 | 628 | * @param string $context View or edit context. |
| 629 | 629 | * @return string |
| 630 | 630 | */ |
| 631 | - public function get_label( $context = 'view' ) { |
|
| 632 | - return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
|
| 631 | + public function get_label($context = 'view') { |
|
| 632 | + return getpaid_get_post_type_label($this->get_post_type($context), false); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -639,8 +639,8 @@ discard block |
||
| 639 | 639 | * @param string $context View or edit context. |
| 640 | 640 | * @return string |
| 641 | 641 | */ |
| 642 | - public function get_post_type( $context = 'view' ) { |
|
| 643 | - return $this->get_prop( 'post_type', $context ); |
|
| 642 | + public function get_post_type($context = 'view') { |
|
| 643 | + return $this->get_prop('post_type', $context); |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | /** |
@@ -650,8 +650,8 @@ discard block |
||
| 650 | 650 | * @param string $context View or edit context. |
| 651 | 651 | * @return string |
| 652 | 652 | */ |
| 653 | - public function get_mode( $context = 'view' ) { |
|
| 654 | - return $this->get_prop( 'mode', $context ); |
|
| 653 | + public function get_mode($context = 'view') { |
|
| 654 | + return $this->get_prop('mode', $context); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -661,13 +661,13 @@ discard block |
||
| 661 | 661 | * @param string $context View or edit context. |
| 662 | 662 | * @return string |
| 663 | 663 | */ |
| 664 | - public function get_path( $context = 'view' ) { |
|
| 665 | - $path = $this->get_prop( 'path', $context ); |
|
| 664 | + public function get_path($context = 'view') { |
|
| 665 | + $path = $this->get_prop('path', $context); |
|
| 666 | 666 | $prefix = $this->get_type(); |
| 667 | 667 | |
| 668 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 669 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 670 | - $this->set_path( $path ); |
|
| 668 | + if (0 !== strpos($path, $prefix)) { |
|
| 669 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
| 670 | + $this->set_path($path); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | return $path; |
@@ -680,8 +680,8 @@ discard block |
||
| 680 | 680 | * @param string $context View or edit context. |
| 681 | 681 | * @return string |
| 682 | 682 | */ |
| 683 | - public function get_name( $context = 'view' ) { |
|
| 684 | - return $this->get_prop( 'title', $context ); |
|
| 683 | + public function get_name($context = 'view') { |
|
| 684 | + return $this->get_prop('title', $context); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -691,8 +691,8 @@ discard block |
||
| 691 | 691 | * @param string $context View or edit context. |
| 692 | 692 | * @return string |
| 693 | 693 | */ |
| 694 | - public function get_title( $context = 'view' ) { |
|
| 695 | - return $this->get_name( $context ); |
|
| 694 | + public function get_title($context = 'view') { |
|
| 695 | + return $this->get_name($context); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | /** |
@@ -702,8 +702,8 @@ discard block |
||
| 702 | 702 | * @param string $context View or edit context. |
| 703 | 703 | * @return string |
| 704 | 704 | */ |
| 705 | - public function get_description( $context = 'view' ) { |
|
| 706 | - return $this->get_prop( 'description', $context ); |
|
| 705 | + public function get_description($context = 'view') { |
|
| 706 | + return $this->get_prop('description', $context); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
@@ -713,8 +713,8 @@ discard block |
||
| 713 | 713 | * @param string $context View or edit context. |
| 714 | 714 | * @return string |
| 715 | 715 | */ |
| 716 | - public function get_excerpt( $context = 'view' ) { |
|
| 717 | - return $this->get_description( $context ); |
|
| 716 | + public function get_excerpt($context = 'view') { |
|
| 717 | + return $this->get_description($context); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
@@ -724,8 +724,8 @@ discard block |
||
| 724 | 724 | * @param string $context View or edit context. |
| 725 | 725 | * @return string |
| 726 | 726 | */ |
| 727 | - public function get_summary( $context = 'view' ) { |
|
| 728 | - return $this->get_description( $context ); |
|
| 727 | + public function get_summary($context = 'view') { |
|
| 728 | + return $this->get_description($context); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
@@ -735,25 +735,25 @@ discard block |
||
| 735 | 735 | * @param string $context View or edit context. |
| 736 | 736 | * @return array |
| 737 | 737 | */ |
| 738 | - public function get_user_info( $context = 'view' ) { |
|
| 738 | + public function get_user_info($context = 'view') { |
|
| 739 | 739 | |
| 740 | 740 | $user_info = array( |
| 741 | - 'user_id' => $this->get_user_id( $context ), |
|
| 742 | - 'email' => $this->get_email( $context ), |
|
| 743 | - 'first_name' => $this->get_first_name( $context ), |
|
| 744 | - 'last_name' => $this->get_last_name( $context ), |
|
| 745 | - 'address' => $this->get_address( $context ), |
|
| 746 | - 'phone' => $this->get_phone( $context ), |
|
| 747 | - 'city' => $this->get_city( $context ), |
|
| 748 | - 'country' => $this->get_country( $context ), |
|
| 749 | - 'state' => $this->get_state( $context ), |
|
| 750 | - 'zip' => $this->get_zip( $context ), |
|
| 751 | - 'company' => $this->get_company( $context ), |
|
| 752 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 753 | - 'discount' => $this->get_discount_code( $context ), |
|
| 741 | + 'user_id' => $this->get_user_id($context), |
|
| 742 | + 'email' => $this->get_email($context), |
|
| 743 | + 'first_name' => $this->get_first_name($context), |
|
| 744 | + 'last_name' => $this->get_last_name($context), |
|
| 745 | + 'address' => $this->get_address($context), |
|
| 746 | + 'phone' => $this->get_phone($context), |
|
| 747 | + 'city' => $this->get_city($context), |
|
| 748 | + 'country' => $this->get_country($context), |
|
| 749 | + 'state' => $this->get_state($context), |
|
| 750 | + 'zip' => $this->get_zip($context), |
|
| 751 | + 'company' => $this->get_company($context), |
|
| 752 | + 'vat_number' => $this->get_vat_number($context), |
|
| 753 | + 'discount' => $this->get_discount_code($context), |
|
| 754 | 754 | ); |
| 755 | 755 | |
| 756 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 756 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 757 | 757 | |
| 758 | 758 | } |
| 759 | 759 | |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | * @param string $context View or edit context. |
| 765 | 765 | * @return int |
| 766 | 766 | */ |
| 767 | - public function get_author( $context = 'view' ) { |
|
| 768 | - return (int) $this->get_prop( 'author', $context ); |
|
| 767 | + public function get_author($context = 'view') { |
|
| 768 | + return (int) $this->get_prop('author', $context); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -775,8 +775,8 @@ discard block |
||
| 775 | 775 | * @param string $context View or edit context. |
| 776 | 776 | * @return int |
| 777 | 777 | */ |
| 778 | - public function get_user_id( $context = 'view' ) { |
|
| 779 | - return $this->get_author( $context ); |
|
| 778 | + public function get_user_id($context = 'view') { |
|
| 779 | + return $this->get_author($context); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
@@ -786,8 +786,8 @@ discard block |
||
| 786 | 786 | * @param string $context View or edit context. |
| 787 | 787 | * @return int |
| 788 | 788 | */ |
| 789 | - public function get_customer_id( $context = 'view' ) { |
|
| 790 | - return $this->get_author( $context ); |
|
| 789 | + public function get_customer_id($context = 'view') { |
|
| 790 | + return $this->get_author($context); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -797,8 +797,8 @@ discard block |
||
| 797 | 797 | * @param string $context View or edit context. |
| 798 | 798 | * @return string |
| 799 | 799 | */ |
| 800 | - public function get_ip( $context = 'view' ) { |
|
| 801 | - return $this->get_prop( 'user_ip', $context ); |
|
| 800 | + public function get_ip($context = 'view') { |
|
| 801 | + return $this->get_prop('user_ip', $context); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | /** |
@@ -808,8 +808,8 @@ discard block |
||
| 808 | 808 | * @param string $context View or edit context. |
| 809 | 809 | * @return string |
| 810 | 810 | */ |
| 811 | - public function get_user_ip( $context = 'view' ) { |
|
| 812 | - return $this->get_ip( $context ); |
|
| 811 | + public function get_user_ip($context = 'view') { |
|
| 812 | + return $this->get_ip($context); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -819,8 +819,8 @@ discard block |
||
| 819 | 819 | * @param string $context View or edit context. |
| 820 | 820 | * @return string |
| 821 | 821 | */ |
| 822 | - public function get_customer_ip( $context = 'view' ) { |
|
| 823 | - return $this->get_ip( $context ); |
|
| 822 | + public function get_customer_ip($context = 'view') { |
|
| 823 | + return $this->get_ip($context); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |
@@ -830,8 +830,8 @@ discard block |
||
| 830 | 830 | * @param string $context View or edit context. |
| 831 | 831 | * @return string |
| 832 | 832 | */ |
| 833 | - public function get_first_name( $context = 'view' ) { |
|
| 834 | - return $this->get_prop( 'first_name', $context ); |
|
| 833 | + public function get_first_name($context = 'view') { |
|
| 834 | + return $this->get_prop('first_name', $context); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | * @param string $context View or edit context. |
| 842 | 842 | * @return string |
| 843 | 843 | */ |
| 844 | - public function get_user_first_name( $context = 'view' ) { |
|
| 845 | - return $this->get_first_name( $context ); |
|
| 844 | + public function get_user_first_name($context = 'view') { |
|
| 845 | + return $this->get_first_name($context); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | /** |
@@ -852,8 +852,8 @@ discard block |
||
| 852 | 852 | * @param string $context View or edit context. |
| 853 | 853 | * @return string |
| 854 | 854 | */ |
| 855 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 856 | - return $this->get_first_name( $context ); |
|
| 855 | + public function get_customer_first_name($context = 'view') { |
|
| 856 | + return $this->get_first_name($context); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
@@ -863,8 +863,8 @@ discard block |
||
| 863 | 863 | * @param string $context View or edit context. |
| 864 | 864 | * @return string |
| 865 | 865 | */ |
| 866 | - public function get_last_name( $context = 'view' ) { |
|
| 867 | - return $this->get_prop( 'last_name', $context ); |
|
| 866 | + public function get_last_name($context = 'view') { |
|
| 867 | + return $this->get_prop('last_name', $context); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
@@ -874,8 +874,8 @@ discard block |
||
| 874 | 874 | * @param string $context View or edit context. |
| 875 | 875 | * @return string |
| 876 | 876 | */ |
| 877 | - public function get_user_last_name( $context = 'view' ) { |
|
| 878 | - return $this->get_last_name( $context ); |
|
| 877 | + public function get_user_last_name($context = 'view') { |
|
| 878 | + return $this->get_last_name($context); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
@@ -885,8 +885,8 @@ discard block |
||
| 885 | 885 | * @param string $context View or edit context. |
| 886 | 886 | * @return string |
| 887 | 887 | */ |
| 888 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 889 | - return $this->get_last_name( $context ); |
|
| 888 | + public function get_customer_last_name($context = 'view') { |
|
| 889 | + return $this->get_last_name($context); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | /** |
@@ -896,8 +896,8 @@ discard block |
||
| 896 | 896 | * @param string $context View or edit context. |
| 897 | 897 | * @return string |
| 898 | 898 | */ |
| 899 | - public function get_full_name( $context = 'view' ) { |
|
| 900 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 899 | + public function get_full_name($context = 'view') { |
|
| 900 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
@@ -907,8 +907,8 @@ discard block |
||
| 907 | 907 | * @param string $context View or edit context. |
| 908 | 908 | * @return string |
| 909 | 909 | */ |
| 910 | - public function get_user_full_name( $context = 'view' ) { |
|
| 911 | - return $this->get_full_name( $context ); |
|
| 910 | + public function get_user_full_name($context = 'view') { |
|
| 911 | + return $this->get_full_name($context); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -918,8 +918,8 @@ discard block |
||
| 918 | 918 | * @param string $context View or edit context. |
| 919 | 919 | * @return string |
| 920 | 920 | */ |
| 921 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 922 | - return $this->get_full_name( $context ); |
|
| 921 | + public function get_customer_full_name($context = 'view') { |
|
| 922 | + return $this->get_full_name($context); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
@@ -929,8 +929,8 @@ discard block |
||
| 929 | 929 | * @param string $context View or edit context. |
| 930 | 930 | * @return string |
| 931 | 931 | */ |
| 932 | - public function get_phone( $context = 'view' ) { |
|
| 933 | - return $this->get_prop( 'phone', $context ); |
|
| 932 | + public function get_phone($context = 'view') { |
|
| 933 | + return $this->get_prop('phone', $context); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
@@ -940,8 +940,8 @@ discard block |
||
| 940 | 940 | * @param string $context View or edit context. |
| 941 | 941 | * @return string |
| 942 | 942 | */ |
| 943 | - public function get_phone_number( $context = 'view' ) { |
|
| 944 | - return $this->get_phone( $context ); |
|
| 943 | + public function get_phone_number($context = 'view') { |
|
| 944 | + return $this->get_phone($context); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | /** |
@@ -951,8 +951,8 @@ discard block |
||
| 951 | 951 | * @param string $context View or edit context. |
| 952 | 952 | * @return string |
| 953 | 953 | */ |
| 954 | - public function get_user_phone( $context = 'view' ) { |
|
| 955 | - return $this->get_phone( $context ); |
|
| 954 | + public function get_user_phone($context = 'view') { |
|
| 955 | + return $this->get_phone($context); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | /** |
@@ -962,8 +962,8 @@ discard block |
||
| 962 | 962 | * @param string $context View or edit context. |
| 963 | 963 | * @return string |
| 964 | 964 | */ |
| 965 | - public function get_customer_phone( $context = 'view' ) { |
|
| 966 | - return $this->get_phone( $context ); |
|
| 965 | + public function get_customer_phone($context = 'view') { |
|
| 966 | + return $this->get_phone($context); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
@@ -973,8 +973,8 @@ discard block |
||
| 973 | 973 | * @param string $context View or edit context. |
| 974 | 974 | * @return string |
| 975 | 975 | */ |
| 976 | - public function get_email( $context = 'view' ) { |
|
| 977 | - return $this->get_prop( 'email', $context ); |
|
| 976 | + public function get_email($context = 'view') { |
|
| 977 | + return $this->get_prop('email', $context); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -984,8 +984,8 @@ discard block |
||
| 984 | 984 | * @param string $context View or edit context. |
| 985 | 985 | * @return string |
| 986 | 986 | */ |
| 987 | - public function get_email_address( $context = 'view' ) { |
|
| 988 | - return $this->get_email( $context ); |
|
| 987 | + public function get_email_address($context = 'view') { |
|
| 988 | + return $this->get_email($context); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | /** |
@@ -995,8 +995,8 @@ discard block |
||
| 995 | 995 | * @param string $context View or edit context. |
| 996 | 996 | * @return string |
| 997 | 997 | */ |
| 998 | - public function get_user_email( $context = 'view' ) { |
|
| 999 | - return $this->get_email( $context ); |
|
| 998 | + public function get_user_email($context = 'view') { |
|
| 999 | + return $this->get_email($context); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1006,8 +1006,8 @@ discard block |
||
| 1006 | 1006 | * @param string $context View or edit context. |
| 1007 | 1007 | * @return string |
| 1008 | 1008 | */ |
| 1009 | - public function get_customer_email( $context = 'view' ) { |
|
| 1010 | - return $this->get_email( $context ); |
|
| 1009 | + public function get_customer_email($context = 'view') { |
|
| 1010 | + return $this->get_email($context); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /** |
@@ -1017,9 +1017,9 @@ discard block |
||
| 1017 | 1017 | * @param string $context View or edit context. |
| 1018 | 1018 | * @return string |
| 1019 | 1019 | */ |
| 1020 | - public function get_country( $context = 'view' ) { |
|
| 1021 | - $country = $this->get_prop( 'country', $context ); |
|
| 1022 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1020 | + public function get_country($context = 'view') { |
|
| 1021 | + $country = $this->get_prop('country', $context); |
|
| 1022 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
| 1029 | 1029 | * @param string $context View or edit context. |
| 1030 | 1030 | * @return string |
| 1031 | 1031 | */ |
| 1032 | - public function get_user_country( $context = 'view' ) { |
|
| 1033 | - return $this->get_country( $context ); |
|
| 1032 | + public function get_user_country($context = 'view') { |
|
| 1033 | + return $this->get_country($context); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | /** |
@@ -1040,8 +1040,8 @@ discard block |
||
| 1040 | 1040 | * @param string $context View or edit context. |
| 1041 | 1041 | * @return string |
| 1042 | 1042 | */ |
| 1043 | - public function get_customer_country( $context = 'view' ) { |
|
| 1044 | - return $this->get_country( $context ); |
|
| 1043 | + public function get_customer_country($context = 'view') { |
|
| 1044 | + return $this->get_country($context); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | /** |
@@ -1051,9 +1051,9 @@ discard block |
||
| 1051 | 1051 | * @param string $context View or edit context. |
| 1052 | 1052 | * @return string |
| 1053 | 1053 | */ |
| 1054 | - public function get_state( $context = 'view' ) { |
|
| 1055 | - $state = $this->get_prop( 'state', $context ); |
|
| 1056 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1054 | + public function get_state($context = 'view') { |
|
| 1055 | + $state = $this->get_prop('state', $context); |
|
| 1056 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1063,8 +1063,8 @@ discard block |
||
| 1063 | 1063 | * @param string $context View or edit context. |
| 1064 | 1064 | * @return string |
| 1065 | 1065 | */ |
| 1066 | - public function get_user_state( $context = 'view' ) { |
|
| 1067 | - return $this->get_state( $context ); |
|
| 1066 | + public function get_user_state($context = 'view') { |
|
| 1067 | + return $this->get_state($context); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | /** |
@@ -1074,8 +1074,8 @@ discard block |
||
| 1074 | 1074 | * @param string $context View or edit context. |
| 1075 | 1075 | * @return string |
| 1076 | 1076 | */ |
| 1077 | - public function get_customer_state( $context = 'view' ) { |
|
| 1078 | - return $this->get_state( $context ); |
|
| 1077 | + public function get_customer_state($context = 'view') { |
|
| 1078 | + return $this->get_state($context); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
@@ -1085,8 +1085,8 @@ discard block |
||
| 1085 | 1085 | * @param string $context View or edit context. |
| 1086 | 1086 | * @return string |
| 1087 | 1087 | */ |
| 1088 | - public function get_city( $context = 'view' ) { |
|
| 1089 | - return $this->get_prop( 'city', $context ); |
|
| 1088 | + public function get_city($context = 'view') { |
|
| 1089 | + return $this->get_prop('city', $context); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | /** |
@@ -1096,8 +1096,8 @@ discard block |
||
| 1096 | 1096 | * @param string $context View or edit context. |
| 1097 | 1097 | * @return string |
| 1098 | 1098 | */ |
| 1099 | - public function get_user_city( $context = 'view' ) { |
|
| 1100 | - return $this->get_city( $context ); |
|
| 1099 | + public function get_user_city($context = 'view') { |
|
| 1100 | + return $this->get_city($context); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -1107,8 +1107,8 @@ discard block |
||
| 1107 | 1107 | * @param string $context View or edit context. |
| 1108 | 1108 | * @return string |
| 1109 | 1109 | */ |
| 1110 | - public function get_customer_city( $context = 'view' ) { |
|
| 1111 | - return $this->get_city( $context ); |
|
| 1110 | + public function get_customer_city($context = 'view') { |
|
| 1111 | + return $this->get_city($context); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
@@ -1118,8 +1118,8 @@ discard block |
||
| 1118 | 1118 | * @param string $context View or edit context. |
| 1119 | 1119 | * @return string |
| 1120 | 1120 | */ |
| 1121 | - public function get_zip( $context = 'view' ) { |
|
| 1122 | - return $this->get_prop( 'zip', $context ); |
|
| 1121 | + public function get_zip($context = 'view') { |
|
| 1122 | + return $this->get_prop('zip', $context); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /** |
@@ -1129,8 +1129,8 @@ discard block |
||
| 1129 | 1129 | * @param string $context View or edit context. |
| 1130 | 1130 | * @return string |
| 1131 | 1131 | */ |
| 1132 | - public function get_user_zip( $context = 'view' ) { |
|
| 1133 | - return $this->get_zip( $context ); |
|
| 1132 | + public function get_user_zip($context = 'view') { |
|
| 1133 | + return $this->get_zip($context); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | /** |
@@ -1140,8 +1140,8 @@ discard block |
||
| 1140 | 1140 | * @param string $context View or edit context. |
| 1141 | 1141 | * @return string |
| 1142 | 1142 | */ |
| 1143 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1144 | - return $this->get_zip( $context ); |
|
| 1143 | + public function get_customer_zip($context = 'view') { |
|
| 1144 | + return $this->get_zip($context); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
@@ -1151,8 +1151,8 @@ discard block |
||
| 1151 | 1151 | * @param string $context View or edit context. |
| 1152 | 1152 | * @return string |
| 1153 | 1153 | */ |
| 1154 | - public function get_company( $context = 'view' ) { |
|
| 1155 | - return $this->get_prop( 'company', $context ); |
|
| 1154 | + public function get_company($context = 'view') { |
|
| 1155 | + return $this->get_prop('company', $context); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | /** |
@@ -1162,8 +1162,8 @@ discard block |
||
| 1162 | 1162 | * @param string $context View or edit context. |
| 1163 | 1163 | * @return string |
| 1164 | 1164 | */ |
| 1165 | - public function get_user_company( $context = 'view' ) { |
|
| 1166 | - return $this->get_company( $context ); |
|
| 1165 | + public function get_user_company($context = 'view') { |
|
| 1166 | + return $this->get_company($context); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | /** |
@@ -1173,8 +1173,8 @@ discard block |
||
| 1173 | 1173 | * @param string $context View or edit context. |
| 1174 | 1174 | * @return string |
| 1175 | 1175 | */ |
| 1176 | - public function get_customer_company( $context = 'view' ) { |
|
| 1177 | - return $this->get_company( $context ); |
|
| 1176 | + public function get_customer_company($context = 'view') { |
|
| 1177 | + return $this->get_company($context); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | /** |
@@ -1184,8 +1184,8 @@ discard block |
||
| 1184 | 1184 | * @param string $context View or edit context. |
| 1185 | 1185 | * @return string |
| 1186 | 1186 | */ |
| 1187 | - public function get_vat_number( $context = 'view' ) { |
|
| 1188 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1187 | + public function get_vat_number($context = 'view') { |
|
| 1188 | + return $this->get_prop('vat_number', $context); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1195,8 +1195,8 @@ discard block |
||
| 1195 | 1195 | * @param string $context View or edit context. |
| 1196 | 1196 | * @return string |
| 1197 | 1197 | */ |
| 1198 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1199 | - return $this->get_vat_number( $context ); |
|
| 1198 | + public function get_user_vat_number($context = 'view') { |
|
| 1199 | + return $this->get_vat_number($context); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | /** |
@@ -1206,8 +1206,8 @@ discard block |
||
| 1206 | 1206 | * @param string $context View or edit context. |
| 1207 | 1207 | * @return string |
| 1208 | 1208 | */ |
| 1209 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1210 | - return $this->get_vat_number( $context ); |
|
| 1209 | + public function get_customer_vat_number($context = 'view') { |
|
| 1210 | + return $this->get_vat_number($context); |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | /** |
@@ -1217,8 +1217,8 @@ discard block |
||
| 1217 | 1217 | * @param string $context View or edit context. |
| 1218 | 1218 | * @return string |
| 1219 | 1219 | */ |
| 1220 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1221 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1220 | + public function get_vat_rate($context = 'view') { |
|
| 1221 | + return $this->get_prop('vat_rate', $context); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | /** |
@@ -1228,8 +1228,8 @@ discard block |
||
| 1228 | 1228 | * @param string $context View or edit context. |
| 1229 | 1229 | * @return string |
| 1230 | 1230 | */ |
| 1231 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1232 | - return $this->get_vat_rate( $context ); |
|
| 1231 | + public function get_user_vat_rate($context = 'view') { |
|
| 1232 | + return $this->get_vat_rate($context); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | /** |
@@ -1239,8 +1239,8 @@ discard block |
||
| 1239 | 1239 | * @param string $context View or edit context. |
| 1240 | 1240 | * @return string |
| 1241 | 1241 | */ |
| 1242 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1243 | - return $this->get_vat_rate( $context ); |
|
| 1242 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1243 | + return $this->get_vat_rate($context); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
@@ -1250,8 +1250,8 @@ discard block |
||
| 1250 | 1250 | * @param string $context View or edit context. |
| 1251 | 1251 | * @return string |
| 1252 | 1252 | */ |
| 1253 | - public function get_address( $context = 'view' ) { |
|
| 1254 | - return $this->get_prop( 'address', $context ); |
|
| 1253 | + public function get_address($context = 'view') { |
|
| 1254 | + return $this->get_prop('address', $context); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | /** |
@@ -1261,8 +1261,8 @@ discard block |
||
| 1261 | 1261 | * @param string $context View or edit context. |
| 1262 | 1262 | * @return string |
| 1263 | 1263 | */ |
| 1264 | - public function get_user_address( $context = 'view' ) { |
|
| 1265 | - return $this->get_address( $context ); |
|
| 1264 | + public function get_user_address($context = 'view') { |
|
| 1265 | + return $this->get_address($context); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | /** |
@@ -1272,8 +1272,8 @@ discard block |
||
| 1272 | 1272 | * @param string $context View or edit context. |
| 1273 | 1273 | * @return string |
| 1274 | 1274 | */ |
| 1275 | - public function get_customer_address( $context = 'view' ) { |
|
| 1276 | - return $this->get_address( $context ); |
|
| 1275 | + public function get_customer_address($context = 'view') { |
|
| 1276 | + return $this->get_address($context); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | 1279 | /** |
@@ -1283,8 +1283,8 @@ discard block |
||
| 1283 | 1283 | * @param string $context View or edit context. |
| 1284 | 1284 | * @return bool |
| 1285 | 1285 | */ |
| 1286 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1287 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1286 | + public function get_is_viewed($context = 'view') { |
|
| 1287 | + return (bool) $this->get_prop('is_viewed', $context); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | 1290 | /** |
@@ -1294,8 +1294,8 @@ discard block |
||
| 1294 | 1294 | * @param string $context View or edit context. |
| 1295 | 1295 | * @return bool |
| 1296 | 1296 | */ |
| 1297 | - public function get_email_cc( $context = 'view' ) { |
|
| 1298 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1297 | + public function get_email_cc($context = 'view') { |
|
| 1298 | + return $this->get_prop('email_cc', $context); |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1305,8 +1305,8 @@ discard block |
||
| 1305 | 1305 | * @param string $context View or edit context. |
| 1306 | 1306 | * @return bool |
| 1307 | 1307 | */ |
| 1308 | - public function get_template( $context = 'view' ) { |
|
| 1309 | - return $this->get_prop( 'template', $context ); |
|
| 1308 | + public function get_template($context = 'view') { |
|
| 1309 | + return $this->get_prop('template', $context); |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | /** |
@@ -1316,8 +1316,8 @@ discard block |
||
| 1316 | 1316 | * @param string $context View or edit context. |
| 1317 | 1317 | * @return bool |
| 1318 | 1318 | */ |
| 1319 | - public function get_created_via( $context = 'view' ) { |
|
| 1320 | - return $this->get_prop( 'created_via', $context ); |
|
| 1319 | + public function get_created_via($context = 'view') { |
|
| 1320 | + return $this->get_prop('created_via', $context); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | /** |
@@ -1327,8 +1327,8 @@ discard block |
||
| 1327 | 1327 | * @param string $context View or edit context. |
| 1328 | 1328 | * @return bool |
| 1329 | 1329 | */ |
| 1330 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1331 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1330 | + public function get_address_confirmed($context = 'view') { |
|
| 1331 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | /** |
@@ -1338,8 +1338,8 @@ discard block |
||
| 1338 | 1338 | * @param string $context View or edit context. |
| 1339 | 1339 | * @return bool |
| 1340 | 1340 | */ |
| 1341 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1342 | - return $this->get_address_confirmed( $context ); |
|
| 1341 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1342 | + return $this->get_address_confirmed($context); |
|
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | /** |
@@ -1349,8 +1349,8 @@ discard block |
||
| 1349 | 1349 | * @param string $context View or edit context. |
| 1350 | 1350 | * @return bool |
| 1351 | 1351 | */ |
| 1352 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1353 | - return $this->get_address_confirmed( $context ); |
|
| 1352 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1353 | + return $this->get_address_confirmed($context); |
|
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | /** |
@@ -1360,12 +1360,12 @@ discard block |
||
| 1360 | 1360 | * @param string $context View or edit context. |
| 1361 | 1361 | * @return float |
| 1362 | 1362 | */ |
| 1363 | - public function get_subtotal( $context = 'view' ) { |
|
| 1364 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1363 | + public function get_subtotal($context = 'view') { |
|
| 1364 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1365 | 1365 | |
| 1366 | 1366 | // Backwards compatibility. |
| 1367 | - if ( is_bool( $context ) && $context ) { |
|
| 1368 | - return wpinv_price( $subtotal, $this->get_currency() ); |
|
| 1367 | + if (is_bool($context) && $context) { |
|
| 1368 | + return wpinv_price($subtotal, $this->get_currency()); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | 1371 | return $subtotal; |
@@ -1378,8 +1378,8 @@ discard block |
||
| 1378 | 1378 | * @param string $context View or edit context. |
| 1379 | 1379 | * @return float |
| 1380 | 1380 | */ |
| 1381 | - public function get_total_discount( $context = 'view' ) { |
|
| 1382 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
| 1381 | + public function get_total_discount($context = 'view') { |
|
| 1382 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context))); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | 1385 | /** |
@@ -1389,18 +1389,18 @@ discard block |
||
| 1389 | 1389 | * @param string $context View or edit context. |
| 1390 | 1390 | * @return float |
| 1391 | 1391 | */ |
| 1392 | - public function get_total_tax( $context = 'view' ) { |
|
| 1393 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
| 1392 | + public function get_total_tax($context = 'view') { |
|
| 1393 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context))); |
|
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | 1396 | /** |
| 1397 | 1397 | * @deprecated |
| 1398 | 1398 | */ |
| 1399 | - public function get_final_tax( $currency = false ) { |
|
| 1399 | + public function get_final_tax($currency = false) { |
|
| 1400 | 1400 | $tax = $this->get_total_tax(); |
| 1401 | 1401 | |
| 1402 | - if ( $currency ) { |
|
| 1403 | - return wpinv_price( $tax, $this->get_currency() ); |
|
| 1402 | + if ($currency) { |
|
| 1403 | + return wpinv_price($tax, $this->get_currency()); |
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | return $tax; |
@@ -1413,8 +1413,8 @@ discard block |
||
| 1413 | 1413 | * @param string $context View or edit context. |
| 1414 | 1414 | * @return float |
| 1415 | 1415 | */ |
| 1416 | - public function get_total_fees( $context = 'view' ) { |
|
| 1417 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
| 1416 | + public function get_total_fees($context = 'view') { |
|
| 1417 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context))); |
|
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | 1420 | /** |
@@ -1424,8 +1424,8 @@ discard block |
||
| 1424 | 1424 | * @param string $context View or edit context. |
| 1425 | 1425 | * @return float |
| 1426 | 1426 | */ |
| 1427 | - public function get_fees_total( $context = 'view' ) { |
|
| 1428 | - return $this->get_total_fees( $context ); |
|
| 1427 | + public function get_fees_total($context = 'view') { |
|
| 1428 | + return $this->get_total_fees($context); |
|
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | /** |
@@ -1434,8 +1434,8 @@ discard block |
||
| 1434 | 1434 | * @since 1.0.19 |
| 1435 | 1435 | * @return float |
| 1436 | 1436 | */ |
| 1437 | - public function get_total( $context = 'view' ) { |
|
| 1438 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) ); |
|
| 1437 | + public function get_total($context = 'view') { |
|
| 1438 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total', $context))); |
|
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | /** |
@@ -1447,20 +1447,20 @@ discard block |
||
| 1447 | 1447 | public function get_non_recurring_total() { |
| 1448 | 1448 | |
| 1449 | 1449 | $subtotal = 0; |
| 1450 | - foreach ( $this->get_items() as $item ) { |
|
| 1451 | - if ( ! $item->is_recurring() ) { |
|
| 1450 | + foreach ($this->get_items() as $item) { |
|
| 1451 | + if (!$item->is_recurring()) { |
|
| 1452 | 1452 | $subtotal += $item->get_sub_total(); |
| 1453 | 1453 | } |
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | - foreach ( $this->get_fees() as $fee ) { |
|
| 1457 | - if ( empty( $fee['recurring_fee'] ) ) { |
|
| 1458 | - $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
| 1456 | + foreach ($this->get_fees() as $fee) { |
|
| 1457 | + if (empty($fee['recurring_fee'])) { |
|
| 1458 | + $subtotal += wpinv_sanitize_amount($fee['initial_fee']); |
|
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | - $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
| 1463 | - return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this ); |
|
| 1462 | + $subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal)); |
|
| 1463 | + return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this); |
|
| 1464 | 1464 | |
| 1465 | 1465 | } |
| 1466 | 1466 | |
@@ -1483,7 +1483,7 @@ discard block |
||
| 1483 | 1483 | */ |
| 1484 | 1484 | public function get_initial_total() { |
| 1485 | 1485 | |
| 1486 | - if ( empty( $this->totals ) ) { |
|
| 1486 | + if (empty($this->totals)) { |
|
| 1487 | 1487 | $this->recalculate_total(); |
| 1488 | 1488 | } |
| 1489 | 1489 | |
@@ -1493,12 +1493,12 @@ discard block |
||
| 1493 | 1493 | $subtotal = $this->totals['subtotal']['initial']; |
| 1494 | 1494 | $total = $tax + $fee - $discount + $subtotal; |
| 1495 | 1495 | |
| 1496 | - if ( 0 > $total ) { |
|
| 1496 | + if (0 > $total) { |
|
| 1497 | 1497 | $total = 0; |
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1501 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1500 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
| 1501 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | 1504 | /** |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | */ |
| 1511 | 1511 | public function get_recurring_total() { |
| 1512 | 1512 | |
| 1513 | - if ( empty( $this->totals ) ) { |
|
| 1513 | + if (empty($this->totals)) { |
|
| 1514 | 1514 | $this->recalculate_total(); |
| 1515 | 1515 | } |
| 1516 | 1516 | |
@@ -1520,12 +1520,12 @@ discard block |
||
| 1520 | 1520 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1521 | 1521 | $total = $tax + $fee - $discount + $subtotal; |
| 1522 | 1522 | |
| 1523 | - if ( 0 > $total ) { |
|
| 1523 | + if (0 > $total) { |
|
| 1524 | 1524 | $total = 0; |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
| 1528 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1527 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
| 1528 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1529 | 1529 | } |
| 1530 | 1530 | |
| 1531 | 1531 | /** |
@@ -1536,10 +1536,10 @@ discard block |
||
| 1536 | 1536 | * @param string $currency Whether to include the currency. |
| 1537 | 1537 | * @return float|string |
| 1538 | 1538 | */ |
| 1539 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1539 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1540 | 1540 | |
| 1541 | 1541 | // Maybe recalculate totals. |
| 1542 | - if ( empty( $this->totals ) ) { |
|
| 1542 | + if (empty($this->totals)) { |
|
| 1543 | 1543 | $this->recalculate_total(); |
| 1544 | 1544 | } |
| 1545 | 1545 | |
@@ -1559,8 +1559,8 @@ discard block |
||
| 1559 | 1559 | $currency |
| 1560 | 1560 | ); |
| 1561 | 1561 | |
| 1562 | - if ( isset( $data[$field] ) ) { |
|
| 1563 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1562 | + if (isset($data[$field])) { |
|
| 1563 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | return $data; |
@@ -1573,8 +1573,8 @@ discard block |
||
| 1573 | 1573 | * @param string $context View or edit context. |
| 1574 | 1574 | * @return array |
| 1575 | 1575 | */ |
| 1576 | - public function get_fees( $context = 'view' ) { |
|
| 1577 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1576 | + public function get_fees($context = 'view') { |
|
| 1577 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | 1580 | /** |
@@ -1584,8 +1584,8 @@ discard block |
||
| 1584 | 1584 | * @param string $context View or edit context. |
| 1585 | 1585 | * @return array |
| 1586 | 1586 | */ |
| 1587 | - public function get_discounts( $context = 'view' ) { |
|
| 1588 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1587 | + public function get_discounts($context = 'view') { |
|
| 1588 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | /** |
@@ -1595,8 +1595,8 @@ discard block |
||
| 1595 | 1595 | * @param string $context View or edit context. |
| 1596 | 1596 | * @return array |
| 1597 | 1597 | */ |
| 1598 | - public function get_taxes( $context = 'view' ) { |
|
| 1599 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1598 | + public function get_taxes($context = 'view') { |
|
| 1599 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | 1602 | /** |
@@ -1606,8 +1606,8 @@ discard block |
||
| 1606 | 1606 | * @param string $context View or edit context. |
| 1607 | 1607 | * @return GetPaid_Form_Item[] |
| 1608 | 1608 | */ |
| 1609 | - public function get_items( $context = 'view' ) { |
|
| 1610 | - return $this->get_prop( 'items', $context ); |
|
| 1609 | + public function get_items($context = 'view') { |
|
| 1610 | + return $this->get_prop('items', $context); |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | /** |
@@ -1617,7 +1617,7 @@ discard block |
||
| 1617 | 1617 | * @return string |
| 1618 | 1618 | */ |
| 1619 | 1619 | public function get_item_ids() { |
| 1620 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
| 1620 | + return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id')); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | /** |
@@ -1627,8 +1627,8 @@ discard block |
||
| 1627 | 1627 | * @param string $context View or edit context. |
| 1628 | 1628 | * @return int |
| 1629 | 1629 | */ |
| 1630 | - public function get_payment_form( $context = 'view' ) { |
|
| 1631 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1630 | + public function get_payment_form($context = 'view') { |
|
| 1631 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | /** |
@@ -1638,8 +1638,8 @@ discard block |
||
| 1638 | 1638 | * @param string $context View or edit context. |
| 1639 | 1639 | * @return string |
| 1640 | 1640 | */ |
| 1641 | - public function get_submission_id( $context = 'view' ) { |
|
| 1642 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1641 | + public function get_submission_id($context = 'view') { |
|
| 1642 | + return $this->get_prop('submission_id', $context); |
|
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | 1645 | /** |
@@ -1649,8 +1649,8 @@ discard block |
||
| 1649 | 1649 | * @param string $context View or edit context. |
| 1650 | 1650 | * @return string |
| 1651 | 1651 | */ |
| 1652 | - public function get_discount_code( $context = 'view' ) { |
|
| 1653 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1652 | + public function get_discount_code($context = 'view') { |
|
| 1653 | + return $this->get_prop('discount_code', $context); |
|
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | /** |
@@ -1660,8 +1660,8 @@ discard block |
||
| 1660 | 1660 | * @param string $context View or edit context. |
| 1661 | 1661 | * @return string |
| 1662 | 1662 | */ |
| 1663 | - public function get_gateway( $context = 'view' ) { |
|
| 1664 | - return $this->get_prop( 'gateway', $context ); |
|
| 1663 | + public function get_gateway($context = 'view') { |
|
| 1664 | + return $this->get_prop('gateway', $context); |
|
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | /** |
@@ -1671,8 +1671,8 @@ discard block |
||
| 1671 | 1671 | * @return string |
| 1672 | 1672 | */ |
| 1673 | 1673 | public function get_gateway_title() { |
| 1674 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1675 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1674 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1675 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | 1678 | /** |
@@ -1682,8 +1682,8 @@ discard block |
||
| 1682 | 1682 | * @param string $context View or edit context. |
| 1683 | 1683 | * @return string |
| 1684 | 1684 | */ |
| 1685 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1686 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1685 | + public function get_transaction_id($context = 'view') { |
|
| 1686 | + return $this->get_prop('transaction_id', $context); |
|
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | 1689 | /** |
@@ -1693,9 +1693,9 @@ discard block |
||
| 1693 | 1693 | * @param string $context View or edit context. |
| 1694 | 1694 | * @return string |
| 1695 | 1695 | */ |
| 1696 | - public function get_currency( $context = 'view' ) { |
|
| 1697 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1698 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1696 | + public function get_currency($context = 'view') { |
|
| 1697 | + $currency = $this->get_prop('currency', $context); |
|
| 1698 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | 1701 | /** |
@@ -1705,8 +1705,8 @@ discard block |
||
| 1705 | 1705 | * @param string $context View or edit context. |
| 1706 | 1706 | * @return bool |
| 1707 | 1707 | */ |
| 1708 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1709 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1708 | + public function get_disable_taxes($context = 'view') { |
|
| 1709 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | /** |
@@ -1716,8 +1716,8 @@ discard block |
||
| 1716 | 1716 | * @param string $context View or edit context. |
| 1717 | 1717 | * @return int |
| 1718 | 1718 | */ |
| 1719 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1720 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1719 | + public function get_subscription_id($context = 'view') { |
|
| 1720 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | 1723 | /** |
@@ -1727,12 +1727,12 @@ discard block |
||
| 1727 | 1727 | * @param string $context View or edit context. |
| 1728 | 1728 | * @return int |
| 1729 | 1729 | */ |
| 1730 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
| 1731 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
| 1730 | + public function get_remote_subscription_id($context = 'view') { |
|
| 1731 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
| 1732 | 1732 | |
| 1733 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1733 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1734 | 1734 | $parent = $this->get_parent(); |
| 1735 | - return $parent->get_remote_subscription_id( $context ); |
|
| 1735 | + return $parent->get_remote_subscription_id($context); |
|
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | 1738 | return $subscription_id; |
@@ -1745,20 +1745,20 @@ discard block |
||
| 1745 | 1745 | * @param string $context View or edit context. |
| 1746 | 1746 | * @return array |
| 1747 | 1747 | */ |
| 1748 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1748 | + public function get_payment_meta($context = 'view') { |
|
| 1749 | 1749 | |
| 1750 | 1750 | return array( |
| 1751 | - 'price' => $this->get_total( $context ), |
|
| 1752 | - 'date' => $this->get_date_created( $context ), |
|
| 1753 | - 'user_email' => $this->get_email( $context ), |
|
| 1754 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1755 | - 'currency' => $this->get_currency( $context ), |
|
| 1756 | - 'items' => $this->get_items( $context ), |
|
| 1757 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1751 | + 'price' => $this->get_total($context), |
|
| 1752 | + 'date' => $this->get_date_created($context), |
|
| 1753 | + 'user_email' => $this->get_email($context), |
|
| 1754 | + 'invoice_key' => $this->get_key($context), |
|
| 1755 | + 'currency' => $this->get_currency($context), |
|
| 1756 | + 'items' => $this->get_items($context), |
|
| 1757 | + 'user_info' => $this->get_user_info($context), |
|
| 1758 | 1758 | 'cart_details' => $this->get_cart_details(), |
| 1759 | - 'status' => $this->get_status( $context ), |
|
| 1760 | - 'fees' => $this->get_fees( $context ), |
|
| 1761 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1759 | + 'status' => $this->get_status($context), |
|
| 1760 | + 'fees' => $this->get_fees($context), |
|
| 1761 | + 'taxes' => $this->get_taxes($context), |
|
| 1762 | 1762 | ); |
| 1763 | 1763 | |
| 1764 | 1764 | } |
@@ -1773,9 +1773,9 @@ discard block |
||
| 1773 | 1773 | $items = $this->get_items(); |
| 1774 | 1774 | $cart_details = array(); |
| 1775 | 1775 | |
| 1776 | - foreach ( $items as $item ) { |
|
| 1776 | + foreach ($items as $item) { |
|
| 1777 | 1777 | $item->invoice_id = $this->get_id(); |
| 1778 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1778 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1779 | 1779 | } |
| 1780 | 1780 | |
| 1781 | 1781 | return $cart_details; |
@@ -1786,11 +1786,11 @@ discard block |
||
| 1786 | 1786 | * |
| 1787 | 1787 | * @return null|GetPaid_Form_Item|int |
| 1788 | 1788 | */ |
| 1789 | - public function get_recurring( $object = false ) { |
|
| 1789 | + public function get_recurring($object = false) { |
|
| 1790 | 1790 | |
| 1791 | 1791 | // Are we returning an object? |
| 1792 | - if ( $object ) { |
|
| 1793 | - return $this->get_item( $this->recurring_item ); |
|
| 1792 | + if ($object) { |
|
| 1793 | + return $this->get_item($this->recurring_item); |
|
| 1794 | 1794 | } |
| 1795 | 1795 | |
| 1796 | 1796 | return $this->recurring_item; |
@@ -1805,15 +1805,15 @@ discard block |
||
| 1805 | 1805 | public function get_subscription_name() { |
| 1806 | 1806 | |
| 1807 | 1807 | // Retrieve the recurring name |
| 1808 | - $item = $this->get_recurring( true ); |
|
| 1808 | + $item = $this->get_recurring(true); |
|
| 1809 | 1809 | |
| 1810 | 1810 | // Abort if it does not exist. |
| 1811 | - if ( empty( $item ) ) { |
|
| 1811 | + if (empty($item)) { |
|
| 1812 | 1812 | return ''; |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | 1815 | // Return the item name. |
| 1816 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1816 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | 1819 | /** |
@@ -1823,9 +1823,9 @@ discard block |
||
| 1823 | 1823 | * @return string |
| 1824 | 1824 | */ |
| 1825 | 1825 | public function get_view_url() { |
| 1826 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1827 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1828 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1826 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1827 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1828 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | 1831 | /** |
@@ -1834,25 +1834,25 @@ discard block |
||
| 1834 | 1834 | * @since 1.0.19 |
| 1835 | 1835 | * @return string |
| 1836 | 1836 | */ |
| 1837 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1837 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1838 | 1838 | |
| 1839 | 1839 | // Retrieve the checkout url. |
| 1840 | 1840 | $pay_url = wpinv_get_checkout_uri(); |
| 1841 | 1841 | |
| 1842 | 1842 | // Maybe force ssl. |
| 1843 | - if ( is_ssl() ) { |
|
| 1844 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1843 | + if (is_ssl()) { |
|
| 1844 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | 1847 | // Add the invoice key. |
| 1848 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1848 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1849 | 1849 | |
| 1850 | 1850 | // (Maybe?) add a secret |
| 1851 | - if ( $secret ) { |
|
| 1852 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1851 | + if ($secret) { |
|
| 1852 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1855 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | /** |
@@ -1867,14 +1867,14 @@ discard block |
||
| 1867 | 1867 | $receipt_url = wpinv_get_success_page_uri(); |
| 1868 | 1868 | |
| 1869 | 1869 | // Maybe force ssl. |
| 1870 | - if ( is_ssl() ) { |
|
| 1871 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
| 1870 | + if (is_ssl()) { |
|
| 1871 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | 1874 | // Add the invoice key. |
| 1875 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1875 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
| 1876 | 1876 | |
| 1877 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
| 1877 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | 1880 | /** |
@@ -1887,7 +1887,7 @@ discard block |
||
| 1887 | 1887 | |
| 1888 | 1888 | $type = $this->get_type(); |
| 1889 | 1889 | $status = "wpi-$type-pending"; |
| 1890 | - return str_replace( '-invoice', '', $status ); |
|
| 1890 | + return str_replace('-invoice', '', $status); |
|
| 1891 | 1891 | |
| 1892 | 1892 | } |
| 1893 | 1893 | |
@@ -1901,8 +1901,8 @@ discard block |
||
| 1901 | 1901 | * @param string $context View or edit context. |
| 1902 | 1902 | * @return mixed Value of the given invoice property (if set). |
| 1903 | 1903 | */ |
| 1904 | - public function get( $key, $context = 'view' ) { |
|
| 1905 | - return $this->get_prop( $key, $context ); |
|
| 1904 | + public function get($key, $context = 'view') { |
|
| 1905 | + return $this->get_prop($key, $context); |
|
| 1906 | 1906 | } |
| 1907 | 1907 | |
| 1908 | 1908 | /* |
@@ -1925,11 +1925,11 @@ discard block |
||
| 1925 | 1925 | * @param mixed $value new value. |
| 1926 | 1926 | * @return mixed Value of the given invoice property (if set). |
| 1927 | 1927 | */ |
| 1928 | - public function set( $key, $value ) { |
|
| 1928 | + public function set($key, $value) { |
|
| 1929 | 1929 | |
| 1930 | 1930 | $setter = "set_$key"; |
| 1931 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1932 | - $this->{$setter}( $value ); |
|
| 1931 | + if (is_callable(array($this, $setter))) { |
|
| 1932 | + $this->{$setter}($value); |
|
| 1933 | 1933 | } |
| 1934 | 1934 | |
| 1935 | 1935 | } |
@@ -1943,45 +1943,45 @@ discard block |
||
| 1943 | 1943 | * @param bool $manual_update Is this a manual status change?. |
| 1944 | 1944 | * @return array details of change. |
| 1945 | 1945 | */ |
| 1946 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1946 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1947 | 1947 | $old_status = $this->get_status(); |
| 1948 | 1948 | |
| 1949 | 1949 | $statuses = $this->get_all_statuses(); |
| 1950 | 1950 | |
| 1951 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1952 | - unset( $statuses[ 'draft' ] ); |
|
| 1951 | + if (isset($statuses['draft'])) { |
|
| 1952 | + unset($statuses['draft']); |
|
| 1953 | 1953 | } |
| 1954 | 1954 | |
| 1955 | - $this->set_prop( 'status', $new_status ); |
|
| 1955 | + $this->set_prop('status', $new_status); |
|
| 1956 | 1956 | |
| 1957 | 1957 | // If setting the status, ensure it's set to a valid status. |
| 1958 | - if ( true === $this->object_read ) { |
|
| 1958 | + if (true === $this->object_read) { |
|
| 1959 | 1959 | |
| 1960 | 1960 | // Only allow valid new status. |
| 1961 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1961 | + if (!array_key_exists($new_status, $statuses)) { |
|
| 1962 | 1962 | $new_status = $this->get_default_status(); |
| 1963 | 1963 | } |
| 1964 | 1964 | |
| 1965 | 1965 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1966 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1966 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
| 1967 | 1967 | $old_status = $this->get_default_status(); |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | 1970 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
| 1971 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1971 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
| 1972 | 1972 | $old_status = 'wpi-pending'; |
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | - if ( $old_status !== $new_status ) { |
|
| 1975 | + if ($old_status !== $new_status) { |
|
| 1976 | 1976 | $this->status_transition = array( |
| 1977 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1977 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1978 | 1978 | 'to' => $new_status, |
| 1979 | 1979 | 'note' => $note, |
| 1980 | 1980 | 'manual' => (bool) $manual_update, |
| 1981 | 1981 | ); |
| 1982 | 1982 | |
| 1983 | - if ( $manual_update ) { |
|
| 1984 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1983 | + if ($manual_update) { |
|
| 1984 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | $this->maybe_set_date_paid(); |
@@ -2006,8 +2006,8 @@ discard block |
||
| 2006 | 2006 | */ |
| 2007 | 2007 | public function maybe_set_date_paid() { |
| 2008 | 2008 | |
| 2009 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 2010 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 2009 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 2010 | + $this->set_date_completed(current_time('mysql')); |
|
| 2011 | 2011 | } |
| 2012 | 2012 | } |
| 2013 | 2013 | |
@@ -2016,11 +2016,11 @@ discard block |
||
| 2016 | 2016 | * |
| 2017 | 2017 | * @since 1.0.19 |
| 2018 | 2018 | */ |
| 2019 | - public function set_parent_id( $value ) { |
|
| 2020 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 2019 | + public function set_parent_id($value) { |
|
| 2020 | + if ($value && ($value === $this->get_id())) { |
|
| 2021 | 2021 | return; |
| 2022 | 2022 | } |
| 2023 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 2023 | + $this->set_prop('parent_id', absint($value)); |
|
| 2024 | 2024 | } |
| 2025 | 2025 | |
| 2026 | 2026 | /** |
@@ -2028,8 +2028,8 @@ discard block |
||
| 2028 | 2028 | * |
| 2029 | 2029 | * @since 1.0.19 |
| 2030 | 2030 | */ |
| 2031 | - public function set_version( $value ) { |
|
| 2032 | - $this->set_prop( 'version', $value ); |
|
| 2031 | + public function set_version($value) { |
|
| 2032 | + $this->set_prop('version', $value); |
|
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | 2035 | /** |
@@ -2039,15 +2039,15 @@ discard block |
||
| 2039 | 2039 | * @param string $value Value to set. |
| 2040 | 2040 | * @return bool Whether or not the date was set. |
| 2041 | 2041 | */ |
| 2042 | - public function set_date_created( $value ) { |
|
| 2043 | - $date = strtotime( $value ); |
|
| 2042 | + public function set_date_created($value) { |
|
| 2043 | + $date = strtotime($value); |
|
| 2044 | 2044 | |
| 2045 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2046 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2045 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2046 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 2047 | 2047 | return true; |
| 2048 | 2048 | } |
| 2049 | 2049 | |
| 2050 | - $this->set_prop( 'date_created', '' ); |
|
| 2050 | + $this->set_prop('date_created', ''); |
|
| 2051 | 2051 | return false; |
| 2052 | 2052 | |
| 2053 | 2053 | } |
@@ -2059,15 +2059,15 @@ discard block |
||
| 2059 | 2059 | * @param string $value Value to set. |
| 2060 | 2060 | * @return bool Whether or not the date was set. |
| 2061 | 2061 | */ |
| 2062 | - public function set_due_date( $value ) { |
|
| 2063 | - $date = strtotime( $value ); |
|
| 2062 | + public function set_due_date($value) { |
|
| 2063 | + $date = strtotime($value); |
|
| 2064 | 2064 | |
| 2065 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2066 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2065 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2066 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 2067 | 2067 | return true; |
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | - $this->set_prop( 'due_date', '' ); |
|
| 2070 | + $this->set_prop('due_date', ''); |
|
| 2071 | 2071 | return false; |
| 2072 | 2072 | |
| 2073 | 2073 | } |
@@ -2078,8 +2078,8 @@ discard block |
||
| 2078 | 2078 | * @since 1.0.19 |
| 2079 | 2079 | * @param string $value New name. |
| 2080 | 2080 | */ |
| 2081 | - public function set_date_due( $value ) { |
|
| 2082 | - $this->set_due_date( $value ); |
|
| 2081 | + public function set_date_due($value) { |
|
| 2082 | + $this->set_due_date($value); |
|
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | /** |
@@ -2089,15 +2089,15 @@ discard block |
||
| 2089 | 2089 | * @param string $value Value to set. |
| 2090 | 2090 | * @return bool Whether or not the date was set. |
| 2091 | 2091 | */ |
| 2092 | - public function set_completed_date( $value ) { |
|
| 2093 | - $date = strtotime( $value ); |
|
| 2092 | + public function set_completed_date($value) { |
|
| 2093 | + $date = strtotime($value); |
|
| 2094 | 2094 | |
| 2095 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2096 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2095 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2096 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 2097 | 2097 | return true; |
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | - $this->set_prop( 'completed_date', '' ); |
|
| 2100 | + $this->set_prop('completed_date', ''); |
|
| 2101 | 2101 | return false; |
| 2102 | 2102 | |
| 2103 | 2103 | } |
@@ -2108,8 +2108,8 @@ discard block |
||
| 2108 | 2108 | * @since 1.0.19 |
| 2109 | 2109 | * @param string $value New name. |
| 2110 | 2110 | */ |
| 2111 | - public function set_date_completed( $value ) { |
|
| 2112 | - $this->set_completed_date( $value ); |
|
| 2111 | + public function set_date_completed($value) { |
|
| 2112 | + $this->set_completed_date($value); |
|
| 2113 | 2113 | } |
| 2114 | 2114 | |
| 2115 | 2115 | /** |
@@ -2119,15 +2119,15 @@ discard block |
||
| 2119 | 2119 | * @param string $value Value to set. |
| 2120 | 2120 | * @return bool Whether or not the date was set. |
| 2121 | 2121 | */ |
| 2122 | - public function set_date_modified( $value ) { |
|
| 2123 | - $date = strtotime( $value ); |
|
| 2122 | + public function set_date_modified($value) { |
|
| 2123 | + $date = strtotime($value); |
|
| 2124 | 2124 | |
| 2125 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2126 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2125 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2126 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 2127 | 2127 | return true; |
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | - $this->set_prop( 'date_modified', '' ); |
|
| 2130 | + $this->set_prop('date_modified', ''); |
|
| 2131 | 2131 | return false; |
| 2132 | 2132 | |
| 2133 | 2133 | } |
@@ -2138,9 +2138,9 @@ discard block |
||
| 2138 | 2138 | * @since 1.0.19 |
| 2139 | 2139 | * @param string $value New number. |
| 2140 | 2140 | */ |
| 2141 | - public function set_number( $value ) { |
|
| 2142 | - $number = sanitize_text_field( $value ); |
|
| 2143 | - $this->set_prop( 'number', $number ); |
|
| 2141 | + public function set_number($value) { |
|
| 2142 | + $number = sanitize_text_field($value); |
|
| 2143 | + $this->set_prop('number', $number); |
|
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | /** |
@@ -2149,9 +2149,9 @@ discard block |
||
| 2149 | 2149 | * @since 1.0.19 |
| 2150 | 2150 | * @param string $value Type. |
| 2151 | 2151 | */ |
| 2152 | - public function set_type( $value ) { |
|
| 2153 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 2154 | - $this->set_prop( 'type', $type ); |
|
| 2152 | + public function set_type($value) { |
|
| 2153 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 2154 | + $this->set_prop('type', $type); |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | /** |
@@ -2160,10 +2160,10 @@ discard block |
||
| 2160 | 2160 | * @since 1.0.19 |
| 2161 | 2161 | * @param string $value Post type. |
| 2162 | 2162 | */ |
| 2163 | - public function set_post_type( $value ) { |
|
| 2164 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 2165 | - $this->set_type( $value ); |
|
| 2166 | - $this->set_prop( 'post_type', $value ); |
|
| 2163 | + public function set_post_type($value) { |
|
| 2164 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 2165 | + $this->set_type($value); |
|
| 2166 | + $this->set_prop('post_type', $value); |
|
| 2167 | 2167 | } |
| 2168 | 2168 | } |
| 2169 | 2169 | |
@@ -2173,9 +2173,9 @@ discard block |
||
| 2173 | 2173 | * @since 1.0.19 |
| 2174 | 2174 | * @param string $value New key. |
| 2175 | 2175 | */ |
| 2176 | - public function set_key( $value ) { |
|
| 2177 | - $key = sanitize_text_field( $value ); |
|
| 2178 | - $this->set_prop( 'key', $key ); |
|
| 2176 | + public function set_key($value) { |
|
| 2177 | + $key = sanitize_text_field($value); |
|
| 2178 | + $this->set_prop('key', $key); |
|
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | 2181 | /** |
@@ -2184,9 +2184,9 @@ discard block |
||
| 2184 | 2184 | * @since 1.0.19 |
| 2185 | 2185 | * @param string $value mode. |
| 2186 | 2186 | */ |
| 2187 | - public function set_mode( $value ) { |
|
| 2188 | - if ( in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2189 | - $this->set_prop( 'mode', $value ); |
|
| 2187 | + public function set_mode($value) { |
|
| 2188 | + if (in_array($value, array('live', 'test'))) { |
|
| 2189 | + $this->set_prop('mode', $value); |
|
| 2190 | 2190 | } |
| 2191 | 2191 | } |
| 2192 | 2192 | |
@@ -2196,8 +2196,8 @@ discard block |
||
| 2196 | 2196 | * @since 1.0.19 |
| 2197 | 2197 | * @param string $value path. |
| 2198 | 2198 | */ |
| 2199 | - public function set_path( $value ) { |
|
| 2200 | - $this->set_prop( 'path', $value ); |
|
| 2199 | + public function set_path($value) { |
|
| 2200 | + $this->set_prop('path', $value); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | 2203 | /** |
@@ -2206,9 +2206,9 @@ discard block |
||
| 2206 | 2206 | * @since 1.0.19 |
| 2207 | 2207 | * @param string $value New name. |
| 2208 | 2208 | */ |
| 2209 | - public function set_name( $value ) { |
|
| 2210 | - $name = sanitize_text_field( $value ); |
|
| 2211 | - $this->set_prop( 'name', $name ); |
|
| 2209 | + public function set_name($value) { |
|
| 2210 | + $name = sanitize_text_field($value); |
|
| 2211 | + $this->set_prop('name', $name); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | |
| 2214 | 2214 | /** |
@@ -2217,8 +2217,8 @@ discard block |
||
| 2217 | 2217 | * @since 1.0.19 |
| 2218 | 2218 | * @param string $value New name. |
| 2219 | 2219 | */ |
| 2220 | - public function set_title( $value ) { |
|
| 2221 | - $this->set_name( $value ); |
|
| 2220 | + public function set_title($value) { |
|
| 2221 | + $this->set_name($value); |
|
| 2222 | 2222 | } |
| 2223 | 2223 | |
| 2224 | 2224 | /** |
@@ -2227,9 +2227,9 @@ discard block |
||
| 2227 | 2227 | * @since 1.0.19 |
| 2228 | 2228 | * @param string $value New description. |
| 2229 | 2229 | */ |
| 2230 | - public function set_description( $value ) { |
|
| 2231 | - $description = wp_kses_post( $value ); |
|
| 2232 | - $this->set_prop( 'description', $description ); |
|
| 2230 | + public function set_description($value) { |
|
| 2231 | + $description = wp_kses_post($value); |
|
| 2232 | + $this->set_prop('description', $description); |
|
| 2233 | 2233 | } |
| 2234 | 2234 | |
| 2235 | 2235 | /** |
@@ -2238,8 +2238,8 @@ discard block |
||
| 2238 | 2238 | * @since 1.0.19 |
| 2239 | 2239 | * @param string $value New description. |
| 2240 | 2240 | */ |
| 2241 | - public function set_excerpt( $value ) { |
|
| 2242 | - $this->set_description( $value ); |
|
| 2241 | + public function set_excerpt($value) { |
|
| 2242 | + $this->set_description($value); |
|
| 2243 | 2243 | } |
| 2244 | 2244 | |
| 2245 | 2245 | /** |
@@ -2248,8 +2248,8 @@ discard block |
||
| 2248 | 2248 | * @since 1.0.19 |
| 2249 | 2249 | * @param string $value New description. |
| 2250 | 2250 | */ |
| 2251 | - public function set_summary( $value ) { |
|
| 2252 | - $this->set_description( $value ); |
|
| 2251 | + public function set_summary($value) { |
|
| 2252 | + $this->set_description($value); |
|
| 2253 | 2253 | } |
| 2254 | 2254 | |
| 2255 | 2255 | /** |
@@ -2258,12 +2258,12 @@ discard block |
||
| 2258 | 2258 | * @since 1.0.19 |
| 2259 | 2259 | * @param int $value New author. |
| 2260 | 2260 | */ |
| 2261 | - public function set_author( $value ) { |
|
| 2262 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2261 | + public function set_author($value) { |
|
| 2262 | + $user = get_user_by('id', (int) $value); |
|
| 2263 | 2263 | |
| 2264 | - if ( $user && $user->ID ) { |
|
| 2265 | - $this->set_prop( 'author', $user->ID ); |
|
| 2266 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2264 | + if ($user && $user->ID) { |
|
| 2265 | + $this->set_prop('author', $user->ID); |
|
| 2266 | + $this->set_prop('email', $user->user_email); |
|
| 2267 | 2267 | } |
| 2268 | 2268 | |
| 2269 | 2269 | } |
@@ -2274,8 +2274,8 @@ discard block |
||
| 2274 | 2274 | * @since 1.0.19 |
| 2275 | 2275 | * @param int $value New user id. |
| 2276 | 2276 | */ |
| 2277 | - public function set_user_id( $value ) { |
|
| 2278 | - $this->set_author( $value ); |
|
| 2277 | + public function set_user_id($value) { |
|
| 2278 | + $this->set_author($value); |
|
| 2279 | 2279 | } |
| 2280 | 2280 | |
| 2281 | 2281 | /** |
@@ -2284,8 +2284,8 @@ discard block |
||
| 2284 | 2284 | * @since 1.0.19 |
| 2285 | 2285 | * @param int $value New user id. |
| 2286 | 2286 | */ |
| 2287 | - public function set_customer_id( $value ) { |
|
| 2288 | - $this->set_author( $value ); |
|
| 2287 | + public function set_customer_id($value) { |
|
| 2288 | + $this->set_author($value); |
|
| 2289 | 2289 | } |
| 2290 | 2290 | |
| 2291 | 2291 | /** |
@@ -2294,8 +2294,8 @@ discard block |
||
| 2294 | 2294 | * @since 1.0.19 |
| 2295 | 2295 | * @param string $value ip address. |
| 2296 | 2296 | */ |
| 2297 | - public function set_ip( $value ) { |
|
| 2298 | - $this->set_prop( 'ip', $value ); |
|
| 2297 | + public function set_ip($value) { |
|
| 2298 | + $this->set_prop('ip', $value); |
|
| 2299 | 2299 | } |
| 2300 | 2300 | |
| 2301 | 2301 | /** |
@@ -2304,8 +2304,8 @@ discard block |
||
| 2304 | 2304 | * @since 1.0.19 |
| 2305 | 2305 | * @param string $value ip address. |
| 2306 | 2306 | */ |
| 2307 | - public function set_user_ip( $value ) { |
|
| 2308 | - $this->set_ip( $value ); |
|
| 2307 | + public function set_user_ip($value) { |
|
| 2308 | + $this->set_ip($value); |
|
| 2309 | 2309 | } |
| 2310 | 2310 | |
| 2311 | 2311 | /** |
@@ -2314,8 +2314,8 @@ discard block |
||
| 2314 | 2314 | * @since 1.0.19 |
| 2315 | 2315 | * @param string $value first name. |
| 2316 | 2316 | */ |
| 2317 | - public function set_first_name( $value ) { |
|
| 2318 | - $this->set_prop( 'first_name', $value ); |
|
| 2317 | + public function set_first_name($value) { |
|
| 2318 | + $this->set_prop('first_name', $value); |
|
| 2319 | 2319 | } |
| 2320 | 2320 | |
| 2321 | 2321 | /** |
@@ -2324,8 +2324,8 @@ discard block |
||
| 2324 | 2324 | * @since 1.0.19 |
| 2325 | 2325 | * @param string $value first name. |
| 2326 | 2326 | */ |
| 2327 | - public function set_user_first_name( $value ) { |
|
| 2328 | - $this->set_first_name( $value ); |
|
| 2327 | + public function set_user_first_name($value) { |
|
| 2328 | + $this->set_first_name($value); |
|
| 2329 | 2329 | } |
| 2330 | 2330 | |
| 2331 | 2331 | /** |
@@ -2334,8 +2334,8 @@ discard block |
||
| 2334 | 2334 | * @since 1.0.19 |
| 2335 | 2335 | * @param string $value first name. |
| 2336 | 2336 | */ |
| 2337 | - public function set_customer_first_name( $value ) { |
|
| 2338 | - $this->set_first_name( $value ); |
|
| 2337 | + public function set_customer_first_name($value) { |
|
| 2338 | + $this->set_first_name($value); |
|
| 2339 | 2339 | } |
| 2340 | 2340 | |
| 2341 | 2341 | /** |
@@ -2344,8 +2344,8 @@ discard block |
||
| 2344 | 2344 | * @since 1.0.19 |
| 2345 | 2345 | * @param string $value last name. |
| 2346 | 2346 | */ |
| 2347 | - public function set_last_name( $value ) { |
|
| 2348 | - $this->set_prop( 'last_name', $value ); |
|
| 2347 | + public function set_last_name($value) { |
|
| 2348 | + $this->set_prop('last_name', $value); |
|
| 2349 | 2349 | } |
| 2350 | 2350 | |
| 2351 | 2351 | /** |
@@ -2354,8 +2354,8 @@ discard block |
||
| 2354 | 2354 | * @since 1.0.19 |
| 2355 | 2355 | * @param string $value last name. |
| 2356 | 2356 | */ |
| 2357 | - public function set_user_last_name( $value ) { |
|
| 2358 | - $this->set_last_name( $value ); |
|
| 2357 | + public function set_user_last_name($value) { |
|
| 2358 | + $this->set_last_name($value); |
|
| 2359 | 2359 | } |
| 2360 | 2360 | |
| 2361 | 2361 | /** |
@@ -2364,8 +2364,8 @@ discard block |
||
| 2364 | 2364 | * @since 1.0.19 |
| 2365 | 2365 | * @param string $value last name. |
| 2366 | 2366 | */ |
| 2367 | - public function set_customer_last_name( $value ) { |
|
| 2368 | - $this->set_last_name( $value ); |
|
| 2367 | + public function set_customer_last_name($value) { |
|
| 2368 | + $this->set_last_name($value); |
|
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | 2371 | /** |
@@ -2374,8 +2374,8 @@ discard block |
||
| 2374 | 2374 | * @since 1.0.19 |
| 2375 | 2375 | * @param string $value phone. |
| 2376 | 2376 | */ |
| 2377 | - public function set_phone( $value ) { |
|
| 2378 | - $this->set_prop( 'phone', $value ); |
|
| 2377 | + public function set_phone($value) { |
|
| 2378 | + $this->set_prop('phone', $value); |
|
| 2379 | 2379 | } |
| 2380 | 2380 | |
| 2381 | 2381 | /** |
@@ -2384,8 +2384,8 @@ discard block |
||
| 2384 | 2384 | * @since 1.0.19 |
| 2385 | 2385 | * @param string $value phone. |
| 2386 | 2386 | */ |
| 2387 | - public function set_user_phone( $value ) { |
|
| 2388 | - $this->set_phone( $value ); |
|
| 2387 | + public function set_user_phone($value) { |
|
| 2388 | + $this->set_phone($value); |
|
| 2389 | 2389 | } |
| 2390 | 2390 | |
| 2391 | 2391 | /** |
@@ -2394,8 +2394,8 @@ discard block |
||
| 2394 | 2394 | * @since 1.0.19 |
| 2395 | 2395 | * @param string $value phone. |
| 2396 | 2396 | */ |
| 2397 | - public function set_customer_phone( $value ) { |
|
| 2398 | - $this->set_phone( $value ); |
|
| 2397 | + public function set_customer_phone($value) { |
|
| 2398 | + $this->set_phone($value); |
|
| 2399 | 2399 | } |
| 2400 | 2400 | |
| 2401 | 2401 | /** |
@@ -2404,8 +2404,8 @@ discard block |
||
| 2404 | 2404 | * @since 1.0.19 |
| 2405 | 2405 | * @param string $value phone. |
| 2406 | 2406 | */ |
| 2407 | - public function set_phone_number( $value ) { |
|
| 2408 | - $this->set_phone( $value ); |
|
| 2407 | + public function set_phone_number($value) { |
|
| 2408 | + $this->set_phone($value); |
|
| 2409 | 2409 | } |
| 2410 | 2410 | |
| 2411 | 2411 | /** |
@@ -2414,8 +2414,8 @@ discard block |
||
| 2414 | 2414 | * @since 1.0.19 |
| 2415 | 2415 | * @param string $value email address. |
| 2416 | 2416 | */ |
| 2417 | - public function set_email( $value ) { |
|
| 2418 | - $this->set_prop( 'email', $value ); |
|
| 2417 | + public function set_email($value) { |
|
| 2418 | + $this->set_prop('email', $value); |
|
| 2419 | 2419 | } |
| 2420 | 2420 | |
| 2421 | 2421 | /** |
@@ -2424,8 +2424,8 @@ discard block |
||
| 2424 | 2424 | * @since 1.0.19 |
| 2425 | 2425 | * @param string $value email address. |
| 2426 | 2426 | */ |
| 2427 | - public function set_user_email( $value ) { |
|
| 2428 | - $this->set_email( $value ); |
|
| 2427 | + public function set_user_email($value) { |
|
| 2428 | + $this->set_email($value); |
|
| 2429 | 2429 | } |
| 2430 | 2430 | |
| 2431 | 2431 | /** |
@@ -2434,8 +2434,8 @@ discard block |
||
| 2434 | 2434 | * @since 1.0.19 |
| 2435 | 2435 | * @param string $value email address. |
| 2436 | 2436 | */ |
| 2437 | - public function set_email_address( $value ) { |
|
| 2438 | - $this->set_email( $value ); |
|
| 2437 | + public function set_email_address($value) { |
|
| 2438 | + $this->set_email($value); |
|
| 2439 | 2439 | } |
| 2440 | 2440 | |
| 2441 | 2441 | /** |
@@ -2444,8 +2444,8 @@ discard block |
||
| 2444 | 2444 | * @since 1.0.19 |
| 2445 | 2445 | * @param string $value email address. |
| 2446 | 2446 | */ |
| 2447 | - public function set_customer_email( $value ) { |
|
| 2448 | - $this->set_email( $value ); |
|
| 2447 | + public function set_customer_email($value) { |
|
| 2448 | + $this->set_email($value); |
|
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | 2451 | /** |
@@ -2454,8 +2454,8 @@ discard block |
||
| 2454 | 2454 | * @since 1.0.19 |
| 2455 | 2455 | * @param string $value country. |
| 2456 | 2456 | */ |
| 2457 | - public function set_country( $value ) { |
|
| 2458 | - $this->set_prop( 'country', $value ); |
|
| 2457 | + public function set_country($value) { |
|
| 2458 | + $this->set_prop('country', $value); |
|
| 2459 | 2459 | } |
| 2460 | 2460 | |
| 2461 | 2461 | /** |
@@ -2464,8 +2464,8 @@ discard block |
||
| 2464 | 2464 | * @since 1.0.19 |
| 2465 | 2465 | * @param string $value country. |
| 2466 | 2466 | */ |
| 2467 | - public function set_user_country( $value ) { |
|
| 2468 | - $this->set_country( $value ); |
|
| 2467 | + public function set_user_country($value) { |
|
| 2468 | + $this->set_country($value); |
|
| 2469 | 2469 | } |
| 2470 | 2470 | |
| 2471 | 2471 | /** |
@@ -2474,8 +2474,8 @@ discard block |
||
| 2474 | 2474 | * @since 1.0.19 |
| 2475 | 2475 | * @param string $value country. |
| 2476 | 2476 | */ |
| 2477 | - public function set_customer_country( $value ) { |
|
| 2478 | - $this->set_country( $value ); |
|
| 2477 | + public function set_customer_country($value) { |
|
| 2478 | + $this->set_country($value); |
|
| 2479 | 2479 | } |
| 2480 | 2480 | |
| 2481 | 2481 | /** |
@@ -2484,8 +2484,8 @@ discard block |
||
| 2484 | 2484 | * @since 1.0.19 |
| 2485 | 2485 | * @param string $value state. |
| 2486 | 2486 | */ |
| 2487 | - public function set_state( $value ) { |
|
| 2488 | - $this->set_prop( 'state', $value ); |
|
| 2487 | + public function set_state($value) { |
|
| 2488 | + $this->set_prop('state', $value); |
|
| 2489 | 2489 | } |
| 2490 | 2490 | |
| 2491 | 2491 | /** |
@@ -2494,8 +2494,8 @@ discard block |
||
| 2494 | 2494 | * @since 1.0.19 |
| 2495 | 2495 | * @param string $value state. |
| 2496 | 2496 | */ |
| 2497 | - public function set_user_state( $value ) { |
|
| 2498 | - $this->set_state( $value ); |
|
| 2497 | + public function set_user_state($value) { |
|
| 2498 | + $this->set_state($value); |
|
| 2499 | 2499 | } |
| 2500 | 2500 | |
| 2501 | 2501 | /** |
@@ -2504,8 +2504,8 @@ discard block |
||
| 2504 | 2504 | * @since 1.0.19 |
| 2505 | 2505 | * @param string $value state. |
| 2506 | 2506 | */ |
| 2507 | - public function set_customer_state( $value ) { |
|
| 2508 | - $this->set_state( $value ); |
|
| 2507 | + public function set_customer_state($value) { |
|
| 2508 | + $this->set_state($value); |
|
| 2509 | 2509 | } |
| 2510 | 2510 | |
| 2511 | 2511 | /** |
@@ -2514,8 +2514,8 @@ discard block |
||
| 2514 | 2514 | * @since 1.0.19 |
| 2515 | 2515 | * @param string $value city. |
| 2516 | 2516 | */ |
| 2517 | - public function set_city( $value ) { |
|
| 2518 | - $this->set_prop( 'city', $value ); |
|
| 2517 | + public function set_city($value) { |
|
| 2518 | + $this->set_prop('city', $value); |
|
| 2519 | 2519 | } |
| 2520 | 2520 | |
| 2521 | 2521 | /** |
@@ -2524,8 +2524,8 @@ discard block |
||
| 2524 | 2524 | * @since 1.0.19 |
| 2525 | 2525 | * @param string $value city. |
| 2526 | 2526 | */ |
| 2527 | - public function set_user_city( $value ) { |
|
| 2528 | - $this->set_city( $value ); |
|
| 2527 | + public function set_user_city($value) { |
|
| 2528 | + $this->set_city($value); |
|
| 2529 | 2529 | } |
| 2530 | 2530 | |
| 2531 | 2531 | /** |
@@ -2534,8 +2534,8 @@ discard block |
||
| 2534 | 2534 | * @since 1.0.19 |
| 2535 | 2535 | * @param string $value city. |
| 2536 | 2536 | */ |
| 2537 | - public function set_customer_city( $value ) { |
|
| 2538 | - $this->set_city( $value ); |
|
| 2537 | + public function set_customer_city($value) { |
|
| 2538 | + $this->set_city($value); |
|
| 2539 | 2539 | } |
| 2540 | 2540 | |
| 2541 | 2541 | /** |
@@ -2544,8 +2544,8 @@ discard block |
||
| 2544 | 2544 | * @since 1.0.19 |
| 2545 | 2545 | * @param string $value zip. |
| 2546 | 2546 | */ |
| 2547 | - public function set_zip( $value ) { |
|
| 2548 | - $this->set_prop( 'zip', $value ); |
|
| 2547 | + public function set_zip($value) { |
|
| 2548 | + $this->set_prop('zip', $value); |
|
| 2549 | 2549 | } |
| 2550 | 2550 | |
| 2551 | 2551 | /** |
@@ -2554,8 +2554,8 @@ discard block |
||
| 2554 | 2554 | * @since 1.0.19 |
| 2555 | 2555 | * @param string $value zip. |
| 2556 | 2556 | */ |
| 2557 | - public function set_user_zip( $value ) { |
|
| 2558 | - $this->set_zip( $value ); |
|
| 2557 | + public function set_user_zip($value) { |
|
| 2558 | + $this->set_zip($value); |
|
| 2559 | 2559 | } |
| 2560 | 2560 | |
| 2561 | 2561 | /** |
@@ -2564,8 +2564,8 @@ discard block |
||
| 2564 | 2564 | * @since 1.0.19 |
| 2565 | 2565 | * @param string $value zip. |
| 2566 | 2566 | */ |
| 2567 | - public function set_customer_zip( $value ) { |
|
| 2568 | - $this->set_zip( $value ); |
|
| 2567 | + public function set_customer_zip($value) { |
|
| 2568 | + $this->set_zip($value); |
|
| 2569 | 2569 | } |
| 2570 | 2570 | |
| 2571 | 2571 | /** |
@@ -2574,8 +2574,8 @@ discard block |
||
| 2574 | 2574 | * @since 1.0.19 |
| 2575 | 2575 | * @param string $value company. |
| 2576 | 2576 | */ |
| 2577 | - public function set_company( $value ) { |
|
| 2578 | - $this->set_prop( 'company', $value ); |
|
| 2577 | + public function set_company($value) { |
|
| 2578 | + $this->set_prop('company', $value); |
|
| 2579 | 2579 | } |
| 2580 | 2580 | |
| 2581 | 2581 | /** |
@@ -2584,8 +2584,8 @@ discard block |
||
| 2584 | 2584 | * @since 1.0.19 |
| 2585 | 2585 | * @param string $value company. |
| 2586 | 2586 | */ |
| 2587 | - public function set_user_company( $value ) { |
|
| 2588 | - $this->set_company( $value ); |
|
| 2587 | + public function set_user_company($value) { |
|
| 2588 | + $this->set_company($value); |
|
| 2589 | 2589 | } |
| 2590 | 2590 | |
| 2591 | 2591 | /** |
@@ -2594,8 +2594,8 @@ discard block |
||
| 2594 | 2594 | * @since 1.0.19 |
| 2595 | 2595 | * @param string $value company. |
| 2596 | 2596 | */ |
| 2597 | - public function set_customer_company( $value ) { |
|
| 2598 | - $this->set_company( $value ); |
|
| 2597 | + public function set_customer_company($value) { |
|
| 2598 | + $this->set_company($value); |
|
| 2599 | 2599 | } |
| 2600 | 2600 | |
| 2601 | 2601 | /** |
@@ -2604,8 +2604,8 @@ discard block |
||
| 2604 | 2604 | * @since 1.0.19 |
| 2605 | 2605 | * @param string $value var number. |
| 2606 | 2606 | */ |
| 2607 | - public function set_vat_number( $value ) { |
|
| 2608 | - $this->set_prop( 'vat_number', $value ); |
|
| 2607 | + public function set_vat_number($value) { |
|
| 2608 | + $this->set_prop('vat_number', $value); |
|
| 2609 | 2609 | } |
| 2610 | 2610 | |
| 2611 | 2611 | /** |
@@ -2614,8 +2614,8 @@ discard block |
||
| 2614 | 2614 | * @since 1.0.19 |
| 2615 | 2615 | * @param string $value var number. |
| 2616 | 2616 | */ |
| 2617 | - public function set_user_vat_number( $value ) { |
|
| 2618 | - $this->set_vat_number( $value ); |
|
| 2617 | + public function set_user_vat_number($value) { |
|
| 2618 | + $this->set_vat_number($value); |
|
| 2619 | 2619 | } |
| 2620 | 2620 | |
| 2621 | 2621 | /** |
@@ -2624,8 +2624,8 @@ discard block |
||
| 2624 | 2624 | * @since 1.0.19 |
| 2625 | 2625 | * @param string $value var number. |
| 2626 | 2626 | */ |
| 2627 | - public function set_customer_vat_number( $value ) { |
|
| 2628 | - $this->set_vat_number( $value ); |
|
| 2627 | + public function set_customer_vat_number($value) { |
|
| 2628 | + $this->set_vat_number($value); |
|
| 2629 | 2629 | } |
| 2630 | 2630 | |
| 2631 | 2631 | /** |
@@ -2634,8 +2634,8 @@ discard block |
||
| 2634 | 2634 | * @since 1.0.19 |
| 2635 | 2635 | * @param string $value var rate. |
| 2636 | 2636 | */ |
| 2637 | - public function set_vat_rate( $value ) { |
|
| 2638 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2637 | + public function set_vat_rate($value) { |
|
| 2638 | + $this->set_prop('vat_rate', $value); |
|
| 2639 | 2639 | } |
| 2640 | 2640 | |
| 2641 | 2641 | /** |
@@ -2644,8 +2644,8 @@ discard block |
||
| 2644 | 2644 | * @since 1.0.19 |
| 2645 | 2645 | * @param string $value var number. |
| 2646 | 2646 | */ |
| 2647 | - public function set_user_vat_rate( $value ) { |
|
| 2648 | - $this->set_vat_rate( $value ); |
|
| 2647 | + public function set_user_vat_rate($value) { |
|
| 2648 | + $this->set_vat_rate($value); |
|
| 2649 | 2649 | } |
| 2650 | 2650 | |
| 2651 | 2651 | /** |
@@ -2654,8 +2654,8 @@ discard block |
||
| 2654 | 2654 | * @since 1.0.19 |
| 2655 | 2655 | * @param string $value var number. |
| 2656 | 2656 | */ |
| 2657 | - public function set_customer_vat_rate( $value ) { |
|
| 2658 | - $this->set_vat_rate( $value ); |
|
| 2657 | + public function set_customer_vat_rate($value) { |
|
| 2658 | + $this->set_vat_rate($value); |
|
| 2659 | 2659 | } |
| 2660 | 2660 | |
| 2661 | 2661 | /** |
@@ -2664,8 +2664,8 @@ discard block |
||
| 2664 | 2664 | * @since 1.0.19 |
| 2665 | 2665 | * @param string $value address. |
| 2666 | 2666 | */ |
| 2667 | - public function set_address( $value ) { |
|
| 2668 | - $this->set_prop( 'address', $value ); |
|
| 2667 | + public function set_address($value) { |
|
| 2668 | + $this->set_prop('address', $value); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | |
| 2671 | 2671 | /** |
@@ -2674,8 +2674,8 @@ discard block |
||
| 2674 | 2674 | * @since 1.0.19 |
| 2675 | 2675 | * @param string $value address. |
| 2676 | 2676 | */ |
| 2677 | - public function set_user_address( $value ) { |
|
| 2678 | - $this->set_address( $value ); |
|
| 2677 | + public function set_user_address($value) { |
|
| 2678 | + $this->set_address($value); |
|
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | 2681 | /** |
@@ -2684,8 +2684,8 @@ discard block |
||
| 2684 | 2684 | * @since 1.0.19 |
| 2685 | 2685 | * @param string $value address. |
| 2686 | 2686 | */ |
| 2687 | - public function set_customer_address( $value ) { |
|
| 2688 | - $this->set_address( $value ); |
|
| 2687 | + public function set_customer_address($value) { |
|
| 2688 | + $this->set_address($value); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | /** |
@@ -2694,8 +2694,8 @@ discard block |
||
| 2694 | 2694 | * @since 1.0.19 |
| 2695 | 2695 | * @param int|bool $value confirmed. |
| 2696 | 2696 | */ |
| 2697 | - public function set_is_viewed( $value ) { |
|
| 2698 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2697 | + public function set_is_viewed($value) { |
|
| 2698 | + $this->set_prop('is_viewed', $value); |
|
| 2699 | 2699 | } |
| 2700 | 2700 | |
| 2701 | 2701 | /** |
@@ -2704,8 +2704,8 @@ discard block |
||
| 2704 | 2704 | * @since 1.0.19 |
| 2705 | 2705 | * @param string $value email recipients. |
| 2706 | 2706 | */ |
| 2707 | - public function set_email_cc( $value ) { |
|
| 2708 | - $this->set_prop( 'email_cc', $value ); |
|
| 2707 | + public function set_email_cc($value) { |
|
| 2708 | + $this->set_prop('email_cc', $value); |
|
| 2709 | 2709 | } |
| 2710 | 2710 | |
| 2711 | 2711 | /** |
@@ -2714,9 +2714,9 @@ discard block |
||
| 2714 | 2714 | * @since 1.0.19 |
| 2715 | 2715 | * @param string $value template. |
| 2716 | 2716 | */ |
| 2717 | - public function set_template( $value ) { |
|
| 2718 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2719 | - $this->set_prop( 'template', $value ); |
|
| 2717 | + public function set_template($value) { |
|
| 2718 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2719 | + $this->set_prop('template', $value); |
|
| 2720 | 2720 | } |
| 2721 | 2721 | } |
| 2722 | 2722 | |
@@ -2727,8 +2727,8 @@ discard block |
||
| 2727 | 2727 | * @param string $value source. |
| 2728 | 2728 | * @deprecated |
| 2729 | 2729 | */ |
| 2730 | - public function created_via( $value ) { |
|
| 2731 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
| 2730 | + public function created_via($value) { |
|
| 2731 | + $this->set_created_via(sanitize_text_field($value)); |
|
| 2732 | 2732 | } |
| 2733 | 2733 | |
| 2734 | 2734 | /** |
@@ -2737,8 +2737,8 @@ discard block |
||
| 2737 | 2737 | * @since 1.0.19 |
| 2738 | 2738 | * @param string $value source. |
| 2739 | 2739 | */ |
| 2740 | - public function set_created_via( $value ) { |
|
| 2741 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2740 | + public function set_created_via($value) { |
|
| 2741 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
| 2742 | 2742 | } |
| 2743 | 2743 | |
| 2744 | 2744 | /** |
@@ -2747,8 +2747,8 @@ discard block |
||
| 2747 | 2747 | * @since 1.0.19 |
| 2748 | 2748 | * @param int|bool $value confirmed. |
| 2749 | 2749 | */ |
| 2750 | - public function set_address_confirmed( $value ) { |
|
| 2751 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2750 | + public function set_address_confirmed($value) { |
|
| 2751 | + $this->set_prop('address_confirmed', $value); |
|
| 2752 | 2752 | } |
| 2753 | 2753 | |
| 2754 | 2754 | /** |
@@ -2757,8 +2757,8 @@ discard block |
||
| 2757 | 2757 | * @since 1.0.19 |
| 2758 | 2758 | * @param int|bool $value confirmed. |
| 2759 | 2759 | */ |
| 2760 | - public function set_user_address_confirmed( $value ) { |
|
| 2761 | - $this->set_address_confirmed( $value ); |
|
| 2760 | + public function set_user_address_confirmed($value) { |
|
| 2761 | + $this->set_address_confirmed($value); |
|
| 2762 | 2762 | } |
| 2763 | 2763 | |
| 2764 | 2764 | /** |
@@ -2767,8 +2767,8 @@ discard block |
||
| 2767 | 2767 | * @since 1.0.19 |
| 2768 | 2768 | * @param int|bool $value confirmed. |
| 2769 | 2769 | */ |
| 2770 | - public function set_customer_address_confirmed( $value ) { |
|
| 2771 | - $this->set_address_confirmed( $value ); |
|
| 2770 | + public function set_customer_address_confirmed($value) { |
|
| 2771 | + $this->set_address_confirmed($value); |
|
| 2772 | 2772 | } |
| 2773 | 2773 | |
| 2774 | 2774 | /** |
@@ -2777,8 +2777,8 @@ discard block |
||
| 2777 | 2777 | * @since 1.0.19 |
| 2778 | 2778 | * @param float $value sub total. |
| 2779 | 2779 | */ |
| 2780 | - public function set_subtotal( $value ) { |
|
| 2781 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
| 2780 | + public function set_subtotal($value) { |
|
| 2781 | + $this->set_prop('subtotal', max(0, $value)); |
|
| 2782 | 2782 | } |
| 2783 | 2783 | |
| 2784 | 2784 | /** |
@@ -2787,8 +2787,8 @@ discard block |
||
| 2787 | 2787 | * @since 1.0.19 |
| 2788 | 2788 | * @param float $value sub total. |
| 2789 | 2789 | */ |
| 2790 | - public function set_total( $value ) { |
|
| 2791 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
| 2790 | + public function set_total($value) { |
|
| 2791 | + $this->set_prop('total', max(0, $value)); |
|
| 2792 | 2792 | } |
| 2793 | 2793 | |
| 2794 | 2794 | /** |
@@ -2797,8 +2797,8 @@ discard block |
||
| 2797 | 2797 | * @since 1.0.19 |
| 2798 | 2798 | * @param float $value discount total. |
| 2799 | 2799 | */ |
| 2800 | - public function set_total_discount( $value ) { |
|
| 2801 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
| 2800 | + public function set_total_discount($value) { |
|
| 2801 | + $this->set_prop('total_discount', max(0, $value)); |
|
| 2802 | 2802 | } |
| 2803 | 2803 | |
| 2804 | 2804 | /** |
@@ -2807,8 +2807,8 @@ discard block |
||
| 2807 | 2807 | * @since 1.0.19 |
| 2808 | 2808 | * @param float $value discount total. |
| 2809 | 2809 | */ |
| 2810 | - public function set_discount( $value ) { |
|
| 2811 | - $this->set_total_discount( $value ); |
|
| 2810 | + public function set_discount($value) { |
|
| 2811 | + $this->set_total_discount($value); |
|
| 2812 | 2812 | } |
| 2813 | 2813 | |
| 2814 | 2814 | /** |
@@ -2817,8 +2817,8 @@ discard block |
||
| 2817 | 2817 | * @since 1.0.19 |
| 2818 | 2818 | * @param float $value tax total. |
| 2819 | 2819 | */ |
| 2820 | - public function set_total_tax( $value ) { |
|
| 2821 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
| 2820 | + public function set_total_tax($value) { |
|
| 2821 | + $this->set_prop('total_tax', max(0, $value)); |
|
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | 2824 | /** |
@@ -2827,8 +2827,8 @@ discard block |
||
| 2827 | 2827 | * @since 1.0.19 |
| 2828 | 2828 | * @param float $value tax total. |
| 2829 | 2829 | */ |
| 2830 | - public function set_tax_total( $value ) { |
|
| 2831 | - $this->set_total_tax( $value ); |
|
| 2830 | + public function set_tax_total($value) { |
|
| 2831 | + $this->set_total_tax($value); |
|
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | 2834 | /** |
@@ -2837,8 +2837,8 @@ discard block |
||
| 2837 | 2837 | * @since 1.0.19 |
| 2838 | 2838 | * @param float $value fees total. |
| 2839 | 2839 | */ |
| 2840 | - public function set_total_fees( $value ) { |
|
| 2841 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
| 2840 | + public function set_total_fees($value) { |
|
| 2841 | + $this->set_prop('total_fees', max(0, $value)); |
|
| 2842 | 2842 | } |
| 2843 | 2843 | |
| 2844 | 2844 | /** |
@@ -2847,8 +2847,8 @@ discard block |
||
| 2847 | 2847 | * @since 1.0.19 |
| 2848 | 2848 | * @param float $value fees total. |
| 2849 | 2849 | */ |
| 2850 | - public function set_fees_total( $value ) { |
|
| 2851 | - $this->set_total_fees( $value ); |
|
| 2850 | + public function set_fees_total($value) { |
|
| 2851 | + $this->set_total_fees($value); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | /** |
@@ -2857,13 +2857,13 @@ discard block |
||
| 2857 | 2857 | * @since 1.0.19 |
| 2858 | 2858 | * @param array $value fees. |
| 2859 | 2859 | */ |
| 2860 | - public function set_fees( $value ) { |
|
| 2860 | + public function set_fees($value) { |
|
| 2861 | 2861 | |
| 2862 | - if ( ! is_array( $value ) ) { |
|
| 2862 | + if (!is_array($value)) { |
|
| 2863 | 2863 | $value = array(); |
| 2864 | 2864 | } |
| 2865 | 2865 | |
| 2866 | - $this->set_prop( 'fees', $value ); |
|
| 2866 | + $this->set_prop('fees', $value); |
|
| 2867 | 2867 | |
| 2868 | 2868 | } |
| 2869 | 2869 | |
@@ -2873,13 +2873,13 @@ discard block |
||
| 2873 | 2873 | * @since 1.0.19 |
| 2874 | 2874 | * @param array $value taxes. |
| 2875 | 2875 | */ |
| 2876 | - public function set_taxes( $value ) { |
|
| 2876 | + public function set_taxes($value) { |
|
| 2877 | 2877 | |
| 2878 | - if ( ! is_array( $value ) ) { |
|
| 2878 | + if (!is_array($value)) { |
|
| 2879 | 2879 | $value = array(); |
| 2880 | 2880 | } |
| 2881 | 2881 | |
| 2882 | - $this->set_prop( 'taxes', $value ); |
|
| 2882 | + $this->set_prop('taxes', $value); |
|
| 2883 | 2883 | |
| 2884 | 2884 | } |
| 2885 | 2885 | |
@@ -2889,13 +2889,13 @@ discard block |
||
| 2889 | 2889 | * @since 1.0.19 |
| 2890 | 2890 | * @param array $value discounts. |
| 2891 | 2891 | */ |
| 2892 | - public function set_discounts( $value ) { |
|
| 2892 | + public function set_discounts($value) { |
|
| 2893 | 2893 | |
| 2894 | - if ( ! is_array( $value ) ) { |
|
| 2894 | + if (!is_array($value)) { |
|
| 2895 | 2895 | $value = array(); |
| 2896 | 2896 | } |
| 2897 | 2897 | |
| 2898 | - $this->set_prop( 'discounts', $value ); |
|
| 2898 | + $this->set_prop('discounts', $value); |
|
| 2899 | 2899 | } |
| 2900 | 2900 | |
| 2901 | 2901 | /** |
@@ -2904,19 +2904,19 @@ discard block |
||
| 2904 | 2904 | * @since 1.0.19 |
| 2905 | 2905 | * @param GetPaid_Form_Item[] $value items. |
| 2906 | 2906 | */ |
| 2907 | - public function set_items( $value ) { |
|
| 2907 | + public function set_items($value) { |
|
| 2908 | 2908 | |
| 2909 | 2909 | // Remove existing items. |
| 2910 | - $this->set_prop( 'items', array() ); |
|
| 2910 | + $this->set_prop('items', array()); |
|
| 2911 | 2911 | $this->recurring_item = null; |
| 2912 | 2912 | |
| 2913 | 2913 | // Ensure that we have an array. |
| 2914 | - if ( ! is_array( $value ) ) { |
|
| 2914 | + if (!is_array($value)) { |
|
| 2915 | 2915 | return; |
| 2916 | 2916 | } |
| 2917 | 2917 | |
| 2918 | - foreach ( $value as $item ) { |
|
| 2919 | - $this->add_item( $item ); |
|
| 2918 | + foreach ($value as $item) { |
|
| 2919 | + $this->add_item($item); |
|
| 2920 | 2920 | } |
| 2921 | 2921 | |
| 2922 | 2922 | } |
@@ -2927,8 +2927,8 @@ discard block |
||
| 2927 | 2927 | * @since 1.0.19 |
| 2928 | 2928 | * @param int $value payment form. |
| 2929 | 2929 | */ |
| 2930 | - public function set_payment_form( $value ) { |
|
| 2931 | - $this->set_prop( 'payment_form', $value ); |
|
| 2930 | + public function set_payment_form($value) { |
|
| 2931 | + $this->set_prop('payment_form', $value); |
|
| 2932 | 2932 | } |
| 2933 | 2933 | |
| 2934 | 2934 | /** |
@@ -2937,8 +2937,8 @@ discard block |
||
| 2937 | 2937 | * @since 1.0.19 |
| 2938 | 2938 | * @param string $value submission id. |
| 2939 | 2939 | */ |
| 2940 | - public function set_submission_id( $value ) { |
|
| 2941 | - $this->set_prop( 'submission_id', $value ); |
|
| 2940 | + public function set_submission_id($value) { |
|
| 2941 | + $this->set_prop('submission_id', $value); |
|
| 2942 | 2942 | } |
| 2943 | 2943 | |
| 2944 | 2944 | /** |
@@ -2947,8 +2947,8 @@ discard block |
||
| 2947 | 2947 | * @since 1.0.19 |
| 2948 | 2948 | * @param string $value discount code. |
| 2949 | 2949 | */ |
| 2950 | - public function set_discount_code( $value ) { |
|
| 2951 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
| 2950 | + public function set_discount_code($value) { |
|
| 2951 | + $this->set_prop('discount_code', sanitize_text_field($value)); |
|
| 2952 | 2952 | } |
| 2953 | 2953 | |
| 2954 | 2954 | /** |
@@ -2957,8 +2957,8 @@ discard block |
||
| 2957 | 2957 | * @since 1.0.19 |
| 2958 | 2958 | * @param string $value gateway. |
| 2959 | 2959 | */ |
| 2960 | - public function set_gateway( $value ) { |
|
| 2961 | - $this->set_prop( 'gateway', $value ); |
|
| 2960 | + public function set_gateway($value) { |
|
| 2961 | + $this->set_prop('gateway', $value); |
|
| 2962 | 2962 | } |
| 2963 | 2963 | |
| 2964 | 2964 | /** |
@@ -2967,9 +2967,9 @@ discard block |
||
| 2967 | 2967 | * @since 1.0.19 |
| 2968 | 2968 | * @param string $value transaction id. |
| 2969 | 2969 | */ |
| 2970 | - public function set_transaction_id( $value ) { |
|
| 2971 | - if ( ! empty( $value ) ) { |
|
| 2972 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2970 | + public function set_transaction_id($value) { |
|
| 2971 | + if (!empty($value)) { |
|
| 2972 | + $this->set_prop('transaction_id', $value); |
|
| 2973 | 2973 | } |
| 2974 | 2974 | } |
| 2975 | 2975 | |
@@ -2979,8 +2979,8 @@ discard block |
||
| 2979 | 2979 | * @since 1.0.19 |
| 2980 | 2980 | * @param string $value currency id. |
| 2981 | 2981 | */ |
| 2982 | - public function set_currency( $value ) { |
|
| 2983 | - $this->set_prop( 'currency', $value ); |
|
| 2982 | + public function set_currency($value) { |
|
| 2983 | + $this->set_prop('currency', $value); |
|
| 2984 | 2984 | } |
| 2985 | 2985 | |
| 2986 | 2986 | /** |
@@ -2989,8 +2989,8 @@ discard block |
||
| 2989 | 2989 | * @since 1.0.19 |
| 2990 | 2990 | * @param bool $value value. |
| 2991 | 2991 | */ |
| 2992 | - public function set_disable_taxes( $value ) { |
|
| 2993 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2992 | + public function set_disable_taxes($value) { |
|
| 2993 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 2994 | 2994 | } |
| 2995 | 2995 | |
| 2996 | 2996 | /** |
@@ -2999,8 +2999,8 @@ discard block |
||
| 2999 | 2999 | * @since 1.0.19 |
| 3000 | 3000 | * @param string $value subscription id. |
| 3001 | 3001 | */ |
| 3002 | - public function set_subscription_id( $value ) { |
|
| 3003 | - $this->set_prop( 'subscription_id', $value ); |
|
| 3002 | + public function set_subscription_id($value) { |
|
| 3003 | + $this->set_prop('subscription_id', $value); |
|
| 3004 | 3004 | } |
| 3005 | 3005 | |
| 3006 | 3006 | /** |
@@ -3009,8 +3009,8 @@ discard block |
||
| 3009 | 3009 | * @since 1.0.19 |
| 3010 | 3010 | * @param string $value subscription id. |
| 3011 | 3011 | */ |
| 3012 | - public function set_remote_subscription_id( $value ) { |
|
| 3013 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 3012 | + public function set_remote_subscription_id($value) { |
|
| 3013 | + $this->set_prop('remote_subscription_id', $value); |
|
| 3014 | 3014 | } |
| 3015 | 3015 | |
| 3016 | 3016 | /* |
@@ -3027,28 +3027,28 @@ discard block |
||
| 3027 | 3027 | */ |
| 3028 | 3028 | public function is_parent() { |
| 3029 | 3029 | $parent = $this->get_parent_id(); |
| 3030 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 3030 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 3031 | 3031 | } |
| 3032 | 3032 | |
| 3033 | 3033 | /** |
| 3034 | 3034 | * Checks if this is a renewal invoice. |
| 3035 | 3035 | */ |
| 3036 | 3036 | public function is_renewal() { |
| 3037 | - return ! $this->is_parent(); |
|
| 3037 | + return !$this->is_parent(); |
|
| 3038 | 3038 | } |
| 3039 | 3039 | |
| 3040 | 3040 | /** |
| 3041 | 3041 | * Checks if this is a recurring invoice. |
| 3042 | 3042 | */ |
| 3043 | 3043 | public function is_recurring() { |
| 3044 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
| 3044 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
| 3045 | 3045 | } |
| 3046 | 3046 | |
| 3047 | 3047 | /** |
| 3048 | 3048 | * Checks if this is a taxable invoice. |
| 3049 | 3049 | */ |
| 3050 | 3050 | public function is_taxable() { |
| 3051 | - return ! $this->get_disable_taxes(); |
|
| 3051 | + return !$this->get_disable_taxes(); |
|
| 3052 | 3052 | } |
| 3053 | 3053 | |
| 3054 | 3054 | /** |
@@ -3062,45 +3062,45 @@ discard block |
||
| 3062 | 3062 | * Checks to see if the invoice requires payment. |
| 3063 | 3063 | */ |
| 3064 | 3064 | public function is_free() { |
| 3065 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
| 3065 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
| 3066 | 3066 | |
| 3067 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 3067 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
| 3068 | 3068 | $is_free = false; |
| 3069 | 3069 | } |
| 3070 | 3070 | |
| 3071 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 3071 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 3072 | 3072 | } |
| 3073 | 3073 | |
| 3074 | 3074 | /** |
| 3075 | 3075 | * Checks if the invoice is paid. |
| 3076 | 3076 | */ |
| 3077 | 3077 | public function is_paid() { |
| 3078 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 3079 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 3078 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 3079 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 3080 | 3080 | } |
| 3081 | 3081 | |
| 3082 | 3082 | /** |
| 3083 | 3083 | * Checks if the invoice needs payment. |
| 3084 | 3084 | */ |
| 3085 | 3085 | public function needs_payment() { |
| 3086 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3087 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 3086 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
| 3087 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 3088 | 3088 | } |
| 3089 | 3089 | |
| 3090 | 3090 | /** |
| 3091 | 3091 | * Checks if the invoice is refunded. |
| 3092 | 3092 | */ |
| 3093 | 3093 | public function is_refunded() { |
| 3094 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 3095 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 3094 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 3095 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 3096 | 3096 | } |
| 3097 | 3097 | |
| 3098 | 3098 | /** |
| 3099 | 3099 | * Checks if the invoice is held. |
| 3100 | 3100 | */ |
| 3101 | 3101 | public function is_held() { |
| 3102 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
| 3103 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
| 3102 | + $is_held = $this->has_status('wpi-onhold'); |
|
| 3103 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
| 3104 | 3104 | } |
| 3105 | 3105 | |
| 3106 | 3106 | /** |
@@ -3108,30 +3108,30 @@ discard block |
||
| 3108 | 3108 | */ |
| 3109 | 3109 | public function is_due() { |
| 3110 | 3110 | $due_date = $this->get_due_date(); |
| 3111 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3111 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
| 3112 | 3112 | } |
| 3113 | 3113 | |
| 3114 | 3114 | /** |
| 3115 | 3115 | * Checks if the invoice is draft. |
| 3116 | 3116 | */ |
| 3117 | 3117 | public function is_draft() { |
| 3118 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 3118 | + return $this->has_status('draft, auto-draft'); |
|
| 3119 | 3119 | } |
| 3120 | 3120 | |
| 3121 | 3121 | /** |
| 3122 | 3122 | * Checks if the invoice has a given status. |
| 3123 | 3123 | */ |
| 3124 | - public function has_status( $status ) { |
|
| 3125 | - $status = wpinv_parse_list( $status ); |
|
| 3126 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 3124 | + public function has_status($status) { |
|
| 3125 | + $status = wpinv_parse_list($status); |
|
| 3126 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 3127 | 3127 | } |
| 3128 | 3128 | |
| 3129 | 3129 | /** |
| 3130 | 3130 | * Checks if the invoice is of a given type. |
| 3131 | 3131 | */ |
| 3132 | - public function is_type( $type ) { |
|
| 3133 | - $type = wpinv_parse_list( $type ); |
|
| 3134 | - return in_array( $this->get_type(), $type ); |
|
| 3132 | + public function is_type($type) { |
|
| 3133 | + $type = wpinv_parse_list($type); |
|
| 3134 | + return in_array($this->get_type(), $type); |
|
| 3135 | 3135 | } |
| 3136 | 3136 | |
| 3137 | 3137 | /** |
@@ -3163,8 +3163,8 @@ discard block |
||
| 3163 | 3163 | * |
| 3164 | 3164 | */ |
| 3165 | 3165 | public function is_initial_free() { |
| 3166 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 3167 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 3166 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 3167 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 3168 | 3168 | } |
| 3169 | 3169 | |
| 3170 | 3170 | /** |
@@ -3174,11 +3174,11 @@ discard block |
||
| 3174 | 3174 | public function item_has_free_trial() { |
| 3175 | 3175 | |
| 3176 | 3176 | // Ensure we have a recurring item. |
| 3177 | - if ( ! $this->is_recurring() ) { |
|
| 3177 | + if (!$this->is_recurring()) { |
|
| 3178 | 3178 | return false; |
| 3179 | 3179 | } |
| 3180 | 3180 | |
| 3181 | - $item = $this->get_recurring( true ); |
|
| 3181 | + $item = $this->get_recurring(true); |
|
| 3182 | 3182 | return $item->has_free_trial(); |
| 3183 | 3183 | } |
| 3184 | 3184 | |
@@ -3186,7 +3186,7 @@ discard block |
||
| 3186 | 3186 | * Check if the free trial is a result of a discount. |
| 3187 | 3187 | */ |
| 3188 | 3188 | public function is_free_trial_from_discount() { |
| 3189 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3189 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 3190 | 3190 | } |
| 3191 | 3191 | |
| 3192 | 3192 | /** |
@@ -3194,12 +3194,12 @@ discard block |
||
| 3194 | 3194 | */ |
| 3195 | 3195 | public function discount_first_payment_only() { |
| 3196 | 3196 | |
| 3197 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3198 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
| 3197 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
| 3198 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
| 3199 | 3199 | return true; |
| 3200 | 3200 | } |
| 3201 | 3201 | |
| 3202 | - return ! $discount->get_is_recurring(); |
|
| 3202 | + return !$discount->get_is_recurring(); |
|
| 3203 | 3203 | } |
| 3204 | 3204 | |
| 3205 | 3205 | /* |
@@ -3217,23 +3217,23 @@ discard block |
||
| 3217 | 3217 | * @param GetPaid_Form_Item|array $item |
| 3218 | 3218 | * @return WP_Error|Bool |
| 3219 | 3219 | */ |
| 3220 | - public function add_item( $item ) { |
|
| 3220 | + public function add_item($item) { |
|
| 3221 | 3221 | |
| 3222 | - if ( is_array( $item ) ) { |
|
| 3223 | - $item = $this->process_array_item( $item ); |
|
| 3222 | + if (is_array($item)) { |
|
| 3223 | + $item = $this->process_array_item($item); |
|
| 3224 | 3224 | } |
| 3225 | 3225 | |
| 3226 | - if ( is_numeric( $item ) ) { |
|
| 3227 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3226 | + if (is_numeric($item)) { |
|
| 3227 | + $item = new GetPaid_Form_Item($item); |
|
| 3228 | 3228 | } |
| 3229 | 3229 | |
| 3230 | 3230 | // Make sure that it is available for purchase. |
| 3231 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3232 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3231 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 3232 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3233 | 3233 | } |
| 3234 | 3234 | |
| 3235 | 3235 | // Do we have a recurring item? |
| 3236 | - if ( $item->is_recurring() ) { |
|
| 3236 | + if ($item->is_recurring()) { |
|
| 3237 | 3237 | $this->recurring_item = $item->get_id(); |
| 3238 | 3238 | } |
| 3239 | 3239 | |
@@ -3241,7 +3241,7 @@ discard block |
||
| 3241 | 3241 | $item->invoice_id = (int) $this->get_id(); |
| 3242 | 3242 | |
| 3243 | 3243 | // Remove duplicates. |
| 3244 | - $this->remove_item( $item->get_id() ); |
|
| 3244 | + $this->remove_item($item->get_id()); |
|
| 3245 | 3245 | |
| 3246 | 3246 | // Retrieve all items. |
| 3247 | 3247 | $items = $this->get_items(); |
@@ -3249,7 +3249,7 @@ discard block |
||
| 3249 | 3249 | // Add new item. |
| 3250 | 3250 | $items[] = $item; |
| 3251 | 3251 | |
| 3252 | - $this->set_prop( 'items', $items ); |
|
| 3252 | + $this->set_prop('items', $items); |
|
| 3253 | 3253 | |
| 3254 | 3254 | return true; |
| 3255 | 3255 | } |
@@ -3260,26 +3260,26 @@ discard block |
||
| 3260 | 3260 | * @since 1.0.19 |
| 3261 | 3261 | * @return GetPaid_Form_Item |
| 3262 | 3262 | */ |
| 3263 | - protected function process_array_item( $array ) { |
|
| 3263 | + protected function process_array_item($array) { |
|
| 3264 | 3264 | |
| 3265 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3266 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3265 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
| 3266 | + $item = new GetPaid_Form_Item($item_id); |
|
| 3267 | 3267 | |
| 3268 | 3268 | // Set item data. |
| 3269 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3270 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3269 | + foreach (array('name', 'price', 'description') as $key) { |
|
| 3270 | + if (isset($array["item_$key"])) { |
|
| 3271 | 3271 | $method = "set_$key"; |
| 3272 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3272 | + $item->$method($array["item_$key"]); |
|
| 3273 | 3273 | } |
| 3274 | 3274 | } |
| 3275 | 3275 | |
| 3276 | - if ( isset( $array['quantity'] ) ) { |
|
| 3277 | - $item->set_quantity( $array['quantity'] ); |
|
| 3276 | + if (isset($array['quantity'])) { |
|
| 3277 | + $item->set_quantity($array['quantity']); |
|
| 3278 | 3278 | } |
| 3279 | 3279 | |
| 3280 | 3280 | // Set item meta. |
| 3281 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3282 | - $item->set_item_meta( $array['meta'] ); |
|
| 3281 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
| 3282 | + $item->set_item_meta($array['meta']); |
|
| 3283 | 3283 | } |
| 3284 | 3284 | |
| 3285 | 3285 | return $item; |
@@ -3292,10 +3292,10 @@ discard block |
||
| 3292 | 3292 | * @since 1.0.19 |
| 3293 | 3293 | * @return GetPaid_Form_Item|null |
| 3294 | 3294 | */ |
| 3295 | - public function get_item( $item_id ) { |
|
| 3295 | + public function get_item($item_id) { |
|
| 3296 | 3296 | |
| 3297 | - foreach ( $this->get_items() as $item ) { |
|
| 3298 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3297 | + foreach ($this->get_items() as $item) { |
|
| 3298 | + if ((int) $item_id == $item->get_id()) { |
|
| 3299 | 3299 | return $item; |
| 3300 | 3300 | } |
| 3301 | 3301 | } |
@@ -3308,16 +3308,16 @@ discard block |
||
| 3308 | 3308 | * |
| 3309 | 3309 | * @since 1.0.19 |
| 3310 | 3310 | */ |
| 3311 | - public function remove_item( $item_id ) { |
|
| 3311 | + public function remove_item($item_id) { |
|
| 3312 | 3312 | $items = $this->get_items(); |
| 3313 | 3313 | $item_id = (int) $item_id; |
| 3314 | 3314 | |
| 3315 | - foreach ( $items as $index => $item ) { |
|
| 3316 | - if ( (int) $item_id == $item->get_id() ) { |
|
| 3317 | - unset( $items[ $index ] ); |
|
| 3318 | - $this->set_prop( 'items', $items ); |
|
| 3315 | + foreach ($items as $index => $item) { |
|
| 3316 | + if ((int) $item_id == $item->get_id()) { |
|
| 3317 | + unset($items[$index]); |
|
| 3318 | + $this->set_prop('items', $items); |
|
| 3319 | 3319 | |
| 3320 | - if ( $item_id == $this->recurring_item ) { |
|
| 3320 | + if ($item_id == $this->recurring_item) { |
|
| 3321 | 3321 | $this->recurring_item = null; |
| 3322 | 3322 | } |
| 3323 | 3323 | |
@@ -3332,11 +3332,11 @@ discard block |
||
| 3332 | 3332 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
| 3333 | 3333 | * @since 1.0.19 |
| 3334 | 3334 | */ |
| 3335 | - public function add_fee( $fee ) { |
|
| 3335 | + public function add_fee($fee) { |
|
| 3336 | 3336 | |
| 3337 | 3337 | $fees = $this->get_fees(); |
| 3338 | - $fees[ $fee['name'] ] = $fee; |
|
| 3339 | - $this->set_prop( 'fees', $fees ); |
|
| 3338 | + $fees[$fee['name']] = $fee; |
|
| 3339 | + $this->set_prop('fees', $fees); |
|
| 3340 | 3340 | |
| 3341 | 3341 | } |
| 3342 | 3342 | |
@@ -3345,9 +3345,9 @@ discard block |
||
| 3345 | 3345 | * |
| 3346 | 3346 | * @since 1.0.19 |
| 3347 | 3347 | */ |
| 3348 | - public function get_fee( $fee ) { |
|
| 3348 | + public function get_fee($fee) { |
|
| 3349 | 3349 | $fees = $this->get_fees(); |
| 3350 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3350 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3351 | 3351 | } |
| 3352 | 3352 | |
| 3353 | 3353 | /** |
@@ -3355,11 +3355,11 @@ discard block |
||
| 3355 | 3355 | * |
| 3356 | 3356 | * @since 1.0.19 |
| 3357 | 3357 | */ |
| 3358 | - public function remove_fee( $fee ) { |
|
| 3358 | + public function remove_fee($fee) { |
|
| 3359 | 3359 | $fees = $this->get_fees(); |
| 3360 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3361 | - unset( $fees[ $fee ] ); |
|
| 3362 | - $this->set_prop( 'fees', $fees ); |
|
| 3360 | + if (isset($fees[$fee])) { |
|
| 3361 | + unset($fees[$fee]); |
|
| 3362 | + $this->set_prop('fees', $fees); |
|
| 3363 | 3363 | } |
| 3364 | 3364 | } |
| 3365 | 3365 | |
@@ -3369,11 +3369,11 @@ discard block |
||
| 3369 | 3369 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
| 3370 | 3370 | * @since 1.0.19 |
| 3371 | 3371 | */ |
| 3372 | - public function add_discount( $discount ) { |
|
| 3372 | + public function add_discount($discount) { |
|
| 3373 | 3373 | |
| 3374 | 3374 | $discounts = $this->get_discounts(); |
| 3375 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3376 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3375 | + $discounts[$discount['name']] = $discount; |
|
| 3376 | + $this->set_prop('discounts', $discounts); |
|
| 3377 | 3377 | |
| 3378 | 3378 | } |
| 3379 | 3379 | |
@@ -3383,15 +3383,15 @@ discard block |
||
| 3383 | 3383 | * @since 1.0.19 |
| 3384 | 3384 | * @return float |
| 3385 | 3385 | */ |
| 3386 | - public function get_discount( $discount = false ) { |
|
| 3386 | + public function get_discount($discount = false) { |
|
| 3387 | 3387 | |
| 3388 | 3388 | // Backwards compatibilty. |
| 3389 | - if ( empty( $discount ) ) { |
|
| 3389 | + if (empty($discount)) { |
|
| 3390 | 3390 | return $this->get_total_discount(); |
| 3391 | 3391 | } |
| 3392 | 3392 | |
| 3393 | 3393 | $discounts = $this->get_discounts(); |
| 3394 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3394 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3395 | 3395 | } |
| 3396 | 3396 | |
| 3397 | 3397 | /** |
@@ -3399,15 +3399,15 @@ discard block |
||
| 3399 | 3399 | * |
| 3400 | 3400 | * @since 1.0.19 |
| 3401 | 3401 | */ |
| 3402 | - public function remove_discount( $discount ) { |
|
| 3402 | + public function remove_discount($discount) { |
|
| 3403 | 3403 | $discounts = $this->get_discounts(); |
| 3404 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3405 | - unset( $discounts[ $discount ] ); |
|
| 3406 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3404 | + if (isset($discounts[$discount])) { |
|
| 3405 | + unset($discounts[$discount]); |
|
| 3406 | + $this->set_prop('discounts', $discounts); |
|
| 3407 | 3407 | } |
| 3408 | 3408 | |
| 3409 | - if ( 'discount_code' == $discount ) { |
|
| 3410 | - foreach ( $this->get_items() as $item ) { |
|
| 3409 | + if ('discount_code' == $discount) { |
|
| 3410 | + foreach ($this->get_items() as $item) { |
|
| 3411 | 3411 | $item->item_discount = 0; |
| 3412 | 3412 | $item->recurring_item_discount = 0; |
| 3413 | 3413 | } |
@@ -3420,12 +3420,12 @@ discard block |
||
| 3420 | 3420 | * |
| 3421 | 3421 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
| 3422 | 3422 | */ |
| 3423 | - public function add_tax( $tax ) { |
|
| 3424 | - if ( $this->is_taxable() ) { |
|
| 3423 | + public function add_tax($tax) { |
|
| 3424 | + if ($this->is_taxable()) { |
|
| 3425 | 3425 | |
| 3426 | - $taxes = $this->get_taxes(); |
|
| 3427 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3428 | - $this->set_prop( 'taxes', $tax ); |
|
| 3426 | + $taxes = $this->get_taxes(); |
|
| 3427 | + $taxes[$tax['name']] = $tax; |
|
| 3428 | + $this->set_prop('taxes', $tax); |
|
| 3429 | 3429 | |
| 3430 | 3430 | } |
| 3431 | 3431 | } |
@@ -3435,15 +3435,15 @@ discard block |
||
| 3435 | 3435 | * |
| 3436 | 3436 | * @since 1.0.19 |
| 3437 | 3437 | */ |
| 3438 | - public function get_tax( $tax = null ) { |
|
| 3438 | + public function get_tax($tax = null) { |
|
| 3439 | 3439 | |
| 3440 | 3440 | // Backwards compatility. |
| 3441 | - if ( empty( $tax ) ) { |
|
| 3441 | + if (empty($tax)) { |
|
| 3442 | 3442 | return $this->get_total_tax(); |
| 3443 | 3443 | } |
| 3444 | 3444 | |
| 3445 | 3445 | $taxes = $this->get_taxes(); |
| 3446 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3446 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3447 | 3447 | } |
| 3448 | 3448 | |
| 3449 | 3449 | /** |
@@ -3451,11 +3451,11 @@ discard block |
||
| 3451 | 3451 | * |
| 3452 | 3452 | * @since 1.0.19 |
| 3453 | 3453 | */ |
| 3454 | - public function remove_tax( $tax ) { |
|
| 3454 | + public function remove_tax($tax) { |
|
| 3455 | 3455 | $taxes = $this->get_taxes(); |
| 3456 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3457 | - unset( $taxes[ $tax ] ); |
|
| 3458 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3456 | + if (isset($taxes[$tax])) { |
|
| 3457 | + unset($taxes[$tax]); |
|
| 3458 | + $this->set_prop('taxes', $taxes); |
|
| 3459 | 3459 | } |
| 3460 | 3460 | } |
| 3461 | 3461 | |
@@ -3466,22 +3466,22 @@ discard block |
||
| 3466 | 3466 | * @return float The recalculated subtotal |
| 3467 | 3467 | */ |
| 3468 | 3468 | public function recalculate_subtotal() { |
| 3469 | - $items = $this->get_items(); |
|
| 3469 | + $items = $this->get_items(); |
|
| 3470 | 3470 | $subtotal = 0; |
| 3471 | 3471 | $recurring = 0; |
| 3472 | 3472 | |
| 3473 | - foreach ( $items as $item ) { |
|
| 3473 | + foreach ($items as $item) { |
|
| 3474 | 3474 | $subtotal += $item->get_sub_total(); |
| 3475 | 3475 | $recurring += $item->get_recurring_sub_total(); |
| 3476 | 3476 | } |
| 3477 | 3477 | |
| 3478 | - if ( wpinv_prices_include_tax() ) { |
|
| 3479 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
| 3480 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
| 3478 | + if (wpinv_prices_include_tax()) { |
|
| 3479 | + $subtotal = max(0, $subtotal - $this->totals['tax']['initial']); |
|
| 3480 | + $recurring = max(0, $recurring - $this->totals['tax']['recurring']); |
|
| 3481 | 3481 | } |
| 3482 | 3482 | |
| 3483 | 3483 | $current = $this->is_renewal() ? $recurring : $subtotal; |
| 3484 | - $this->set_subtotal( $current ); |
|
| 3484 | + $this->set_subtotal($current); |
|
| 3485 | 3485 | |
| 3486 | 3486 | $this->totals['subtotal'] = array( |
| 3487 | 3487 | 'initial' => $subtotal, |
@@ -3502,14 +3502,14 @@ discard block |
||
| 3502 | 3502 | $discount = 0; |
| 3503 | 3503 | $recurring = 0; |
| 3504 | 3504 | |
| 3505 | - foreach ( $discounts as $data ) { |
|
| 3506 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3507 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3505 | + foreach ($discounts as $data) { |
|
| 3506 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
| 3507 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
| 3508 | 3508 | } |
| 3509 | 3509 | |
| 3510 | 3510 | $current = $this->is_renewal() ? $recurring : $discount; |
| 3511 | 3511 | |
| 3512 | - $this->set_total_discount( $current ); |
|
| 3512 | + $this->set_total_discount($current); |
|
| 3513 | 3513 | |
| 3514 | 3514 | $this->totals['discount'] = array( |
| 3515 | 3515 | 'initial' => $discount, |
@@ -3530,13 +3530,13 @@ discard block |
||
| 3530 | 3530 | |
| 3531 | 3531 | // Maybe disable taxes. |
| 3532 | 3532 | $vat_number = $this->get_vat_number(); |
| 3533 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
| 3533 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number); |
|
| 3534 | 3534 | |
| 3535 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 3535 | + if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
| 3536 | 3536 | $skip_tax = false; |
| 3537 | 3537 | } |
| 3538 | 3538 | |
| 3539 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
| 3539 | + if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) { |
|
| 3540 | 3540 | |
| 3541 | 3541 | $this->totals['tax'] = array( |
| 3542 | 3542 | 'initial' => 0, |
@@ -3545,38 +3545,38 @@ discard block |
||
| 3545 | 3545 | |
| 3546 | 3546 | $this->tax_rate = 0; |
| 3547 | 3547 | |
| 3548 | - $this->set_taxes( array() ); |
|
| 3548 | + $this->set_taxes(array()); |
|
| 3549 | 3549 | $current = 0; |
| 3550 | 3550 | } else { |
| 3551 | 3551 | |
| 3552 | 3552 | $item_taxes = array(); |
| 3553 | 3553 | |
| 3554 | - foreach ( $this->get_items() as $item ) { |
|
| 3555 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
| 3556 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 3557 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 3558 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 3559 | - foreach ( $taxes as $name => $amount ) { |
|
| 3560 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 3561 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 3562 | - |
|
| 3563 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
| 3564 | - $item_taxes[ $name ] = $tax; |
|
| 3554 | + foreach ($this->get_items() as $item) { |
|
| 3555 | + $rates = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state()); |
|
| 3556 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
| 3557 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
| 3558 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
| 3559 | + foreach ($taxes as $name => $amount) { |
|
| 3560 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
| 3561 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
| 3562 | + |
|
| 3563 | + if (!isset($item_taxes[$name])) { |
|
| 3564 | + $item_taxes[$name] = $tax; |
|
| 3565 | 3565 | continue; |
| 3566 | 3566 | } |
| 3567 | 3567 | |
| 3568 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 3569 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3568 | + $item_taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
| 3569 | + $item_taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
| 3570 | 3570 | |
| 3571 | 3571 | } |
| 3572 | 3572 | |
| 3573 | 3573 | } |
| 3574 | 3574 | |
| 3575 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
| 3576 | - $this->set_taxes( $item_taxes ); |
|
| 3575 | + $item_taxes = array_replace($this->get_taxes(), $item_taxes); |
|
| 3576 | + $this->set_taxes($item_taxes); |
|
| 3577 | 3577 | |
| 3578 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
| 3579 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
| 3578 | + $initial_tax = array_sum(wp_list_pluck($item_taxes, 'initial_tax')); |
|
| 3579 | + $recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax')); |
|
| 3580 | 3580 | |
| 3581 | 3581 | $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
| 3582 | 3582 | |
@@ -3587,7 +3587,7 @@ discard block |
||
| 3587 | 3587 | |
| 3588 | 3588 | } |
| 3589 | 3589 | |
| 3590 | - $this->set_total_tax( $current ); |
|
| 3590 | + $this->set_total_tax($current); |
|
| 3591 | 3591 | |
| 3592 | 3592 | return $current; |
| 3593 | 3593 | |
@@ -3604,20 +3604,20 @@ discard block |
||
| 3604 | 3604 | $fee = 0; |
| 3605 | 3605 | $recurring = 0; |
| 3606 | 3606 | |
| 3607 | - foreach ( $fees as $data ) { |
|
| 3608 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3609 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3607 | + foreach ($fees as $data) { |
|
| 3608 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
| 3609 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
| 3610 | 3610 | } |
| 3611 | 3611 | |
| 3612 | 3612 | $current = $this->is_renewal() ? $recurring : $fee; |
| 3613 | - $this->set_total_fees( $current ); |
|
| 3613 | + $this->set_total_fees($current); |
|
| 3614 | 3614 | |
| 3615 | 3615 | $this->totals['fee'] = array( |
| 3616 | 3616 | 'initial' => $fee, |
| 3617 | 3617 | 'recurring' => $recurring, |
| 3618 | 3618 | ); |
| 3619 | 3619 | |
| 3620 | - $this->set_total_fees( $fee ); |
|
| 3620 | + $this->set_total_fees($fee); |
|
| 3621 | 3621 | return $current; |
| 3622 | 3622 | } |
| 3623 | 3623 | |
@@ -3632,7 +3632,7 @@ discard block |
||
| 3632 | 3632 | $this->recalculate_total_discount(); |
| 3633 | 3633 | $this->recalculate_total_tax(); |
| 3634 | 3634 | $this->recalculate_subtotal(); |
| 3635 | - $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() ); |
|
| 3635 | + $this->set_total($this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount()); |
|
| 3636 | 3636 | return $this->get_total(); |
| 3637 | 3637 | } |
| 3638 | 3638 | |
@@ -3641,7 +3641,7 @@ discard block |
||
| 3641 | 3641 | */ |
| 3642 | 3642 | public function recalculate_totals() { |
| 3643 | 3643 | $this->recalculate_total(); |
| 3644 | - $this->save( true ); |
|
| 3644 | + $this->save(true); |
|
| 3645 | 3645 | return $this; |
| 3646 | 3646 | } |
| 3647 | 3647 | |
@@ -3659,10 +3659,10 @@ discard block |
||
| 3659 | 3659 | * @return int|false The new note's ID on success, false on failure. |
| 3660 | 3660 | * |
| 3661 | 3661 | */ |
| 3662 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3662 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3663 | 3663 | |
| 3664 | 3664 | // Bail if no note specified or this invoice is not yet saved. |
| 3665 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
| 3665 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
| 3666 | 3666 | return false; |
| 3667 | 3667 | } |
| 3668 | 3668 | |
@@ -3670,23 +3670,23 @@ discard block |
||
| 3670 | 3670 | $author_email = '[email protected]'; |
| 3671 | 3671 | |
| 3672 | 3672 | // If this is an admin comment or it has been added by the user. |
| 3673 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3674 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3673 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
| 3674 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3675 | 3675 | $author = $user->display_name; |
| 3676 | 3676 | $author_email = $user->user_email; |
| 3677 | 3677 | } |
| 3678 | 3678 | |
| 3679 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3679 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
| 3680 | 3680 | |
| 3681 | 3681 | } |
| 3682 | 3682 | |
| 3683 | 3683 | /** |
| 3684 | 3684 | * Generates a unique key for the invoice. |
| 3685 | 3685 | */ |
| 3686 | - public function generate_key( $string = '' ) { |
|
| 3687 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3686 | + public function generate_key($string = '') { |
|
| 3687 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3688 | 3688 | return strtolower( |
| 3689 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3689 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3690 | 3690 | ); |
| 3691 | 3691 | } |
| 3692 | 3692 | |
@@ -3696,11 +3696,11 @@ discard block |
||
| 3696 | 3696 | public function generate_number() { |
| 3697 | 3697 | $number = $this->get_id(); |
| 3698 | 3698 | |
| 3699 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
| 3700 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
| 3699 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
| 3700 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
| 3701 | 3701 | } |
| 3702 | 3702 | |
| 3703 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3703 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
| 3704 | 3704 | |
| 3705 | 3705 | } |
| 3706 | 3706 | |
@@ -3713,55 +3713,55 @@ discard block |
||
| 3713 | 3713 | // Reset status transition variable. |
| 3714 | 3714 | $this->status_transition = false; |
| 3715 | 3715 | |
| 3716 | - if ( $status_transition ) { |
|
| 3716 | + if ($status_transition) { |
|
| 3717 | 3717 | try { |
| 3718 | 3718 | |
| 3719 | 3719 | // Fire a hook for the status change. |
| 3720 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3720 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
| 3721 | 3721 | |
| 3722 | 3722 | // @deprecated this is deprecated and will be removed in the future. |
| 3723 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3723 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3724 | 3724 | |
| 3725 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3725 | + if (!empty($status_transition['from'])) { |
|
| 3726 | 3726 | |
| 3727 | 3727 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3728 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3728 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3729 | 3729 | |
| 3730 | 3730 | // Fire another hook. |
| 3731 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3732 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3731 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
| 3732 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
| 3733 | 3733 | |
| 3734 | 3734 | // @deprecated this is deprecated and will be removed in the future. |
| 3735 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3735 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3736 | 3736 | |
| 3737 | 3737 | // Note the transition occurred. |
| 3738 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3738 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
| 3739 | 3739 | |
| 3740 | 3740 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3741 | 3741 | if ( |
| 3742 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3743 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3742 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3743 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3744 | 3744 | ) { |
| 3745 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3745 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
| 3746 | 3746 | } |
| 3747 | 3747 | |
| 3748 | 3748 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
| 3749 | 3749 | if ( |
| 3750 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3751 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3750 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3751 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3752 | 3752 | ) { |
| 3753 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3753 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
| 3754 | 3754 | } |
| 3755 | 3755 | } else { |
| 3756 | 3756 | /* translators: %s: new invoice status */ |
| 3757 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3757 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3758 | 3758 | |
| 3759 | 3759 | // Note the transition occurred. |
| 3760 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3760 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3761 | 3761 | |
| 3762 | 3762 | } |
| 3763 | - } catch ( Exception $e ) { |
|
| 3764 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3763 | + } catch (Exception $e) { |
|
| 3764 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3765 | 3765 | } |
| 3766 | 3766 | } |
| 3767 | 3767 | } |
@@ -3769,13 +3769,13 @@ discard block |
||
| 3769 | 3769 | /** |
| 3770 | 3770 | * Updates an invoice status. |
| 3771 | 3771 | */ |
| 3772 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3772 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3773 | 3773 | |
| 3774 | 3774 | // Fires before updating a status. |
| 3775 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3775 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3776 | 3776 | |
| 3777 | 3777 | // Update the status. |
| 3778 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3778 | + $this->set_status($new_status, $note, $manual); |
|
| 3779 | 3779 | |
| 3780 | 3780 | // Save the order. |
| 3781 | 3781 | return $this->save(); |
@@ -3786,18 +3786,18 @@ discard block |
||
| 3786 | 3786 | * @deprecated |
| 3787 | 3787 | */ |
| 3788 | 3788 | public function refresh_item_ids() { |
| 3789 | - $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
|
| 3790 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3789 | + $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id'))); |
|
| 3790 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3791 | 3791 | } |
| 3792 | 3792 | |
| 3793 | 3793 | /** |
| 3794 | 3794 | * @deprecated |
| 3795 | 3795 | */ |
| 3796 | - public function update_items( $temp = false ) { |
|
| 3796 | + public function update_items($temp = false) { |
|
| 3797 | 3797 | |
| 3798 | - $this->set_items( $this->get_items() ); |
|
| 3798 | + $this->set_items($this->get_items()); |
|
| 3799 | 3799 | |
| 3800 | - if ( ! $temp ) { |
|
| 3800 | + if (!$temp) { |
|
| 3801 | 3801 | $this->save(); |
| 3802 | 3802 | } |
| 3803 | 3803 | |
@@ -3811,11 +3811,11 @@ discard block |
||
| 3811 | 3811 | |
| 3812 | 3812 | $discount_code = $this->get_discount_code(); |
| 3813 | 3813 | |
| 3814 | - if ( empty( $discount_code ) ) { |
|
| 3814 | + if (empty($discount_code)) { |
|
| 3815 | 3815 | return false; |
| 3816 | 3816 | } |
| 3817 | 3817 | |
| 3818 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3818 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3819 | 3819 | |
| 3820 | 3820 | // Ensure it is active. |
| 3821 | 3821 | return $discount->exists(); |
@@ -3826,7 +3826,7 @@ discard block |
||
| 3826 | 3826 | * Refunds an invoice. |
| 3827 | 3827 | */ |
| 3828 | 3828 | public function refund() { |
| 3829 | - $this->set_status( 'wpi-refunded' ); |
|
| 3829 | + $this->set_status('wpi-refunded'); |
|
| 3830 | 3830 | $this->save(); |
| 3831 | 3831 | } |
| 3832 | 3832 | |
@@ -3835,53 +3835,53 @@ discard block |
||
| 3835 | 3835 | * |
| 3836 | 3836 | * @param string $transaction_id |
| 3837 | 3837 | */ |
| 3838 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
| 3838 | + public function mark_paid($transaction_id = null, $note = '') { |
|
| 3839 | 3839 | |
| 3840 | 3840 | // Set the transaction id. |
| 3841 | - if ( empty( $transaction_id ) ) { |
|
| 3841 | + if (empty($transaction_id)) { |
|
| 3842 | 3842 | $transaction_id = $this->generate_key('trans_'); |
| 3843 | 3843 | } |
| 3844 | 3844 | |
| 3845 | - if ( ! $this->get_transaction_id() ) { |
|
| 3846 | - $this->set_transaction_id( $transaction_id ); |
|
| 3845 | + if (!$this->get_transaction_id()) { |
|
| 3846 | + $this->set_transaction_id($transaction_id); |
|
| 3847 | 3847 | } |
| 3848 | 3848 | |
| 3849 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3849 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
| 3850 | 3850 | return $this->save(); |
| 3851 | 3851 | } |
| 3852 | 3852 | |
| 3853 | 3853 | // Set the completed date. |
| 3854 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3854 | + $this->set_date_completed(current_time('mysql')); |
|
| 3855 | 3855 | |
| 3856 | 3856 | // Set the new status. |
| 3857 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
| 3858 | - if ( $this->is_renewal() ) { |
|
| 3857 | + $gateway = sanitize_text_field($this->get_gateway_title()); |
|
| 3858 | + if ($this->is_renewal()) { |
|
| 3859 | 3859 | |
| 3860 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
| 3861 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3860 | + $_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway); |
|
| 3861 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
| 3862 | 3862 | |
| 3863 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3863 | + if ('none' == $this->get_gateway()) { |
|
| 3864 | 3864 | $_note = $note; |
| 3865 | 3865 | } |
| 3866 | 3866 | |
| 3867 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3867 | + $this->set_status('wpi-renewal', $_note); |
|
| 3868 | 3868 | |
| 3869 | 3869 | } else { |
| 3870 | 3870 | |
| 3871 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 3872 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
| 3871 | + $_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway); |
|
| 3872 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
| 3873 | 3873 | |
| 3874 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3874 | + if ('none' == $this->get_gateway()) { |
|
| 3875 | 3875 | $_note = $note; |
| 3876 | 3876 | } |
| 3877 | 3877 | |
| 3878 | - $this->set_status( 'publish', $_note ); |
|
| 3878 | + $this->set_status('publish', $_note); |
|
| 3879 | 3879 | |
| 3880 | 3880 | } |
| 3881 | 3881 | |
| 3882 | 3882 | // Set checkout mode. |
| 3883 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3884 | - $this->set_mode( $mode ); |
|
| 3883 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
| 3884 | + $this->set_mode($mode); |
|
| 3885 | 3885 | |
| 3886 | 3886 | // Save the invoice. |
| 3887 | 3887 | $this->save(); |
@@ -3906,9 +3906,9 @@ discard block |
||
| 3906 | 3906 | * Clears the subscription's cache. |
| 3907 | 3907 | */ |
| 3908 | 3908 | public function clear_cache() { |
| 3909 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3910 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3911 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3909 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
| 3910 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
| 3911 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
| 3912 | 3912 | } |
| 3913 | 3913 | |
| 3914 | 3914 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | - exit; // Exit if accessed directly |
|
| 9 | + exit; // Exit if accessed directly |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | class GetPaid_Meta_Box_Invoice_Subscription { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Output the subscription metabox. |
|
| 19 | - * |
|
| 20 | - * @param WP_Post $post |
|
| 21 | - */ |
|
| 18 | + * Output the subscription metabox. |
|
| 19 | + * |
|
| 20 | + * @param WP_Post $post |
|
| 21 | + */ |
|
| 22 | 22 | public static function output( $post ) { |
| 23 | 23 | |
| 24 | 24 | // Fetch the invoice. |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Output the subscription invoices. |
|
| 38 | - * |
|
| 39 | - * @param WP_Post $post |
|
| 40 | - */ |
|
| 37 | + * Output the subscription invoices. |
|
| 38 | + * |
|
| 39 | + * @param WP_Post $post |
|
| 40 | + */ |
|
| 41 | 41 | public static function output_invoices( $post ) { |
| 42 | 42 | |
| 43 | 43 | // Fetch the invoice. |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * Outputs related subscriptions. |
|
| 57 | - * |
|
| 58 | - * @param WP_Post $post |
|
| 59 | - */ |
|
| 56 | + * Outputs related subscriptions. |
|
| 57 | + * |
|
| 58 | + * @param WP_Post $post |
|
| 59 | + */ |
|
| 60 | 60 | public static function output_related( $post ) { |
| 61 | 61 | |
| 62 | 62 | // Fetch the invoice. |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 8 | +if (!defined('ABSPATH')) { |
|
| 9 | 9 | exit; // Exit if accessed directly |
| 10 | 10 | } |
| 11 | 11 | |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @param WP_Post $post |
| 21 | 21 | */ |
| 22 | - public static function output( $post ) { |
|
| 22 | + public static function output($post) { |
|
| 23 | 23 | |
| 24 | 24 | // Fetch the invoice. |
| 25 | - $invoice = new WPInv_Invoice( $post ); |
|
| 25 | + $invoice = new WPInv_Invoice($post); |
|
| 26 | 26 | |
| 27 | 27 | // Fetch the subscription. |
| 28 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 28 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
| 29 | 29 | |
| 30 | 30 | echo '<div class="bsui">'; |
| 31 | - getpaid_admin_subscription_details_metabox( /** @scrutinizer ignore-type */$subscription ); |
|
| 31 | + getpaid_admin_subscription_details_metabox(/** @scrutinizer ignore-type */$subscription); |
|
| 32 | 32 | echo '</div>'; |
| 33 | 33 | |
| 34 | 34 | } |
@@ -38,16 +38,16 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param WP_Post $post |
| 40 | 40 | */ |
| 41 | - public static function output_invoices( $post ) { |
|
| 41 | + public static function output_invoices($post) { |
|
| 42 | 42 | |
| 43 | 43 | // Fetch the invoice. |
| 44 | - $invoice = new WPInv_Invoice( $post ); |
|
| 44 | + $invoice = new WPInv_Invoice($post); |
|
| 45 | 45 | |
| 46 | 46 | // Fetch the subscription. |
| 47 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 47 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
| 48 | 48 | |
| 49 | 49 | echo '<div class="bsui">'; |
| 50 | - getpaid_admin_subscription_invoice_details_metabox( /** @scrutinizer ignore-type */$subscription, false ); |
|
| 50 | + getpaid_admin_subscription_invoice_details_metabox(/** @scrutinizer ignore-type */$subscription, false); |
|
| 51 | 51 | echo '</div>'; |
| 52 | 52 | |
| 53 | 53 | } |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param WP_Post $post |
| 59 | 59 | */ |
| 60 | - public static function output_related( $post ) { |
|
| 60 | + public static function output_related($post) { |
|
| 61 | 61 | |
| 62 | 62 | // Fetch the invoice. |
| 63 | - $invoice = new WPInv_Invoice( $post ); |
|
| 63 | + $invoice = new WPInv_Invoice($post); |
|
| 64 | 64 | |
| 65 | 65 | // Fetch the subscription. |
| 66 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 66 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
| 67 | 67 | |
| 68 | 68 | echo '<div class="bsui">'; |
| 69 | - getpaid_admin_subscription_related_subscriptions_metabox( /** @scrutinizer ignore-type */$subscription, false ); |
|
| 69 | + getpaid_admin_subscription_related_subscriptions_metabox(/** @scrutinizer ignore-type */$subscription, false); |
|
| 70 | 70 | echo '</div>'; |
| 71 | 71 | |
| 72 | 72 | } |
@@ -14,144 +14,144 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class WPInv_Subscriptions_Widget extends WP_Super_Duper { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Register the widget with WordPress. |
|
| 19 | - * |
|
| 20 | - */ |
|
| 21 | - public function __construct() { |
|
| 22 | - |
|
| 23 | - $options = array( |
|
| 24 | - 'textdomain' => 'invoicing', |
|
| 25 | - 'block-icon' => 'controls-repeat', |
|
| 26 | - 'block-category'=> 'widgets', |
|
| 27 | - 'block-keywords'=> "['invoicing','subscriptions', 'getpaid']", |
|
| 28 | - 'class_name' => __CLASS__, |
|
| 29 | - 'base_id' => 'wpinv_subscriptions', |
|
| 30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 31 | - 'widget_ops' => array( |
|
| 32 | - 'classname' => 'getpaid-subscriptions bsui', |
|
| 33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 34 | - ), |
|
| 35 | - 'arguments' => array( |
|
| 36 | - 'title' => array( |
|
| 37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 39 | - 'type' => 'text', |
|
| 40 | - 'desc_tip' => true, |
|
| 41 | - 'default' => '', |
|
| 42 | - 'advanced' => false |
|
| 43 | - ), |
|
| 44 | - ) |
|
| 45 | - |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - parent::__construct( $options ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Retrieves current user's subscriptions. |
|
| 54 | - * |
|
| 55 | - * @return GetPaid_Subscriptions_Query |
|
| 56 | - */ |
|
| 57 | - public function get_subscriptions() { |
|
| 58 | - |
|
| 59 | - // Prepare license args. |
|
| 60 | - $args = array( |
|
| 61 | - 'customer_in' => get_current_user_id(), |
|
| 62 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 63 | - ); |
|
| 64 | - |
|
| 65 | - return new GetPaid_Subscriptions_Query( $args ); |
|
| 66 | - |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The Super block output function. |
|
| 71 | - * |
|
| 72 | - * @param array $args |
|
| 73 | - * @param array $widget_args |
|
| 74 | - * @param string $content |
|
| 75 | - * |
|
| 76 | - * @return mixed|string|bool |
|
| 77 | - */ |
|
| 78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 79 | - |
|
| 80 | - // Ensure that the user is logged in. |
|
| 81 | - if ( ! is_user_logged_in() ) { |
|
| 82 | - |
|
| 83 | - return aui()->alert( |
|
| 84 | - array( |
|
| 85 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 86 | - 'type' => 'error', |
|
| 87 | - ) |
|
| 88 | - ); |
|
| 89 | - |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // Are we displaying a single subscription? |
|
| 93 | - if ( isset( $_GET['subscription'] ) ) { |
|
| 94 | - return $this->display_single_subscription( trim( $_GET['subscription'] ) ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // Retrieve the user's subscriptions. |
|
| 98 | - $subscriptions = $this->get_subscriptions(); |
|
| 99 | - |
|
| 100 | - // Start the output buffer. |
|
| 101 | - ob_start(); |
|
| 102 | - |
|
| 103 | - // Backwards compatibility. |
|
| 104 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
| 105 | - |
|
| 106 | - // Display errors and notices. |
|
| 107 | - wpinv_print_errors(); |
|
| 108 | - |
|
| 109 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 110 | - |
|
| 111 | - // Print the table header. |
|
| 112 | - $this->print_table_header(); |
|
| 113 | - |
|
| 114 | - // Print table body. |
|
| 115 | - $this->print_table_body( $subscriptions->get_results() ); |
|
| 116 | - |
|
| 117 | - // Print table footer. |
|
| 118 | - $this->print_table_footer(); |
|
| 119 | - |
|
| 120 | - // Print the navigation. |
|
| 121 | - $this->print_navigation( $subscriptions->get_total() ); |
|
| 122 | - |
|
| 123 | - // Backwards compatibility. |
|
| 124 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
| 125 | - |
|
| 126 | - // Return the output. |
|
| 127 | - return ob_get_clean(); |
|
| 128 | - |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Retrieves the subscription columns. |
|
| 133 | - * |
|
| 134 | - * @return array |
|
| 135 | - */ |
|
| 136 | - public function get_subscriptions_table_columns() { |
|
| 17 | + /** |
|
| 18 | + * Register the widget with WordPress. |
|
| 19 | + * |
|
| 20 | + */ |
|
| 21 | + public function __construct() { |
|
| 22 | + |
|
| 23 | + $options = array( |
|
| 24 | + 'textdomain' => 'invoicing', |
|
| 25 | + 'block-icon' => 'controls-repeat', |
|
| 26 | + 'block-category'=> 'widgets', |
|
| 27 | + 'block-keywords'=> "['invoicing','subscriptions', 'getpaid']", |
|
| 28 | + 'class_name' => __CLASS__, |
|
| 29 | + 'base_id' => 'wpinv_subscriptions', |
|
| 30 | + 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 31 | + 'widget_ops' => array( |
|
| 32 | + 'classname' => 'getpaid-subscriptions bsui', |
|
| 33 | + 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 34 | + ), |
|
| 35 | + 'arguments' => array( |
|
| 36 | + 'title' => array( |
|
| 37 | + 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | + 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 39 | + 'type' => 'text', |
|
| 40 | + 'desc_tip' => true, |
|
| 41 | + 'default' => '', |
|
| 42 | + 'advanced' => false |
|
| 43 | + ), |
|
| 44 | + ) |
|
| 45 | + |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + parent::__construct( $options ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Retrieves current user's subscriptions. |
|
| 54 | + * |
|
| 55 | + * @return GetPaid_Subscriptions_Query |
|
| 56 | + */ |
|
| 57 | + public function get_subscriptions() { |
|
| 58 | + |
|
| 59 | + // Prepare license args. |
|
| 60 | + $args = array( |
|
| 61 | + 'customer_in' => get_current_user_id(), |
|
| 62 | + 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 63 | + ); |
|
| 64 | + |
|
| 65 | + return new GetPaid_Subscriptions_Query( $args ); |
|
| 66 | + |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The Super block output function. |
|
| 71 | + * |
|
| 72 | + * @param array $args |
|
| 73 | + * @param array $widget_args |
|
| 74 | + * @param string $content |
|
| 75 | + * |
|
| 76 | + * @return mixed|string|bool |
|
| 77 | + */ |
|
| 78 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 79 | + |
|
| 80 | + // Ensure that the user is logged in. |
|
| 81 | + if ( ! is_user_logged_in() ) { |
|
| 82 | + |
|
| 83 | + return aui()->alert( |
|
| 84 | + array( |
|
| 85 | + 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 86 | + 'type' => 'error', |
|
| 87 | + ) |
|
| 88 | + ); |
|
| 89 | + |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // Are we displaying a single subscription? |
|
| 93 | + if ( isset( $_GET['subscription'] ) ) { |
|
| 94 | + return $this->display_single_subscription( trim( $_GET['subscription'] ) ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // Retrieve the user's subscriptions. |
|
| 98 | + $subscriptions = $this->get_subscriptions(); |
|
| 99 | + |
|
| 100 | + // Start the output buffer. |
|
| 101 | + ob_start(); |
|
| 102 | + |
|
| 103 | + // Backwards compatibility. |
|
| 104 | + do_action( 'wpinv_before_user_subscriptions' ); |
|
| 105 | + |
|
| 106 | + // Display errors and notices. |
|
| 107 | + wpinv_print_errors(); |
|
| 108 | + |
|
| 109 | + do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 110 | + |
|
| 111 | + // Print the table header. |
|
| 112 | + $this->print_table_header(); |
|
| 113 | + |
|
| 114 | + // Print table body. |
|
| 115 | + $this->print_table_body( $subscriptions->get_results() ); |
|
| 116 | + |
|
| 117 | + // Print table footer. |
|
| 118 | + $this->print_table_footer(); |
|
| 119 | + |
|
| 120 | + // Print the navigation. |
|
| 121 | + $this->print_navigation( $subscriptions->get_total() ); |
|
| 122 | + |
|
| 123 | + // Backwards compatibility. |
|
| 124 | + do_action( 'wpinv_after_user_subscriptions' ); |
|
| 125 | + |
|
| 126 | + // Return the output. |
|
| 127 | + return ob_get_clean(); |
|
| 128 | + |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Retrieves the subscription columns. |
|
| 133 | + * |
|
| 134 | + * @return array |
|
| 135 | + */ |
|
| 136 | + public function get_subscriptions_table_columns() { |
|
| 137 | 137 | |
| 138 | - $columns = array( |
|
| 139 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 140 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 141 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 142 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 143 | - ); |
|
| 138 | + $columns = array( |
|
| 139 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 140 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 141 | + 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 142 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 143 | + ); |
|
| 144 | 144 | |
| 145 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 146 | - } |
|
| 145 | + return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Displays the table header. |
|
| 150 | - * |
|
| 151 | - */ |
|
| 152 | - public function print_table_header() { |
|
| 148 | + /** |
|
| 149 | + * Displays the table header. |
|
| 150 | + * |
|
| 151 | + */ |
|
| 152 | + public function print_table_header() { |
|
| 153 | 153 | |
| 154 | - ?> |
|
| 154 | + ?> |
|
| 155 | 155 | |
| 156 | 156 | <table class="table table-bordered table-striped"> |
| 157 | 157 | |
@@ -167,121 +167,121 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | <?php |
| 169 | 169 | |
| 170 | - } |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Displays the table body. |
|
| 174 | - * |
|
| 175 | - * @param WPInv_Subscription[] $subscriptions |
|
| 176 | - */ |
|
| 177 | - public function print_table_body( $subscriptions ) { |
|
| 172 | + /** |
|
| 173 | + * Displays the table body. |
|
| 174 | + * |
|
| 175 | + * @param WPInv_Subscription[] $subscriptions |
|
| 176 | + */ |
|
| 177 | + public function print_table_body( $subscriptions ) { |
|
| 178 | 178 | |
| 179 | - if ( empty( $subscriptions ) ) { |
|
| 180 | - $this->print_table_body_no_subscriptions(); |
|
| 181 | - } else { |
|
| 182 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
| 183 | - } |
|
| 179 | + if ( empty( $subscriptions ) ) { |
|
| 180 | + $this->print_table_body_no_subscriptions(); |
|
| 181 | + } else { |
|
| 182 | + $this->print_table_body_subscriptions( $subscriptions ); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * Displays the table body if no subscriptions were found. |
|
| 189 | - * |
|
| 190 | - */ |
|
| 191 | - public function print_table_body_no_subscriptions() { |
|
| 187 | + /** |
|
| 188 | + * Displays the table body if no subscriptions were found. |
|
| 189 | + * |
|
| 190 | + */ |
|
| 191 | + public function print_table_body_no_subscriptions() { |
|
| 192 | 192 | |
| 193 | - ?> |
|
| 193 | + ?> |
|
| 194 | 194 | <tbody> |
| 195 | 195 | |
| 196 | 196 | <tr> |
| 197 | 197 | <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
| 198 | 198 | |
| 199 | 199 | <?php |
| 200 | - echo aui()->alert( |
|
| 201 | - array( |
|
| 202 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 203 | - 'type' => 'warning', |
|
| 204 | - ) |
|
| 205 | - ); |
|
| 206 | - ?> |
|
| 200 | + echo aui()->alert( |
|
| 201 | + array( |
|
| 202 | + 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 203 | + 'type' => 'warning', |
|
| 204 | + ) |
|
| 205 | + ); |
|
| 206 | + ?> |
|
| 207 | 207 | |
| 208 | 208 | </td> |
| 209 | 209 | </tr> |
| 210 | 210 | |
| 211 | 211 | </tbody> |
| 212 | 212 | <?php |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Displays the table body if subscriptions were found. |
|
| 217 | - * |
|
| 218 | - * @param WPInv_Subscription[] $subscriptions |
|
| 219 | - */ |
|
| 220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
| 215 | + /** |
|
| 216 | + * Displays the table body if subscriptions were found. |
|
| 217 | + * |
|
| 218 | + * @param WPInv_Subscription[] $subscriptions |
|
| 219 | + */ |
|
| 220 | + public function print_table_body_subscriptions( $subscriptions ) { |
|
| 221 | 221 | |
| 222 | - ?> |
|
| 222 | + ?> |
|
| 223 | 223 | <tbody> |
| 224 | 224 | |
| 225 | 225 | <?php foreach ( $subscriptions as $subscription ) : ?> |
| 226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
| 227 | 227 | <?php |
| 228 | - wpinv_get_template( |
|
| 229 | - 'subscriptions/subscriptions-table-row.php', |
|
| 230 | - array( |
|
| 231 | - 'subscription' => $subscription, |
|
| 232 | - 'widget' => $this |
|
| 233 | - ) |
|
| 234 | - ); |
|
| 235 | - ?> |
|
| 228 | + wpinv_get_template( |
|
| 229 | + 'subscriptions/subscriptions-table-row.php', |
|
| 230 | + array( |
|
| 231 | + 'subscription' => $subscription, |
|
| 232 | + 'widget' => $this |
|
| 233 | + ) |
|
| 234 | + ); |
|
| 235 | + ?> |
|
| 236 | 236 | </tr> |
| 237 | 237 | <?php endforeach; ?> |
| 238 | 238 | |
| 239 | 239 | </tbody> |
| 240 | 240 | <?php |
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Adds row actions to a column |
|
| 245 | - * |
|
| 246 | - * @param string $content column content |
|
| 247 | - * @param WPInv_Subscription $subscription |
|
| 248 | - * @since 1.0.0 |
|
| 249 | - * @return string |
|
| 250 | - */ |
|
| 251 | - public function add_row_actions( $content, $subscription ) { |
|
| 252 | - |
|
| 253 | - // Prepare row actions. |
|
| 254 | - $actions = array(); |
|
| 255 | - |
|
| 256 | - // View subscription action. |
|
| 257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 260 | - |
|
| 261 | - // Filter the actions. |
|
| 262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 263 | - |
|
| 264 | - $sanitized = array(); |
|
| 265 | - foreach ( $actions as $key => $action ) { |
|
| 266 | - $key = sanitize_html_class( $key ); |
|
| 267 | - $action = wp_kses_post( $action ); |
|
| 268 | - $sanitized[] = "<span class='$key'>$action</span>"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
| 272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
| 273 | - $row_actions .= '</small>'; |
|
| 274 | - |
|
| 275 | - return $content . $row_actions; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Displays the table footer. |
|
| 280 | - * |
|
| 281 | - */ |
|
| 282 | - public function print_table_footer() { |
|
| 283 | - |
|
| 284 | - ?> |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Adds row actions to a column |
|
| 245 | + * |
|
| 246 | + * @param string $content column content |
|
| 247 | + * @param WPInv_Subscription $subscription |
|
| 248 | + * @since 1.0.0 |
|
| 249 | + * @return string |
|
| 250 | + */ |
|
| 251 | + public function add_row_actions( $content, $subscription ) { |
|
| 252 | + |
|
| 253 | + // Prepare row actions. |
|
| 254 | + $actions = array(); |
|
| 255 | + |
|
| 256 | + // View subscription action. |
|
| 257 | + $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | + $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 260 | + |
|
| 261 | + // Filter the actions. |
|
| 262 | + $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 263 | + |
|
| 264 | + $sanitized = array(); |
|
| 265 | + foreach ( $actions as $key => $action ) { |
|
| 266 | + $key = sanitize_html_class( $key ); |
|
| 267 | + $action = wp_kses_post( $action ); |
|
| 268 | + $sanitized[] = "<span class='$key'>$action</span>"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
| 272 | + $row_actions .= implode( ' | ', $sanitized ); |
|
| 273 | + $row_actions .= '</small>'; |
|
| 274 | + |
|
| 275 | + return $content . $row_actions; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Displays the table footer. |
|
| 280 | + * |
|
| 281 | + */ |
|
| 282 | + public function print_table_footer() { |
|
| 283 | + |
|
| 284 | + ?> |
|
| 285 | 285 | |
| 286 | 286 | <tfoot> |
| 287 | 287 | <tr> |
@@ -296,143 +296,143 @@ discard block |
||
| 296 | 296 | </table> |
| 297 | 297 | <?php |
| 298 | 298 | |
| 299 | - } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - /** |
|
| 302 | - * Displays the navigation. |
|
| 303 | - * |
|
| 304 | - * @param int $total |
|
| 305 | - */ |
|
| 306 | - public function print_navigation( $total ) { |
|
| 301 | + /** |
|
| 302 | + * Displays the navigation. |
|
| 303 | + * |
|
| 304 | + * @param int $total |
|
| 305 | + */ |
|
| 306 | + public function print_navigation( $total ) { |
|
| 307 | 307 | |
| 308 | - if ( $total < 1 ) { |
|
| 308 | + if ( $total < 1 ) { |
|
| 309 | 309 | |
| 310 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 311 | - $args = array( |
|
| 312 | - 'customer_in' => get_current_user_id(), |
|
| 313 | - 'fields' => 'id', |
|
| 314 | - ); |
|
| 310 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 311 | + $args = array( |
|
| 312 | + 'customer_in' => get_current_user_id(), |
|
| 313 | + 'fields' => 'id', |
|
| 314 | + ); |
|
| 315 | 315 | |
| 316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 317 | - $total = $count_query->get_total(); |
|
| 318 | - } |
|
| 316 | + $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 317 | + $total = $count_query->get_total(); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - // Abort if we do not have pages. |
|
| 321 | - if ( 2 > $total ) { |
|
| 322 | - return; |
|
| 323 | - } |
|
| 320 | + // Abort if we do not have pages. |
|
| 321 | + if ( 2 > $total ) { |
|
| 322 | + return; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - ?> |
|
| 325 | + ?> |
|
| 326 | 326 | |
| 327 | 327 | <div class="getpaid-subscriptions-pagination"> |
| 328 | 328 | <?php |
| 329 | - $big = 999999; |
|
| 330 | - |
|
| 331 | - echo getpaid_paginate_links( |
|
| 332 | - array( |
|
| 333 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 334 | - 'format' => '?paged=%#%', |
|
| 335 | - 'total' => (int) ceil( $total / 10 ), |
|
| 336 | - ) |
|
| 337 | - ); |
|
| 338 | - ?> |
|
| 329 | + $big = 999999; |
|
| 330 | + |
|
| 331 | + echo getpaid_paginate_links( |
|
| 332 | + array( |
|
| 333 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 334 | + 'format' => '?paged=%#%', |
|
| 335 | + 'total' => (int) ceil( $total / 10 ), |
|
| 336 | + ) |
|
| 337 | + ); |
|
| 338 | + ?> |
|
| 339 | 339 | </div> |
| 340 | 340 | |
| 341 | 341 | <?php |
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Returns a single subscription's columns. |
|
| 346 | - * |
|
| 347 | - * @param WPInv_Subscription $subscription |
|
| 348 | - * |
|
| 349 | - * @return array |
|
| 350 | - */ |
|
| 351 | - public function get_single_subscription_columns( $subscription ) { |
|
| 352 | - |
|
| 353 | - // Prepare subscription detail columns. |
|
| 354 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 355 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 356 | - $fields = apply_filters( |
|
| 357 | - 'getpaid_single_subscription_details_fields', |
|
| 358 | - array( |
|
| 359 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 360 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 361 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 362 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 363 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 364 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
| 365 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 366 | - ), |
|
| 367 | - $subscription |
|
| 368 | - ); |
|
| 369 | - |
|
| 370 | - if ( isset( $fields['expiry_date'] ) ) { |
|
| 371 | - |
|
| 372 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 373 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - if ( 'pending' == $subscription->get_status() ) { |
|
| 377 | - unset( $fields['expiry_date'] ); |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
| 383 | - unset( $fields['start_date'] ); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
| 387 | - unset( $fields['initial_amount'] ); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - return $fields; |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Displays a single subscription. |
|
| 395 | - * |
|
| 396 | - * @param string $subscription |
|
| 397 | - * |
|
| 398 | - * @return string |
|
| 399 | - */ |
|
| 400 | - public function display_single_subscription( $subscription ) { |
|
| 401 | - |
|
| 402 | - // Fetch the subscription. |
|
| 403 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 404 | - |
|
| 405 | - if ( ! $subscription->exists() ) { |
|
| 406 | - |
|
| 407 | - return aui()->alert( |
|
| 408 | - array( |
|
| 409 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 410 | - 'type' => 'error', |
|
| 411 | - ) |
|
| 412 | - ); |
|
| 413 | - |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - // Ensure that the user owns this subscription key. |
|
| 417 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 418 | - |
|
| 419 | - return aui()->alert( |
|
| 420 | - array( |
|
| 421 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 422 | - 'type' => 'error', |
|
| 423 | - ) |
|
| 424 | - ); |
|
| 425 | - |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - return wpinv_get_template_html( |
|
| 429 | - 'subscriptions/subscription-details.php', |
|
| 430 | - array( |
|
| 431 | - 'subscription' => $subscription, |
|
| 432 | - 'widget' => $this |
|
| 433 | - ) |
|
| 434 | - ); |
|
| 435 | - |
|
| 436 | - } |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Returns a single subscription's columns. |
|
| 346 | + * |
|
| 347 | + * @param WPInv_Subscription $subscription |
|
| 348 | + * |
|
| 349 | + * @return array |
|
| 350 | + */ |
|
| 351 | + public function get_single_subscription_columns( $subscription ) { |
|
| 352 | + |
|
| 353 | + // Prepare subscription detail columns. |
|
| 354 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 355 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 356 | + $fields = apply_filters( |
|
| 357 | + 'getpaid_single_subscription_details_fields', |
|
| 358 | + array( |
|
| 359 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 360 | + 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 361 | + 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 362 | + 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 363 | + 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 364 | + 'payments' => __( 'Payments', 'invoicing' ), |
|
| 365 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 366 | + ), |
|
| 367 | + $subscription |
|
| 368 | + ); |
|
| 369 | + |
|
| 370 | + if ( isset( $fields['expiry_date'] ) ) { |
|
| 371 | + |
|
| 372 | + if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 373 | + $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + if ( 'pending' == $subscription->get_status() ) { |
|
| 377 | + unset( $fields['expiry_date'] ); |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
| 383 | + unset( $fields['start_date'] ); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
| 387 | + unset( $fields['initial_amount'] ); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + return $fields; |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Displays a single subscription. |
|
| 395 | + * |
|
| 396 | + * @param string $subscription |
|
| 397 | + * |
|
| 398 | + * @return string |
|
| 399 | + */ |
|
| 400 | + public function display_single_subscription( $subscription ) { |
|
| 401 | + |
|
| 402 | + // Fetch the subscription. |
|
| 403 | + $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 404 | + |
|
| 405 | + if ( ! $subscription->exists() ) { |
|
| 406 | + |
|
| 407 | + return aui()->alert( |
|
| 408 | + array( |
|
| 409 | + 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 410 | + 'type' => 'error', |
|
| 411 | + ) |
|
| 412 | + ); |
|
| 413 | + |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + // Ensure that the user owns this subscription key. |
|
| 417 | + if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 418 | + |
|
| 419 | + return aui()->alert( |
|
| 420 | + array( |
|
| 421 | + 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 422 | + 'type' => 'error', |
|
| 423 | + ) |
|
| 424 | + ); |
|
| 425 | + |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + return wpinv_get_template_html( |
|
| 429 | + 'subscriptions/subscription-details.php', |
|
| 430 | + array( |
|
| 431 | + 'subscription' => $subscription, |
|
| 432 | + 'widget' => $this |
|
| 433 | + ) |
|
| 434 | + ); |
|
| 435 | + |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @version 1.0.0 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Contains the subscriptions widget. |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | 'block-keywords'=> "['invoicing','subscriptions', 'getpaid']", |
| 28 | 28 | 'class_name' => __CLASS__, |
| 29 | 29 | 'base_id' => 'wpinv_subscriptions', |
| 30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 30 | + 'name' => __('GetPaid > Subscriptions', 'invoicing'), |
|
| 31 | 31 | 'widget_ops' => array( |
| 32 | 32 | 'classname' => 'getpaid-subscriptions bsui', |
| 33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 33 | + 'description' => esc_html__("Displays the current user's subscriptions.", 'invoicing'), |
|
| 34 | 34 | ), |
| 35 | 35 | 'arguments' => array( |
| 36 | 36 | 'title' => array( |
| 37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 37 | + 'title' => __('Widget title', 'invoicing'), |
|
| 38 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 39 | 39 | 'type' => 'text', |
| 40 | 40 | 'desc_tip' => true, |
| 41 | 41 | 'default' => '', |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - parent::__construct( $options ); |
|
| 49 | + parent::__construct($options); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | public function get_subscriptions() { |
| 58 | 58 | |
| 59 | 59 | // Prepare license args. |
| 60 | - $args = array( |
|
| 60 | + $args = array( |
|
| 61 | 61 | 'customer_in' => get_current_user_id(), |
| 62 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 62 | + 'paged' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - return new GetPaid_Subscriptions_Query( $args ); |
|
| 65 | + return new GetPaid_Subscriptions_Query($args); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -75,14 +75,14 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return mixed|string|bool |
| 77 | 77 | */ |
| 78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 78 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 79 | 79 | |
| 80 | 80 | // Ensure that the user is logged in. |
| 81 | - if ( ! is_user_logged_in() ) { |
|
| 81 | + if (!is_user_logged_in()) { |
|
| 82 | 82 | |
| 83 | 83 | return aui()->alert( |
| 84 | 84 | array( |
| 85 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 85 | + 'content' => wp_kses_post(__('You need to log-in or create an account to view this section.', 'invoicing')), |
|
| 86 | 86 | 'type' => 'error', |
| 87 | 87 | ) |
| 88 | 88 | ); |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Are we displaying a single subscription? |
| 93 | - if ( isset( $_GET['subscription'] ) ) { |
|
| 94 | - return $this->display_single_subscription( trim( $_GET['subscription'] ) ); |
|
| 93 | + if (isset($_GET['subscription'])) { |
|
| 94 | + return $this->display_single_subscription(trim($_GET['subscription'])); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Retrieve the user's subscriptions. |
@@ -101,27 +101,27 @@ discard block |
||
| 101 | 101 | ob_start(); |
| 102 | 102 | |
| 103 | 103 | // Backwards compatibility. |
| 104 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
| 104 | + do_action('wpinv_before_user_subscriptions'); |
|
| 105 | 105 | |
| 106 | 106 | // Display errors and notices. |
| 107 | 107 | wpinv_print_errors(); |
| 108 | 108 | |
| 109 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 109 | + do_action('getpaid_license_manager_before_subscriptions', $subscriptions); |
|
| 110 | 110 | |
| 111 | 111 | // Print the table header. |
| 112 | 112 | $this->print_table_header(); |
| 113 | 113 | |
| 114 | 114 | // Print table body. |
| 115 | - $this->print_table_body( $subscriptions->get_results() ); |
|
| 115 | + $this->print_table_body($subscriptions->get_results()); |
|
| 116 | 116 | |
| 117 | 117 | // Print table footer. |
| 118 | 118 | $this->print_table_footer(); |
| 119 | 119 | |
| 120 | 120 | // Print the navigation. |
| 121 | - $this->print_navigation( $subscriptions->get_total() ); |
|
| 121 | + $this->print_navigation($subscriptions->get_total()); |
|
| 122 | 122 | |
| 123 | 123 | // Backwards compatibility. |
| 124 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
| 124 | + do_action('wpinv_after_user_subscriptions'); |
|
| 125 | 125 | |
| 126 | 126 | // Return the output. |
| 127 | 127 | return ob_get_clean(); |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | public function get_subscriptions_table_columns() { |
| 137 | 137 | |
| 138 | 138 | $columns = array( |
| 139 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 140 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 141 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 142 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 139 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 140 | + 'amount' => __('Amount', 'invoicing'), |
|
| 141 | + 'renewal-date' => __('Next payment', 'invoicing'), |
|
| 142 | + 'status' => __('Status', 'invoicing'), |
|
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 145 | + return apply_filters('getpaid_frontend_subscriptions_table_columns', $columns); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | <thead> |
| 159 | 159 | <tr> |
| 160 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
| 161 | - <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 162 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 160 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
| 161 | + <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class($key); ?>"> |
|
| 162 | + <?php echo sanitize_text_field($label); ?> |
|
| 163 | 163 | </th> |
| 164 | 164 | <?php endforeach; ?> |
| 165 | 165 | </tr> |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param WPInv_Subscription[] $subscriptions |
| 176 | 176 | */ |
| 177 | - public function print_table_body( $subscriptions ) { |
|
| 177 | + public function print_table_body($subscriptions) { |
|
| 178 | 178 | |
| 179 | - if ( empty( $subscriptions ) ) { |
|
| 179 | + if (empty($subscriptions)) { |
|
| 180 | 180 | $this->print_table_body_no_subscriptions(); |
| 181 | 181 | } else { |
| 182 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
| 182 | + $this->print_table_body_subscriptions($subscriptions); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | } |
@@ -194,12 +194,12 @@ discard block |
||
| 194 | 194 | <tbody> |
| 195 | 195 | |
| 196 | 196 | <tr> |
| 197 | - <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
|
| 197 | + <td colspan="<?php echo count($this->get_subscriptions_table_columns()); ?>"> |
|
| 198 | 198 | |
| 199 | 199 | <?php |
| 200 | 200 | echo aui()->alert( |
| 201 | 201 | array( |
| 202 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 202 | + 'content' => wp_kses_post(__('No subscriptions found.', 'invoicing')), |
|
| 203 | 203 | 'type' => 'warning', |
| 204 | 204 | ) |
| 205 | 205 | ); |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @param WPInv_Subscription[] $subscriptions |
| 219 | 219 | */ |
| 220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
| 220 | + public function print_table_body_subscriptions($subscriptions) { |
|
| 221 | 221 | |
| 222 | 222 | ?> |
| 223 | 223 | <tbody> |
| 224 | 224 | |
| 225 | - <?php foreach ( $subscriptions as $subscription ) : ?> |
|
| 225 | + <?php foreach ($subscriptions as $subscription) : ?> |
|
| 226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
| 227 | 227 | <?php |
| 228 | 228 | wpinv_get_template( |
@@ -248,28 +248,28 @@ discard block |
||
| 248 | 248 | * @since 1.0.0 |
| 249 | 249 | * @return string |
| 250 | 250 | */ |
| 251 | - public function add_row_actions( $content, $subscription ) { |
|
| 251 | + public function add_row_actions($content, $subscription) { |
|
| 252 | 252 | |
| 253 | 253 | // Prepare row actions. |
| 254 | 254 | $actions = array(); |
| 255 | 255 | |
| 256 | 256 | // View subscription action. |
| 257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 257 | + $view_url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
| 258 | + $view_url = esc_url(add_query_arg('subscription', (int) $subscription->get_id(), $view_url)); |
|
| 259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
| 260 | 260 | |
| 261 | 261 | // Filter the actions. |
| 262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 262 | + $actions = apply_filters('getpaid_subscriptions_table_subscription_actions', $actions, $subscription); |
|
| 263 | 263 | |
| 264 | - $sanitized = array(); |
|
| 265 | - foreach ( $actions as $key => $action ) { |
|
| 266 | - $key = sanitize_html_class( $key ); |
|
| 267 | - $action = wp_kses_post( $action ); |
|
| 264 | + $sanitized = array(); |
|
| 265 | + foreach ($actions as $key => $action) { |
|
| 266 | + $key = sanitize_html_class($key); |
|
| 267 | + $action = wp_kses_post($action); |
|
| 268 | 268 | $sanitized[] = "<span class='$key'>$action</span>"; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
| 272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
| 272 | + $row_actions .= implode(' | ', $sanitized); |
|
| 273 | 273 | $row_actions .= '</small>'; |
| 274 | 274 | |
| 275 | 275 | return $content . $row_actions; |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | <tfoot> |
| 287 | 287 | <tr> |
| 288 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
| 289 | - <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 290 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 288 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
| 289 | + <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class($key); ?>"> |
|
| 290 | + <?php echo sanitize_text_field($label); ?> |
|
| 291 | 291 | </th> |
| 292 | 292 | <?php endforeach; ?> |
| 293 | 293 | </tr> |
@@ -303,22 +303,22 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @param int $total |
| 305 | 305 | */ |
| 306 | - public function print_navigation( $total ) { |
|
| 306 | + public function print_navigation($total) { |
|
| 307 | 307 | |
| 308 | - if ( $total < 1 ) { |
|
| 308 | + if ($total < 1) { |
|
| 309 | 309 | |
| 310 | 310 | // Out-of-bounds, run the query again without LIMIT for total count. |
| 311 | - $args = array( |
|
| 311 | + $args = array( |
|
| 312 | 312 | 'customer_in' => get_current_user_id(), |
| 313 | 313 | 'fields' => 'id', |
| 314 | 314 | ); |
| 315 | 315 | |
| 316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 316 | + $count_query = new GetPaid_Subscriptions_Query($args); |
|
| 317 | 317 | $total = $count_query->get_total(); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Abort if we do not have pages. |
| 321 | - if ( 2 > $total ) { |
|
| 321 | + if (2 > $total) { |
|
| 322 | 322 | return; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | echo getpaid_paginate_links( |
| 332 | 332 | array( |
| 333 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 333 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 334 | 334 | 'format' => '?paged=%#%', |
| 335 | - 'total' => (int) ceil( $total / 10 ), |
|
| 335 | + 'total' => (int) ceil($total / 10), |
|
| 336 | 336 | ) |
| 337 | 337 | ); |
| 338 | 338 | ?> |
@@ -348,43 +348,43 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @return array |
| 350 | 350 | */ |
| 351 | - public function get_single_subscription_columns( $subscription ) { |
|
| 351 | + public function get_single_subscription_columns($subscription) { |
|
| 352 | 352 | |
| 353 | 353 | // Prepare subscription detail columns. |
| 354 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 355 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 354 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
| 355 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
| 356 | 356 | $fields = apply_filters( |
| 357 | 357 | 'getpaid_single_subscription_details_fields', |
| 358 | 358 | array( |
| 359 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 360 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 361 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 362 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 363 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 364 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
| 365 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 359 | + 'status' => __('Status', 'invoicing'), |
|
| 360 | + 'initial_amount' => __('Initial amount', 'invoicing'), |
|
| 361 | + 'recurring_amount' => __('Recurring amount', 'invoicing'), |
|
| 362 | + 'start_date' => __('Start date', 'invoicing'), |
|
| 363 | + 'expiry_date' => __('Next payment', 'invoicing'), |
|
| 364 | + 'payments' => __('Payments', 'invoicing'), |
|
| 365 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
| 366 | 366 | ), |
| 367 | 367 | $subscription |
| 368 | 368 | ); |
| 369 | 369 | |
| 370 | - if ( isset( $fields['expiry_date'] ) ) { |
|
| 370 | + if (isset($fields['expiry_date'])) { |
|
| 371 | 371 | |
| 372 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 373 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 372 | + if (!$subscription->is_active() || $subscription->is_last_renewal()) { |
|
| 373 | + $fields['expiry_date'] = __('End date', 'invoicing'); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( 'pending' == $subscription->get_status() ) { |
|
| 377 | - unset( $fields['expiry_date'] ); |
|
| 376 | + if ('pending' == $subscription->get_status()) { |
|
| 377 | + unset($fields['expiry_date']); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
| 383 | - unset( $fields['start_date'] ); |
|
| 382 | + if (isset($fields['start_date']) && 'pending' == $subscription->get_status()) { |
|
| 383 | + unset($fields['start_date']); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
| 387 | - unset( $fields['initial_amount'] ); |
|
| 386 | + if ($subscription->get_initial_amount() == $subscription->get_recurring_amount()) { |
|
| 387 | + unset($fields['initial_amount']); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | return $fields; |
@@ -397,16 +397,16 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @return string |
| 399 | 399 | */ |
| 400 | - public function display_single_subscription( $subscription ) { |
|
| 400 | + public function display_single_subscription($subscription) { |
|
| 401 | 401 | |
| 402 | 402 | // Fetch the subscription. |
| 403 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 403 | + $subscription = new WPInv_Subscription((int) $subscription); |
|
| 404 | 404 | |
| 405 | - if ( ! $subscription->exists() ) { |
|
| 405 | + if (!$subscription->exists()) { |
|
| 406 | 406 | |
| 407 | 407 | return aui()->alert( |
| 408 | 408 | array( |
| 409 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 409 | + 'content' => wp_kses_post(__('Subscription not found.', 'invoicing')), |
|
| 410 | 410 | 'type' => 'error', |
| 411 | 411 | ) |
| 412 | 412 | ); |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | // Ensure that the user owns this subscription key. |
| 417 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 417 | + if (get_current_user_id() != $subscription->get_customer_id() && !wpinv_current_user_can_manage_invoicing()) { |
|
| 418 | 418 | |
| 419 | 419 | return aui()->alert( |
| 420 | 420 | array( |
| 421 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 421 | + 'content' => wp_kses_post(__('You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing')), |
|
| 422 | 422 | 'type' => 'error', |
| 423 | 423 | ) |
| 424 | 424 | ); |