@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -10,891 +10,891 @@ discard block |
||
| 10 | 10 | class GetPaid_Payment_Form_Submission { |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Submission ID |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - public $id = null; |
|
| 13 | + * Submission ID |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + public $id = null; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Sets the associated payment form. |
|
| 21 | - * |
|
| 22 | - * @var GetPaid_Payment_Form |
|
| 23 | - */ |
|
| 19 | + /** |
|
| 20 | + * Sets the associated payment form. |
|
| 21 | + * |
|
| 22 | + * @var GetPaid_Payment_Form |
|
| 23 | + */ |
|
| 24 | 24 | protected $payment_form = null; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * The country for the submission. |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - public $country = null; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * The state for the submission. |
|
| 35 | - * |
|
| 36 | - * @since 1.0.19 |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - public $state = null; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * The invoice associated with the submission. |
|
| 43 | - * |
|
| 44 | - * @var WPInv_Invoice |
|
| 45 | - */ |
|
| 46 | - protected $invoice = null; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * The discount associated with the submission. |
|
| 50 | - * |
|
| 51 | - * @var WPInv_Discount |
|
| 52 | - */ |
|
| 53 | - protected $discount = null; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * The raw submission data. |
|
| 57 | - * |
|
| 58 | - * @var array |
|
| 59 | - */ |
|
| 60 | - protected $data = null; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Whether this submission contains a recurring item. |
|
| 64 | - * |
|
| 65 | - * @var bool |
|
| 66 | - */ |
|
| 67 | - public $has_recurring = false; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The sub total amount for the submission. |
|
| 71 | - * |
|
| 72 | - * @var float |
|
| 73 | - */ |
|
| 74 | - public $subtotal_amount = 0; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * The total discount amount for the submission. |
|
| 78 | - * |
|
| 79 | - * @var float |
|
| 80 | - */ |
|
| 81 | - protected $total_discount_amount = 0; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * The total tax amount for the submission. |
|
| 85 | - * |
|
| 86 | - * @var float |
|
| 87 | - */ |
|
| 88 | - protected $total_tax_amount = 0; |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * The total fees amount for the submission. |
|
| 92 | - * |
|
| 93 | - * @var float |
|
| 94 | - */ |
|
| 95 | - protected $total_fees_amount = 0; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * An array of fees for the submission. |
|
| 99 | - * |
|
| 100 | - * @var array |
|
| 101 | - */ |
|
| 102 | - protected $fees = array(); |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * An array of discounts for the submission. |
|
| 106 | - * |
|
| 107 | - * @var array |
|
| 108 | - */ |
|
| 109 | - protected $discounts = array(); |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * An array of taxes for the submission. |
|
| 113 | - * |
|
| 114 | - * @var array |
|
| 115 | - */ |
|
| 116 | - protected $taxes = array(); |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * An array of items for the submission. |
|
| 120 | - * |
|
| 121 | - * @var GetPaid_Form_Item[] |
|
| 122 | - */ |
|
| 123 | - protected $items = array(); |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * The last error. |
|
| 127 | - * |
|
| 128 | - * @var string |
|
| 129 | - */ |
|
| 130 | - public $last_error = null; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Is the discount valid? |
|
| 134 | - * |
|
| 135 | - * @var bool |
|
| 136 | - */ |
|
| 137 | - public $is_discount_valid = true; |
|
| 27 | + * The country for the submission. |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + public $country = null; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * The state for the submission. |
|
| 35 | + * |
|
| 36 | + * @since 1.0.19 |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + public $state = null; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * The invoice associated with the submission. |
|
| 43 | + * |
|
| 44 | + * @var WPInv_Invoice |
|
| 45 | + */ |
|
| 46 | + protected $invoice = null; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * The discount associated with the submission. |
|
| 50 | + * |
|
| 51 | + * @var WPInv_Discount |
|
| 52 | + */ |
|
| 53 | + protected $discount = null; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * The raw submission data. |
|
| 57 | + * |
|
| 58 | + * @var array |
|
| 59 | + */ |
|
| 60 | + protected $data = null; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Whether this submission contains a recurring item. |
|
| 64 | + * |
|
| 65 | + * @var bool |
|
| 66 | + */ |
|
| 67 | + public $has_recurring = false; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The sub total amount for the submission. |
|
| 71 | + * |
|
| 72 | + * @var float |
|
| 73 | + */ |
|
| 74 | + public $subtotal_amount = 0; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * The total discount amount for the submission. |
|
| 78 | + * |
|
| 79 | + * @var float |
|
| 80 | + */ |
|
| 81 | + protected $total_discount_amount = 0; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * The total tax amount for the submission. |
|
| 85 | + * |
|
| 86 | + * @var float |
|
| 87 | + */ |
|
| 88 | + protected $total_tax_amount = 0; |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * The total fees amount for the submission. |
|
| 92 | + * |
|
| 93 | + * @var float |
|
| 94 | + */ |
|
| 95 | + protected $total_fees_amount = 0; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * An array of fees for the submission. |
|
| 99 | + * |
|
| 100 | + * @var array |
|
| 101 | + */ |
|
| 102 | + protected $fees = array(); |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * An array of discounts for the submission. |
|
| 106 | + * |
|
| 107 | + * @var array |
|
| 108 | + */ |
|
| 109 | + protected $discounts = array(); |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * An array of taxes for the submission. |
|
| 113 | + * |
|
| 114 | + * @var array |
|
| 115 | + */ |
|
| 116 | + protected $taxes = array(); |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * An array of items for the submission. |
|
| 120 | + * |
|
| 121 | + * @var GetPaid_Form_Item[] |
|
| 122 | + */ |
|
| 123 | + protected $items = array(); |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * The last error. |
|
| 127 | + * |
|
| 128 | + * @var string |
|
| 129 | + */ |
|
| 130 | + public $last_error = null; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Is the discount valid? |
|
| 134 | + * |
|
| 135 | + * @var bool |
|
| 136 | + */ |
|
| 137 | + public $is_discount_valid = true; |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Checks if we have a digital vat rule. |
|
| 141 | - * |
|
| 142 | - * @var bool |
|
| 143 | - */ |
|
| 144 | - public $has_digital = false; |
|
| 139 | + /** |
|
| 140 | + * Checks if we have a digital vat rule. |
|
| 141 | + * |
|
| 142 | + * @var bool |
|
| 143 | + */ |
|
| 144 | + public $has_digital = false; |
|
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Checks if we require vat. |
|
| 148 | - * |
|
| 149 | - * @var bool |
|
| 150 | - */ |
|
| 146 | + /** |
|
| 147 | + * Checks if we require vat. |
|
| 148 | + * |
|
| 149 | + * @var bool |
|
| 150 | + */ |
|
| 151 | 151 | public $requires_vat = false; |
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | - * Class constructor. |
|
| 155 | - * |
|
| 156 | - */ |
|
| 157 | - public function __construct() { |
|
| 158 | - |
|
| 159 | - // Set the state and country to the default state and country. |
|
| 160 | - $this->country = wpinv_default_billing_country(); |
|
| 161 | - $this->state = wpinv_get_default_state(); |
|
| 162 | - |
|
| 163 | - // Do we have an actual submission? |
|
| 164 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 165 | - $this->load_data( $_POST ); |
|
| 166 | - } |
|
| 167 | - } |
|
| 154 | + * Class constructor. |
|
| 155 | + * |
|
| 156 | + */ |
|
| 157 | + public function __construct() { |
|
| 158 | + |
|
| 159 | + // Set the state and country to the default state and country. |
|
| 160 | + $this->country = wpinv_default_billing_country(); |
|
| 161 | + $this->state = wpinv_get_default_state(); |
|
| 162 | + |
|
| 163 | + // Do we have an actual submission? |
|
| 164 | + if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 165 | + $this->load_data( $_POST ); |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Loads submission data. |
|
| 171 | - * |
|
| 172 | - * @param array $data |
|
| 173 | - */ |
|
| 174 | - public function load_data( $data ) { |
|
| 169 | + /** |
|
| 170 | + * Loads submission data. |
|
| 171 | + * |
|
| 172 | + * @param array $data |
|
| 173 | + */ |
|
| 174 | + public function load_data( $data ) { |
|
| 175 | 175 | |
| 176 | - // Prepare submitted data... |
|
| 177 | - $data = wp_unslash( $data ); |
|
| 176 | + // Prepare submitted data... |
|
| 177 | + $data = wp_unslash( $data ); |
|
| 178 | 178 | |
| 179 | - // Filter the data. |
|
| 180 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
| 179 | + // Filter the data. |
|
| 180 | + $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
| 181 | 181 | |
| 182 | - $this->data = $data; |
|
| 182 | + $this->data = $data; |
|
| 183 | 183 | |
| 184 | - $this->id = md5( wp_json_encode( $data ) ); |
|
| 184 | + $this->id = md5( wp_json_encode( $data ) ); |
|
| 185 | 185 | |
| 186 | - // Every submission needs an active payment form. |
|
| 187 | - if ( empty( $data['form_id'] ) ) { |
|
| 188 | - $this->last_error = __( 'Missing payment form', 'invoicing' ); |
|
| 186 | + // Every submission needs an active payment form. |
|
| 187 | + if ( empty( $data['form_id'] ) ) { |
|
| 188 | + $this->last_error = __( 'Missing payment form', 'invoicing' ); |
|
| 189 | 189 | return; |
| 190 | - } |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - // Fetch the payment form. |
|
| 193 | - $form = new GetPaid_Payment_Form( $data['form_id'] ); |
|
| 192 | + // Fetch the payment form. |
|
| 193 | + $form = new GetPaid_Payment_Form( $data['form_id'] ); |
|
| 194 | 194 | |
| 195 | - if ( ! $form->is_active() ) { |
|
| 196 | - $this->last_error = __( 'Payment form not active', 'invoicing' ); |
|
| 197 | - return; |
|
| 198 | - } |
|
| 195 | + if ( ! $form->is_active() ) { |
|
| 196 | + $this->last_error = __( 'Payment form not active', 'invoicing' ); |
|
| 197 | + return; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - // Fetch the payment form. |
|
| 201 | - $this->payment_form = $form; |
|
| 200 | + // Fetch the payment form. |
|
| 201 | + $this->payment_form = $form; |
|
| 202 | 202 | |
| 203 | - // For existing invoices, make sure that it is valid. |
|
| 203 | + // For existing invoices, make sure that it is valid. |
|
| 204 | 204 | if ( ! empty( $data['invoice_id'] ) ) { |
| 205 | 205 | $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
| 206 | 206 | |
| 207 | 207 | if ( empty( $invoice ) ) { |
| 208 | - $this->last_error = __( 'Invalid invoice', 'invoicing' ); |
|
| 208 | + $this->last_error = __( 'Invalid invoice', 'invoicing' ); |
|
| 209 | 209 | return; |
| 210 | - } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - if ( $invoice->is_paid() ) { |
|
| 213 | - $this->last_error = __( 'This invoice is already paid for.', 'invoicing' ); |
|
| 212 | + if ( $invoice->is_paid() ) { |
|
| 213 | + $this->last_error = __( 'This invoice is already paid for.', 'invoicing' ); |
|
| 214 | 214 | return; |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
| 217 | + $this->payment_form->set_items( $invoice->get_items() ); |
|
| 218 | 218 | |
| 219 | - $this->country = $invoice->get_country(); |
|
| 220 | - $this->state = $invoice->get_state(); |
|
| 221 | - $this->invoice = $invoice; |
|
| 219 | + $this->country = $invoice->get_country(); |
|
| 220 | + $this->state = $invoice->get_state(); |
|
| 221 | + $this->invoice = $invoice; |
|
| 222 | 222 | |
| 223 | - // Default forms do not have items. |
|
| 223 | + // Default forms do not have items. |
|
| 224 | 224 | } else if ( $form->is_default() && isset( $data['form_items'] ) ) { |
| 225 | - $this->payment_form->set_items( $data['form_items'] ); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // User's country. |
|
| 229 | - if ( ! empty( $data['wpinv_country'] ) ) { |
|
| 230 | - $this->country = $data['wpinv_country']; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // User's state. |
|
| 234 | - if ( ! empty( $data['wpinv_state'] ) ) { |
|
| 235 | - $this->country = $data['wpinv_state']; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - // Handle discounts. |
|
| 239 | - $this->maybe_prepare_discount(); |
|
| 240 | - |
|
| 241 | - // Handle items. |
|
| 242 | - $selected_items = array(); |
|
| 243 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
| 244 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - foreach ( $this->payment_form->get_items() as $item ) { |
|
| 248 | - |
|
| 249 | - // Continue if this is an optional item and it has not been selected. |
|
| 250 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
| 251 | - continue; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - // (maybe) let customers change the quantities and prices. |
|
| 255 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
| 256 | - |
|
| 257 | - // Maybe change the quantities. |
|
| 258 | - if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) { |
|
| 259 | - $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - // Maybe change the price. |
|
| 263 | - if ( $item->user_can_set_their_price() ) { |
|
| 264 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
| 265 | - |
|
| 266 | - // But don't get lower than the minimum price. |
|
| 267 | - if ( $price < $item->get_minimum_price() ) { |
|
| 268 | - $price = $item->get_minimum_price(); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - $item->set_price( $price ); |
|
| 272 | - |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - // Add the item to the form. |
|
| 278 | - $this->add_item( $item ); |
|
| 279 | - |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - // (Maybe) validate vat number. |
|
| 283 | - $this->maybe_validate_vat(); |
|
| 284 | - |
|
| 285 | - // Fired when we are done processing a submission. |
|
| 286 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
| 287 | - |
|
| 288 | - // Remove invalid discount. |
|
| 289 | - $this->maybe_remove_discount(); |
|
| 290 | - |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Returns the payment form. |
|
| 295 | - * |
|
| 296 | - * @since 1.0.19 |
|
| 297 | - * @return GetPaid_Payment_Form |
|
| 298 | - */ |
|
| 299 | - public function get_payment_form() { |
|
| 300 | - return $this->payment_form; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Returns the associated invoice. |
|
| 305 | - * |
|
| 306 | - * @since 1.0.19 |
|
| 307 | - * @return WPInv_Invoice |
|
| 308 | - */ |
|
| 309 | - public function get_invoice() { |
|
| 310 | - return $this->invoice; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * Checks whether there is an invoice associated with this submission. |
|
| 315 | - * |
|
| 316 | - * @since 1.0.19 |
|
| 317 | - * @return bool |
|
| 318 | - */ |
|
| 319 | - public function has_invoice() { |
|
| 320 | - return ! empty( $this->invoice ); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * Retrieves the vat number. |
|
| 325 | - * |
|
| 326 | - * @since 1.0.19 |
|
| 327 | - * @return string |
|
| 328 | - */ |
|
| 329 | - public function get_vat_number() { |
|
| 330 | - |
|
| 331 | - // Retrieve from the posted data. |
|
| 332 | - if ( ! empty( $this->data['wpinv_vat_number'] ) ) { |
|
| 333 | - return wpinv_clean( $this->data['wpinv_vat_number'] ); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - // Retrieve from the invoice. |
|
| 337 | - return $this->has_invoice() ? $this->invoice->get_vat_number() : ''; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * Retrieves the company. |
|
| 342 | - * |
|
| 343 | - * @since 1.0.19 |
|
| 344 | - * @return string |
|
| 345 | - */ |
|
| 346 | - public function get_company() { |
|
| 347 | - |
|
| 348 | - // Retrieve from the posted data. |
|
| 349 | - if ( ! empty( $this->data['wpinv_company'] ) ) { |
|
| 350 | - return wpinv_clean( $this->data['wpinv_company'] ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - // Retrieve from the invoice. |
|
| 354 | - return $this->has_invoice() ? $this->invoice->get_company() : ''; |
|
| 355 | - } |
|
| 225 | + $this->payment_form->set_items( $data['form_items'] ); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // User's country. |
|
| 229 | + if ( ! empty( $data['wpinv_country'] ) ) { |
|
| 230 | + $this->country = $data['wpinv_country']; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // User's state. |
|
| 234 | + if ( ! empty( $data['wpinv_state'] ) ) { |
|
| 235 | + $this->country = $data['wpinv_state']; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + // Handle discounts. |
|
| 239 | + $this->maybe_prepare_discount(); |
|
| 240 | + |
|
| 241 | + // Handle items. |
|
| 242 | + $selected_items = array(); |
|
| 243 | + if ( ! empty( $data['getpaid-items'] ) ) { |
|
| 244 | + $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + foreach ( $this->payment_form->get_items() as $item ) { |
|
| 248 | + |
|
| 249 | + // Continue if this is an optional item and it has not been selected. |
|
| 250 | + if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
| 251 | + continue; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + // (maybe) let customers change the quantities and prices. |
|
| 255 | + if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
| 256 | + |
|
| 257 | + // Maybe change the quantities. |
|
| 258 | + if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) { |
|
| 259 | + $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + // Maybe change the price. |
|
| 263 | + if ( $item->user_can_set_their_price() ) { |
|
| 264 | + $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
| 265 | + |
|
| 266 | + // But don't get lower than the minimum price. |
|
| 267 | + if ( $price < $item->get_minimum_price() ) { |
|
| 268 | + $price = $item->get_minimum_price(); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + $item->set_price( $price ); |
|
| 272 | + |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + // Add the item to the form. |
|
| 278 | + $this->add_item( $item ); |
|
| 279 | + |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + // (Maybe) validate vat number. |
|
| 283 | + $this->maybe_validate_vat(); |
|
| 284 | + |
|
| 285 | + // Fired when we are done processing a submission. |
|
| 286 | + do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
| 287 | + |
|
| 288 | + // Remove invalid discount. |
|
| 289 | + $this->maybe_remove_discount(); |
|
| 290 | + |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Returns the payment form. |
|
| 295 | + * |
|
| 296 | + * @since 1.0.19 |
|
| 297 | + * @return GetPaid_Payment_Form |
|
| 298 | + */ |
|
| 299 | + public function get_payment_form() { |
|
| 300 | + return $this->payment_form; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Returns the associated invoice. |
|
| 305 | + * |
|
| 306 | + * @since 1.0.19 |
|
| 307 | + * @return WPInv_Invoice |
|
| 308 | + */ |
|
| 309 | + public function get_invoice() { |
|
| 310 | + return $this->invoice; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * Checks whether there is an invoice associated with this submission. |
|
| 315 | + * |
|
| 316 | + * @since 1.0.19 |
|
| 317 | + * @return bool |
|
| 318 | + */ |
|
| 319 | + public function has_invoice() { |
|
| 320 | + return ! empty( $this->invoice ); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * Retrieves the vat number. |
|
| 325 | + * |
|
| 326 | + * @since 1.0.19 |
|
| 327 | + * @return string |
|
| 328 | + */ |
|
| 329 | + public function get_vat_number() { |
|
| 330 | + |
|
| 331 | + // Retrieve from the posted data. |
|
| 332 | + if ( ! empty( $this->data['wpinv_vat_number'] ) ) { |
|
| 333 | + return wpinv_clean( $this->data['wpinv_vat_number'] ); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + // Retrieve from the invoice. |
|
| 337 | + return $this->has_invoice() ? $this->invoice->get_vat_number() : ''; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * Retrieves the company. |
|
| 342 | + * |
|
| 343 | + * @since 1.0.19 |
|
| 344 | + * @return string |
|
| 345 | + */ |
|
| 346 | + public function get_company() { |
|
| 347 | + |
|
| 348 | + // Retrieve from the posted data. |
|
| 349 | + if ( ! empty( $this->data['wpinv_company'] ) ) { |
|
| 350 | + return wpinv_clean( $this->data['wpinv_company'] ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // Retrieve from the invoice. |
|
| 354 | + return $this->has_invoice() ? $this->invoice->get_company() : ''; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * Returns the appropriate currency for the submission. |
|
| 359 | - * |
|
| 360 | - * @since 1.0.19 |
|
| 361 | - * @return string |
|
| 362 | - */ |
|
| 363 | - public function get_currency() { |
|
| 364 | - if ( $this->has_invoice() ) { |
|
| 365 | - return $this->invoice->get_currency(); |
|
| 366 | - } |
|
| 367 | - return wpinv_get_currency(); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * Returns the raw submission data. |
|
| 372 | - * |
|
| 373 | - * @since 1.0.19 |
|
| 374 | - * @return array |
|
| 375 | - */ |
|
| 376 | - public function get_data() { |
|
| 377 | - return $this->data; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Checks if a required field is set. |
|
| 382 | - * |
|
| 383 | - * @since 1.0.19 |
|
| 384 | - */ |
|
| 385 | - public function is_required_field_set( $field ) { |
|
| 386 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - ///////// Items ////////////// |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Adds an item to the submission. |
|
| 393 | - * |
|
| 394 | - * @since 1.0.19 |
|
| 395 | - * @param GetPaid_Form_Item $item |
|
| 396 | - */ |
|
| 397 | - public function add_item( $item ) { |
|
| 398 | - |
|
| 399 | - // Make sure that it is available for purchase. |
|
| 400 | - if ( ! $item->can_purchase() ) { |
|
| 401 | - return; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // Do we have a recurring item? |
|
| 405 | - if ( $item->is_recurring() ) { |
|
| 406 | - |
|
| 407 | - if ( $this->has_recurring ) { |
|
| 408 | - $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' ); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - $this->has_recurring = true; |
|
| 412 | - |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - $this->items[ $item->get_id() ] = $item; |
|
| 416 | - |
|
| 417 | - $this->subtotal_amount += $item->get_sub_total(); |
|
| 418 | - |
|
| 419 | - $this->process_item_discount( $item ); |
|
| 420 | - |
|
| 421 | - $this->process_item_tax( $item ); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * Retrieves a specific item. |
|
| 426 | - * |
|
| 427 | - * @since 1.0.19 |
|
| 428 | - */ |
|
| 429 | - public function get_item( $item_id ) { |
|
| 430 | - return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * Returns all items. |
|
| 435 | - * |
|
| 436 | - * @since 1.0.19 |
|
| 437 | - * @return GetPaid_Form_Item[] |
|
| 438 | - */ |
|
| 439 | - public function get_items() { |
|
| 440 | - return $this->items; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - ///////// TAXES ////////////// |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * Adds a tax to the submission. |
|
| 447 | - * |
|
| 448 | - * @since 1.0.19 |
|
| 449 | - */ |
|
| 450 | - public function add_tax( $name, $amount ) { |
|
| 451 | - $amount = (float) wpinv_sanitize_amount( $amount ); |
|
| 452 | - |
|
| 453 | - $this->total_tax_amount += $amount; |
|
| 454 | - |
|
| 455 | - if ( isset( $this->taxes[ $name ] ) ) { |
|
| 456 | - $this->taxes[ $name ] += $amount; |
|
| 457 | - } else { |
|
| 458 | - $this->taxes[ $name ] = $amount; |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * Whether or not we'll use taxes for the submission. |
|
| 465 | - * |
|
| 466 | - * @since 1.0.19 |
|
| 467 | - */ |
|
| 468 | - public function use_taxes() { |
|
| 469 | - |
|
| 470 | - $use_taxes = wpinv_use_taxes(); |
|
| 471 | - |
|
| 472 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
| 473 | - $use_taxes = false; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
| 477 | - |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - /** |
|
| 481 | - * Maybe process tax. |
|
| 482 | - * |
|
| 483 | - * @since 1.0.19 |
|
| 484 | - * @param GetPaid_Form_Item $item |
|
| 485 | - */ |
|
| 486 | - public function process_item_tax( $item ) { |
|
| 487 | - |
|
| 488 | - // Abort early if we're not using taxes. |
|
| 489 | - if ( ! $this->use_taxes() ) { |
|
| 490 | - return; |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - $rate = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() ); |
|
| 494 | - $price = $item->get_sub_total(); |
|
| 495 | - |
|
| 496 | - if ( wpinv_prices_include_tax() ) { |
|
| 497 | - $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
| 498 | - } else { |
|
| 499 | - $item_tax = $price * $rate * 0.01; |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - $this->add_tax( 'Tax', $item_tax ); |
|
| 503 | - |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * Returns the total tax amount. |
|
| 508 | - * |
|
| 509 | - * @since 1.0.19 |
|
| 510 | - */ |
|
| 511 | - public function get_total_tax() { |
|
| 512 | - return $this->total_tax_amount; |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - /** |
|
| 516 | - * Retrieves a specific tax. |
|
| 517 | - * |
|
| 518 | - * @since 1.0.19 |
|
| 519 | - */ |
|
| 520 | - public function get_tax( $name ) { |
|
| 521 | - return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - /** |
|
| 525 | - * Returns all taxes. |
|
| 526 | - * |
|
| 527 | - * @since 1.0.19 |
|
| 528 | - */ |
|
| 529 | - public function get_taxes() { |
|
| 530 | - return $this->taxes; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - ///////// DISCOUNTS ////////////// |
|
| 534 | - |
|
| 535 | - /** |
|
| 536 | - * Adds a discount to the submission. |
|
| 537 | - * |
|
| 538 | - * @since 1.0.19 |
|
| 539 | - */ |
|
| 540 | - public function add_discount( $name, $amount ) { |
|
| 541 | - $amount = wpinv_sanitize_amount( $amount ); |
|
| 542 | - |
|
| 543 | - $this->total_discount_amount += $amount; |
|
| 544 | - |
|
| 545 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
| 546 | - $this->discounts[ $name ] += $amount; |
|
| 547 | - } else { |
|
| 548 | - $this->discounts[ $name ] = $amount; |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - /** |
|
| 554 | - * Removes a discount from the submission. |
|
| 555 | - * |
|
| 556 | - * @since 1.0.19 |
|
| 557 | - */ |
|
| 558 | - public function remove_discount( $name ) { |
|
| 559 | - |
|
| 560 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
| 561 | - $this->total_discount_amount -= $this->discounts[ $name ]; |
|
| 562 | - unset( $this->discounts[ $name ] ); |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Checks whether there is a discount code associated with this submission. |
|
| 569 | - * |
|
| 570 | - * @since 1.0.19 |
|
| 571 | - * @return bool |
|
| 572 | - */ |
|
| 573 | - public function has_discount_code() { |
|
| 574 | - return ! empty( $this->discount ); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Returns the discount code. |
|
| 579 | - * |
|
| 580 | - * @since 1.0.19 |
|
| 581 | - * @return bool |
|
| 582 | - */ |
|
| 583 | - public function get_discount_code() { |
|
| 584 | - return $this->has_discount_code() ? $this->discount->code : ''; |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * Prepares an item discount. |
|
| 589 | - * |
|
| 590 | - * @since 1.0.19 |
|
| 591 | - */ |
|
| 592 | - public function maybe_prepare_discount() { |
|
| 593 | - |
|
| 594 | - // Do we have a discount? |
|
| 595 | - if ( empty( $this->data['discount'] ) ) { |
|
| 596 | - return; |
|
| 597 | - } |
|
| 598 | - |
|
| 599 | - // Fetch the discount. |
|
| 600 | - $discount = wpinv_get_discount_obj( $this->data['discount'] ); |
|
| 601 | - |
|
| 602 | - // Ensure it is active. |
|
| 603 | - if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) { |
|
| 604 | - $this->is_discount_valid = false; |
|
| 605 | - $this->last_error = __( 'Invalid or expired discount code', 'invoicing' ); |
|
| 606 | - return; |
|
| 607 | - } |
|
| 357 | + /** |
|
| 358 | + * Returns the appropriate currency for the submission. |
|
| 359 | + * |
|
| 360 | + * @since 1.0.19 |
|
| 361 | + * @return string |
|
| 362 | + */ |
|
| 363 | + public function get_currency() { |
|
| 364 | + if ( $this->has_invoice() ) { |
|
| 365 | + return $this->invoice->get_currency(); |
|
| 366 | + } |
|
| 367 | + return wpinv_get_currency(); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * Returns the raw submission data. |
|
| 372 | + * |
|
| 373 | + * @since 1.0.19 |
|
| 374 | + * @return array |
|
| 375 | + */ |
|
| 376 | + public function get_data() { |
|
| 377 | + return $this->data; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Checks if a required field is set. |
|
| 382 | + * |
|
| 383 | + * @since 1.0.19 |
|
| 384 | + */ |
|
| 385 | + public function is_required_field_set( $field ) { |
|
| 386 | + return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + ///////// Items ////////////// |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Adds an item to the submission. |
|
| 393 | + * |
|
| 394 | + * @since 1.0.19 |
|
| 395 | + * @param GetPaid_Form_Item $item |
|
| 396 | + */ |
|
| 397 | + public function add_item( $item ) { |
|
| 398 | + |
|
| 399 | + // Make sure that it is available for purchase. |
|
| 400 | + if ( ! $item->can_purchase() ) { |
|
| 401 | + return; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + // Do we have a recurring item? |
|
| 405 | + if ( $item->is_recurring() ) { |
|
| 406 | + |
|
| 407 | + if ( $this->has_recurring ) { |
|
| 408 | + $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' ); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + $this->has_recurring = true; |
|
| 412 | + |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + $this->items[ $item->get_id() ] = $item; |
|
| 416 | + |
|
| 417 | + $this->subtotal_amount += $item->get_sub_total(); |
|
| 418 | + |
|
| 419 | + $this->process_item_discount( $item ); |
|
| 420 | + |
|
| 421 | + $this->process_item_tax( $item ); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * Retrieves a specific item. |
|
| 426 | + * |
|
| 427 | + * @since 1.0.19 |
|
| 428 | + */ |
|
| 429 | + public function get_item( $item_id ) { |
|
| 430 | + return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * Returns all items. |
|
| 435 | + * |
|
| 436 | + * @since 1.0.19 |
|
| 437 | + * @return GetPaid_Form_Item[] |
|
| 438 | + */ |
|
| 439 | + public function get_items() { |
|
| 440 | + return $this->items; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + ///////// TAXES ////////////// |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * Adds a tax to the submission. |
|
| 447 | + * |
|
| 448 | + * @since 1.0.19 |
|
| 449 | + */ |
|
| 450 | + public function add_tax( $name, $amount ) { |
|
| 451 | + $amount = (float) wpinv_sanitize_amount( $amount ); |
|
| 452 | + |
|
| 453 | + $this->total_tax_amount += $amount; |
|
| 454 | + |
|
| 455 | + if ( isset( $this->taxes[ $name ] ) ) { |
|
| 456 | + $this->taxes[ $name ] += $amount; |
|
| 457 | + } else { |
|
| 458 | + $this->taxes[ $name ] = $amount; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * Whether or not we'll use taxes for the submission. |
|
| 465 | + * |
|
| 466 | + * @since 1.0.19 |
|
| 467 | + */ |
|
| 468 | + public function use_taxes() { |
|
| 608 | 469 | |
| 609 | - // For single use discounts... |
|
| 610 | - if ( $discount->is_single_use ) { |
|
| 470 | + $use_taxes = wpinv_use_taxes(); |
|
| 611 | 471 | |
| 612 | - if ( ! $this->has_billing_email() ) { |
|
| 613 | - $this->is_discount_valid = false; |
|
| 614 | - $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' ); |
|
| 615 | - return; |
|
| 616 | - } |
|
| 472 | + if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
| 473 | + $use_taxes = false; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
| 477 | + |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * Maybe process tax. |
|
| 482 | + * |
|
| 483 | + * @since 1.0.19 |
|
| 484 | + * @param GetPaid_Form_Item $item |
|
| 485 | + */ |
|
| 486 | + public function process_item_tax( $item ) { |
|
| 487 | + |
|
| 488 | + // Abort early if we're not using taxes. |
|
| 489 | + if ( ! $this->use_taxes() ) { |
|
| 490 | + return; |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + $rate = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() ); |
|
| 494 | + $price = $item->get_sub_total(); |
|
| 495 | + |
|
| 496 | + if ( wpinv_prices_include_tax() ) { |
|
| 497 | + $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
| 498 | + } else { |
|
| 499 | + $item_tax = $price * $rate * 0.01; |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + $this->add_tax( 'Tax', $item_tax ); |
|
| 503 | + |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * Returns the total tax amount. |
|
| 508 | + * |
|
| 509 | + * @since 1.0.19 |
|
| 510 | + */ |
|
| 511 | + public function get_total_tax() { |
|
| 512 | + return $this->total_tax_amount; |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + /** |
|
| 516 | + * Retrieves a specific tax. |
|
| 517 | + * |
|
| 518 | + * @since 1.0.19 |
|
| 519 | + */ |
|
| 520 | + public function get_tax( $name ) { |
|
| 521 | + return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + /** |
|
| 525 | + * Returns all taxes. |
|
| 526 | + * |
|
| 527 | + * @since 1.0.19 |
|
| 528 | + */ |
|
| 529 | + public function get_taxes() { |
|
| 530 | + return $this->taxes; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + ///////// DISCOUNTS ////////////// |
|
| 534 | + |
|
| 535 | + /** |
|
| 536 | + * Adds a discount to the submission. |
|
| 537 | + * |
|
| 538 | + * @since 1.0.19 |
|
| 539 | + */ |
|
| 540 | + public function add_discount( $name, $amount ) { |
|
| 541 | + $amount = wpinv_sanitize_amount( $amount ); |
|
| 542 | + |
|
| 543 | + $this->total_discount_amount += $amount; |
|
| 544 | + |
|
| 545 | + if ( isset( $this->discounts[ $name ] ) ) { |
|
| 546 | + $this->discounts[ $name ] += $amount; |
|
| 547 | + } else { |
|
| 548 | + $this->discounts[ $name ] = $amount; |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + /** |
|
| 554 | + * Removes a discount from the submission. |
|
| 555 | + * |
|
| 556 | + * @since 1.0.19 |
|
| 557 | + */ |
|
| 558 | + public function remove_discount( $name ) { |
|
| 559 | + |
|
| 560 | + if ( isset( $this->discounts[ $name ] ) ) { |
|
| 561 | + $this->total_discount_amount -= $this->discounts[ $name ]; |
|
| 562 | + unset( $this->discounts[ $name ] ); |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + } |
|
| 617 | 566 | |
| 618 | - if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) { |
|
| 619 | - $this->is_discount_valid = false; |
|
| 620 | - $this->last_error = __( 'You have already used this discount', 'invoicing' ); |
|
| 621 | - return; |
|
| 622 | - } |
|
| 567 | + /** |
|
| 568 | + * Checks whether there is a discount code associated with this submission. |
|
| 569 | + * |
|
| 570 | + * @since 1.0.19 |
|
| 571 | + * @return bool |
|
| 572 | + */ |
|
| 573 | + public function has_discount_code() { |
|
| 574 | + return ! empty( $this->discount ); |
|
| 575 | + } |
|
| 623 | 576 | |
| 624 | - } |
|
| 577 | + /** |
|
| 578 | + * Returns the discount code. |
|
| 579 | + * |
|
| 580 | + * @since 1.0.19 |
|
| 581 | + * @return bool |
|
| 582 | + */ |
|
| 583 | + public function get_discount_code() { |
|
| 584 | + return $this->has_discount_code() ? $this->discount->code : ''; |
|
| 585 | + } |
|
| 625 | 586 | |
| 626 | - // Set the discount. |
|
| 627 | - $this->discount = $discount; |
|
| 587 | + /** |
|
| 588 | + * Prepares an item discount. |
|
| 589 | + * |
|
| 590 | + * @since 1.0.19 |
|
| 591 | + */ |
|
| 592 | + public function maybe_prepare_discount() { |
|
| 593 | + |
|
| 594 | + // Do we have a discount? |
|
| 595 | + if ( empty( $this->data['discount'] ) ) { |
|
| 596 | + return; |
|
| 597 | + } |
|
| 628 | 598 | |
| 629 | - } |
|
| 599 | + // Fetch the discount. |
|
| 600 | + $discount = wpinv_get_discount_obj( $this->data['discount'] ); |
|
| 630 | 601 | |
| 631 | - /** |
|
| 632 | - * Removes an invalid discount code. |
|
| 633 | - * |
|
| 634 | - * @since 1.0.19 |
|
| 635 | - */ |
|
| 636 | - public function maybe_remove_discount() { |
|
| 602 | + // Ensure it is active. |
|
| 603 | + if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) { |
|
| 604 | + $this->is_discount_valid = false; |
|
| 605 | + $this->last_error = __( 'Invalid or expired discount code', 'invoicing' ); |
|
| 606 | + return; |
|
| 607 | + } |
|
| 637 | 608 | |
| 638 | - // Do we have a discount? |
|
| 639 | - if ( empty( $this->has_discount_code() ) ) { |
|
| 640 | - return; |
|
| 641 | - } |
|
| 609 | + // For single use discounts... |
|
| 610 | + if ( $discount->is_single_use ) { |
|
| 642 | 611 | |
| 643 | - // Fetch the discount amount. |
|
| 644 | - $amount = $this->get_discount( 'Discount' ); |
|
| 612 | + if ( ! $this->has_billing_email() ) { |
|
| 613 | + $this->is_discount_valid = false; |
|
| 614 | + $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' ); |
|
| 615 | + return; |
|
| 616 | + } |
|
| 645 | 617 | |
| 646 | - // Abort early if this is a "zero" discount. |
|
| 647 | - if ( empty( $amount ) ) { |
|
| 648 | - return; |
|
| 649 | - } |
|
| 618 | + if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) { |
|
| 619 | + $this->is_discount_valid = false; |
|
| 620 | + $this->last_error = __( 'You have already used this discount', 'invoicing' ); |
|
| 621 | + return; |
|
| 622 | + } |
|
| 650 | 623 | |
| 651 | - $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax(); |
|
| 624 | + } |
|
| 652 | 625 | |
| 653 | - if ( ! $this->discount->is_minimum_amount_met( $total ) ) { |
|
| 654 | - $this->is_discount_valid = false; |
|
| 626 | + // Set the discount. |
|
| 627 | + $this->discount = $discount; |
|
| 628 | + |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + /** |
|
| 632 | + * Removes an invalid discount code. |
|
| 633 | + * |
|
| 634 | + * @since 1.0.19 |
|
| 635 | + */ |
|
| 636 | + public function maybe_remove_discount() { |
|
| 637 | + |
|
| 638 | + // Do we have a discount? |
|
| 639 | + if ( empty( $this->has_discount_code() ) ) { |
|
| 640 | + return; |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + // Fetch the discount amount. |
|
| 644 | + $amount = $this->get_discount( 'Discount' ); |
|
| 645 | + |
|
| 646 | + // Abort early if this is a "zero" discount. |
|
| 647 | + if ( empty( $amount ) ) { |
|
| 648 | + return; |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax(); |
|
| 652 | + |
|
| 653 | + if ( ! $this->discount->is_minimum_amount_met( $total ) ) { |
|
| 654 | + $this->is_discount_valid = false; |
|
| 655 | 655 | $min = wpinv_price( wpinv_format_amount( $$this->discount->min_total ) ); |
| 656 | - $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ); |
|
| 656 | + $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | if ( ! $this->discount->is_maximum_amount_met( $total ) ) { |
| 660 | - $this->is_discount_valid = false; |
|
| 660 | + $this->is_discount_valid = false; |
|
| 661 | 661 | $max = wpinv_price( wpinv_format_amount( $$this->discount->max_total ) ); |
| 662 | - $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ); |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - if ( ! $this->is_discount_valid ) { |
|
| 666 | - $this->discount = null; |
|
| 667 | - $this->remove_discount( 'Discount' ); |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * Maybe process discount. |
|
| 674 | - * |
|
| 675 | - * @since 1.0.19 |
|
| 676 | - * @param GetPaid_Form_Item $item |
|
| 677 | - */ |
|
| 678 | - public function process_item_discount( $item ) { |
|
| 679 | - |
|
| 680 | - // Abort early if there is no discount. |
|
| 681 | - if ( ! $this->has_discount_code() ) { |
|
| 682 | - return; |
|
| 683 | - } |
|
| 684 | - |
|
| 685 | - // Ensure that it is valid for this item. |
|
| 686 | - if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
| 687 | - return; |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - // Fetch the discounted amount. |
|
| 691 | - $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() ); |
|
| 692 | - |
|
| 693 | - $this->add_discount( 'Discount', $discount ); |
|
| 694 | - |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - /** |
|
| 698 | - * Returns the total discount amount. |
|
| 699 | - * |
|
| 700 | - * @since 1.0.19 |
|
| 701 | - */ |
|
| 702 | - public function get_total_discount() { |
|
| 703 | - return $this->total_discount_amount; |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - /** |
|
| 707 | - * Gets a specific discount. |
|
| 708 | - * |
|
| 709 | - * @since 1.0.19 |
|
| 710 | - */ |
|
| 711 | - public function get_discount( $name ) { |
|
| 712 | - return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0; |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - /** |
|
| 716 | - * Returns all discounts. |
|
| 717 | - * |
|
| 718 | - * @since 1.0.19 |
|
| 719 | - */ |
|
| 720 | - public function get_discounts() { |
|
| 721 | - return $this->discounts; |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - ///////// FEES ////////////// |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * Adds a fee to the submission. |
|
| 728 | - * |
|
| 729 | - * @since 1.0.19 |
|
| 730 | - */ |
|
| 731 | - public function add_fee( $name, $amount ) { |
|
| 732 | - $amount = wpinv_sanitize_amount( $amount ); |
|
| 733 | - |
|
| 734 | - $this->total_fees_amount += $amount; |
|
| 735 | - |
|
| 736 | - if ( isset( $this->fees[ $name ] ) ) { |
|
| 737 | - $this->fees[ $name ] += $amount; |
|
| 738 | - } else { |
|
| 739 | - $this->fees[ $name ] = $amount; |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - /** |
|
| 745 | - * Returns the total fees amount. |
|
| 746 | - * |
|
| 747 | - * @since 1.0.19 |
|
| 748 | - */ |
|
| 749 | - public function get_total_fees() { |
|
| 750 | - return $this->total_fees_amount; |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - /** |
|
| 754 | - * Retrieves a specific fee. |
|
| 755 | - * |
|
| 756 | - * @since 1.0.19 |
|
| 757 | - */ |
|
| 758 | - public function get_fee( $name ) { |
|
| 759 | - return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0; |
|
| 760 | - } |
|
| 761 | - |
|
| 762 | - /** |
|
| 763 | - * Returns all fees. |
|
| 764 | - * |
|
| 765 | - * @since 1.0.19 |
|
| 766 | - */ |
|
| 767 | - public function get_fees() { |
|
| 768 | - return $this->fees; |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - // MISC // |
|
| 772 | - |
|
| 773 | - /** |
|
| 774 | - * Returns the total amount to collect for this submission. |
|
| 775 | - * |
|
| 776 | - * @since 1.0.19 |
|
| 777 | - */ |
|
| 778 | - public function get_total() { |
|
| 779 | - $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
| 780 | - $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this ); |
|
| 781 | - return wpinv_sanitize_amount( $total ); |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - /** |
|
| 785 | - * Whether payment details should be collected for this submission. |
|
| 786 | - * |
|
| 787 | - * @since 1.0.19 |
|
| 788 | - */ |
|
| 789 | - public function get_payment_details() { |
|
| 790 | - $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
| 791 | - |
|
| 792 | - if ( $this->has_recurring ) { |
|
| 793 | - $collect = true; |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this ); |
|
| 797 | - return $collect; |
|
| 798 | - } |
|
| 799 | - |
|
| 800 | - /** |
|
| 801 | - * Returns the billing email of the user. |
|
| 802 | - * |
|
| 803 | - * @since 1.0.19 |
|
| 804 | - */ |
|
| 805 | - public function get_billing_email() { |
|
| 806 | - $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email']; |
|
| 807 | - return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this ); |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - /** |
|
| 811 | - * Checks if the submitter has a billing email. |
|
| 812 | - * |
|
| 813 | - * @since 1.0.19 |
|
| 814 | - */ |
|
| 815 | - public function has_billing_email() { |
|
| 816 | - $billing_email = $this->get_billing_email(); |
|
| 817 | - return ! empty( $billing_email ); |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - /** |
|
| 821 | - * Validate VAT data. |
|
| 822 | - * |
|
| 823 | - * @since 1.0.19 |
|
| 824 | - */ |
|
| 825 | - public function maybe_validate_vat() { |
|
| 662 | + $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ); |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + if ( ! $this->is_discount_valid ) { |
|
| 666 | + $this->discount = null; |
|
| 667 | + $this->remove_discount( 'Discount' ); |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * Maybe process discount. |
|
| 674 | + * |
|
| 675 | + * @since 1.0.19 |
|
| 676 | + * @param GetPaid_Form_Item $item |
|
| 677 | + */ |
|
| 678 | + public function process_item_discount( $item ) { |
|
| 679 | + |
|
| 680 | + // Abort early if there is no discount. |
|
| 681 | + if ( ! $this->has_discount_code() ) { |
|
| 682 | + return; |
|
| 683 | + } |
|
| 684 | + |
|
| 685 | + // Ensure that it is valid for this item. |
|
| 686 | + if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
| 687 | + return; |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + // Fetch the discounted amount. |
|
| 691 | + $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() ); |
|
| 692 | + |
|
| 693 | + $this->add_discount( 'Discount', $discount ); |
|
| 694 | + |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + /** |
|
| 698 | + * Returns the total discount amount. |
|
| 699 | + * |
|
| 700 | + * @since 1.0.19 |
|
| 701 | + */ |
|
| 702 | + public function get_total_discount() { |
|
| 703 | + return $this->total_discount_amount; |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + /** |
|
| 707 | + * Gets a specific discount. |
|
| 708 | + * |
|
| 709 | + * @since 1.0.19 |
|
| 710 | + */ |
|
| 711 | + public function get_discount( $name ) { |
|
| 712 | + return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0; |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + /** |
|
| 716 | + * Returns all discounts. |
|
| 717 | + * |
|
| 718 | + * @since 1.0.19 |
|
| 719 | + */ |
|
| 720 | + public function get_discounts() { |
|
| 721 | + return $this->discounts; |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + ///////// FEES ////////////// |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * Adds a fee to the submission. |
|
| 728 | + * |
|
| 729 | + * @since 1.0.19 |
|
| 730 | + */ |
|
| 731 | + public function add_fee( $name, $amount ) { |
|
| 732 | + $amount = wpinv_sanitize_amount( $amount ); |
|
| 733 | + |
|
| 734 | + $this->total_fees_amount += $amount; |
|
| 735 | + |
|
| 736 | + if ( isset( $this->fees[ $name ] ) ) { |
|
| 737 | + $this->fees[ $name ] += $amount; |
|
| 738 | + } else { |
|
| 739 | + $this->fees[ $name ] = $amount; |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + /** |
|
| 745 | + * Returns the total fees amount. |
|
| 746 | + * |
|
| 747 | + * @since 1.0.19 |
|
| 748 | + */ |
|
| 749 | + public function get_total_fees() { |
|
| 750 | + return $this->total_fees_amount; |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + /** |
|
| 754 | + * Retrieves a specific fee. |
|
| 755 | + * |
|
| 756 | + * @since 1.0.19 |
|
| 757 | + */ |
|
| 758 | + public function get_fee( $name ) { |
|
| 759 | + return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0; |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + /** |
|
| 763 | + * Returns all fees. |
|
| 764 | + * |
|
| 765 | + * @since 1.0.19 |
|
| 766 | + */ |
|
| 767 | + public function get_fees() { |
|
| 768 | + return $this->fees; |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + // MISC // |
|
| 772 | + |
|
| 773 | + /** |
|
| 774 | + * Returns the total amount to collect for this submission. |
|
| 775 | + * |
|
| 776 | + * @since 1.0.19 |
|
| 777 | + */ |
|
| 778 | + public function get_total() { |
|
| 779 | + $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
| 780 | + $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this ); |
|
| 781 | + return wpinv_sanitize_amount( $total ); |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + /** |
|
| 785 | + * Whether payment details should be collected for this submission. |
|
| 786 | + * |
|
| 787 | + * @since 1.0.19 |
|
| 788 | + */ |
|
| 789 | + public function get_payment_details() { |
|
| 790 | + $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
| 791 | + |
|
| 792 | + if ( $this->has_recurring ) { |
|
| 793 | + $collect = true; |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this ); |
|
| 797 | + return $collect; |
|
| 798 | + } |
|
| 799 | + |
|
| 800 | + /** |
|
| 801 | + * Returns the billing email of the user. |
|
| 802 | + * |
|
| 803 | + * @since 1.0.19 |
|
| 804 | + */ |
|
| 805 | + public function get_billing_email() { |
|
| 806 | + $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email']; |
|
| 807 | + return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this ); |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + /** |
|
| 811 | + * Checks if the submitter has a billing email. |
|
| 812 | + * |
|
| 813 | + * @since 1.0.19 |
|
| 814 | + */ |
|
| 815 | + public function has_billing_email() { |
|
| 816 | + $billing_email = $this->get_billing_email(); |
|
| 817 | + return ! empty( $billing_email ); |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + /** |
|
| 821 | + * Validate VAT data. |
|
| 822 | + * |
|
| 823 | + * @since 1.0.19 |
|
| 824 | + */ |
|
| 825 | + public function maybe_validate_vat() { |
|
| 826 | 826 | |
| 827 | - // Make sure that taxes are enabled. |
|
| 828 | - if ( ! wpinv_use_taxes() ) { |
|
| 829 | - return; |
|
| 830 | - } |
|
| 827 | + // Make sure that taxes are enabled. |
|
| 828 | + if ( ! wpinv_use_taxes() ) { |
|
| 829 | + return; |
|
| 830 | + } |
|
| 831 | 831 | |
| 832 | - // Check if we have a digital VAT rule. |
|
| 833 | - $has_digital = false; |
|
| 832 | + // Check if we have a digital VAT rule. |
|
| 833 | + $has_digital = false; |
|
| 834 | 834 | |
| 835 | - foreach ( $this->get_items() as $item ) { |
|
| 835 | + foreach ( $this->get_items() as $item ) { |
|
| 836 | 836 | |
| 837 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
| 838 | - $has_digital = true; |
|
| 839 | - break; |
|
| 840 | - } |
|
| 837 | + if ( 'digital' == $item->get_vat_rule() ) { |
|
| 838 | + $has_digital = true; |
|
| 839 | + break; |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - } |
|
| 842 | + } |
|
| 843 | 843 | |
| 844 | - $this->has_digital = $has_digital; |
|
| 844 | + $this->has_digital = $has_digital; |
|
| 845 | 845 | |
| 846 | - // Check if we require vat. |
|
| 847 | - $requires_vat = ( |
|
| 848 | - ( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) |
|
| 849 | - || ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) |
|
| 850 | - ); |
|
| 846 | + // Check if we require vat. |
|
| 847 | + $requires_vat = ( |
|
| 848 | + ( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) |
|
| 849 | + || ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) |
|
| 850 | + ); |
|
| 851 | 851 | |
| 852 | - $this->requires_vat = $requires_vat; |
|
| 852 | + $this->requires_vat = $requires_vat; |
|
| 853 | 853 | |
| 854 | - // Abort if we are not calculating the taxes. |
|
| 855 | - if ( ! $has_digital && ! $requires_vat ) { |
|
| 854 | + // Abort if we are not calculating the taxes. |
|
| 855 | + if ( ! $has_digital && ! $requires_vat ) { |
|
| 856 | 856 | return; |
| 857 | - } |
|
| 857 | + } |
|
| 858 | 858 | |
| 859 | - // Prepare variables. |
|
| 860 | - $vat_number = $this->get_vat_number(); |
|
| 861 | - $company = $this->get_company(); |
|
| 862 | - $ip_country = WPInv_EUVat::get_country_by_ip(); |
|
| 859 | + // Prepare variables. |
|
| 860 | + $vat_number = $this->get_vat_number(); |
|
| 861 | + $company = $this->get_company(); |
|
| 862 | + $ip_country = WPInv_EUVat::get_country_by_ip(); |
|
| 863 | 863 | $is_eu = getpaid_is_eu_state( $this->country ); |
| 864 | 864 | $is_ip_eu = getpaid_is_eu_state( $ip_country ); |
| 865 | - $is_non_eu = ! $is_eu && ! $is_ip_eu; |
|
| 866 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 865 | + $is_non_eu = ! $is_eu && ! $is_ip_eu; |
|
| 866 | + $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 867 | 867 | |
| 868 | - // If we're preventing business to consumer purchases... |
|
| 869 | - if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) { |
|
| 868 | + // If we're preventing business to consumer purchases... |
|
| 869 | + if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) { |
|
| 870 | 870 | |
| 871 | 871 | if ( $is_eu ) { |
| 872 | - $this->last_error = wp_sprintf( |
|
| 873 | - __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
| 874 | - getpaid_vat_name() |
|
| 875 | - ); |
|
| 872 | + $this->last_error = wp_sprintf( |
|
| 873 | + __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
| 874 | + getpaid_vat_name() |
|
| 875 | + ); |
|
| 876 | 876 | } else if ( $has_digital && $is_ip_eu ) { |
| 877 | 877 | |
| 878 | - $this->last_error = wp_sprintf( |
|
| 879 | - __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), |
|
| 880 | - getpaid_vat_name() |
|
| 881 | - ); |
|
| 878 | + $this->last_error = wp_sprintf( |
|
| 879 | + __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), |
|
| 880 | + getpaid_vat_name() |
|
| 881 | + ); |
|
| 882 | 882 | |
| 883 | - } |
|
| 883 | + } |
|
| 884 | 884 | |
| 885 | - } |
|
| 885 | + } |
|
| 886 | 886 | |
| 887 | - // Abort if we are not validating vat. |
|
| 888 | - if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) { |
|
| 887 | + // Abort if we are not validating vat. |
|
| 888 | + if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) { |
|
| 889 | 889 | return; |
| 890 | - } |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | - $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country ); |
|
| 892 | + $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country ); |
|
| 893 | 893 | |
| 894 | - if ( is_string( $is_valid ) ) { |
|
| 895 | - $this->last_error = $is_valid; |
|
| 896 | - } |
|
| 894 | + if ( is_string( $is_valid ) ) { |
|
| 895 | + $this->last_error = $is_valid; |
|
| 896 | + } |
|
| 897 | 897 | |
| 898 | - } |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | 900 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | $this->state = wpinv_get_default_state(); |
| 162 | 162 | |
| 163 | 163 | // Do we have an actual submission? |
| 164 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 165 | - $this->load_data( $_POST ); |
|
| 164 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
| 165 | + $this->load_data($_POST); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
@@ -171,29 +171,29 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @param array $data |
| 173 | 173 | */ |
| 174 | - public function load_data( $data ) { |
|
| 174 | + public function load_data($data) { |
|
| 175 | 175 | |
| 176 | 176 | // Prepare submitted data... |
| 177 | - $data = wp_unslash( $data ); |
|
| 177 | + $data = wp_unslash($data); |
|
| 178 | 178 | |
| 179 | 179 | // Filter the data. |
| 180 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
| 180 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
| 181 | 181 | |
| 182 | 182 | $this->data = $data; |
| 183 | 183 | |
| 184 | - $this->id = md5( wp_json_encode( $data ) ); |
|
| 184 | + $this->id = md5(wp_json_encode($data)); |
|
| 185 | 185 | |
| 186 | 186 | // Every submission needs an active payment form. |
| 187 | - if ( empty( $data['form_id'] ) ) { |
|
| 188 | - $this->last_error = __( 'Missing payment form', 'invoicing' ); |
|
| 187 | + if (empty($data['form_id'])) { |
|
| 188 | + $this->last_error = __('Missing payment form', 'invoicing'); |
|
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Fetch the payment form. |
| 193 | - $form = new GetPaid_Payment_Form( $data['form_id'] ); |
|
| 193 | + $form = new GetPaid_Payment_Form($data['form_id']); |
|
| 194 | 194 | |
| 195 | - if ( ! $form->is_active() ) { |
|
| 196 | - $this->last_error = __( 'Payment form not active', 'invoicing' ); |
|
| 195 | + if (!$form->is_active()) { |
|
| 196 | + $this->last_error = __('Payment form not active', 'invoicing'); |
|
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -201,37 +201,37 @@ discard block |
||
| 201 | 201 | $this->payment_form = $form; |
| 202 | 202 | |
| 203 | 203 | // For existing invoices, make sure that it is valid. |
| 204 | - if ( ! empty( $data['invoice_id'] ) ) { |
|
| 205 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
| 204 | + if (!empty($data['invoice_id'])) { |
|
| 205 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
| 206 | 206 | |
| 207 | - if ( empty( $invoice ) ) { |
|
| 208 | - $this->last_error = __( 'Invalid invoice', 'invoicing' ); |
|
| 207 | + if (empty($invoice)) { |
|
| 208 | + $this->last_error = __('Invalid invoice', 'invoicing'); |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( $invoice->is_paid() ) { |
|
| 213 | - $this->last_error = __( 'This invoice is already paid for.', 'invoicing' ); |
|
| 212 | + if ($invoice->is_paid()) { |
|
| 213 | + $this->last_error = __('This invoice is already paid for.', 'invoicing'); |
|
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
| 217 | + $this->payment_form->set_items($invoice->get_items()); |
|
| 218 | 218 | |
| 219 | 219 | $this->country = $invoice->get_country(); |
| 220 | 220 | $this->state = $invoice->get_state(); |
| 221 | 221 | $this->invoice = $invoice; |
| 222 | 222 | |
| 223 | 223 | // Default forms do not have items. |
| 224 | - } else if ( $form->is_default() && isset( $data['form_items'] ) ) { |
|
| 225 | - $this->payment_form->set_items( $data['form_items'] ); |
|
| 224 | + } else if ($form->is_default() && isset($data['form_items'])) { |
|
| 225 | + $this->payment_form->set_items($data['form_items']); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // User's country. |
| 229 | - if ( ! empty( $data['wpinv_country'] ) ) { |
|
| 229 | + if (!empty($data['wpinv_country'])) { |
|
| 230 | 230 | $this->country = $data['wpinv_country']; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // User's state. |
| 234 | - if ( ! empty( $data['wpinv_state'] ) ) { |
|
| 234 | + if (!empty($data['wpinv_state'])) { |
|
| 235 | 235 | $this->country = $data['wpinv_state']; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -240,42 +240,42 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | // Handle items. |
| 242 | 242 | $selected_items = array(); |
| 243 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
| 244 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
| 243 | + if (!empty($data['getpaid-items'])) { |
|
| 244 | + $selected_items = wpinv_clean($data['getpaid-items']); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - foreach ( $this->payment_form->get_items() as $item ) { |
|
| 247 | + foreach ($this->payment_form->get_items() as $item) { |
|
| 248 | 248 | |
| 249 | 249 | // Continue if this is an optional item and it has not been selected. |
| 250 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
| 250 | + if (!$item->is_required() && !isset($selected_items[$item->get_id()])) { |
|
| 251 | 251 | continue; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // (maybe) let customers change the quantities and prices. |
| 255 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
| 255 | + if (isset($selected_items[$item->get_id()])) { |
|
| 256 | 256 | |
| 257 | 257 | // Maybe change the quantities. |
| 258 | - if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) { |
|
| 259 | - $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
| 258 | + if ($item->allows_quantities() && is_numeric($selected_items[$item->get_id()]['quantity'])) { |
|
| 259 | + $item->set_quantity((int) $selected_items[$item->get_id()]['quantity']); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // Maybe change the price. |
| 263 | - if ( $item->user_can_set_their_price() ) { |
|
| 264 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
| 263 | + if ($item->user_can_set_their_price()) { |
|
| 264 | + $price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']); |
|
| 265 | 265 | |
| 266 | 266 | // But don't get lower than the minimum price. |
| 267 | - if ( $price < $item->get_minimum_price() ) { |
|
| 267 | + if ($price < $item->get_minimum_price()) { |
|
| 268 | 268 | $price = $item->get_minimum_price(); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - $item->set_price( $price ); |
|
| 271 | + $item->set_price($price); |
|
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Add the item to the form. |
| 278 | - $this->add_item( $item ); |
|
| 278 | + $this->add_item($item); |
|
| 279 | 279 | |
| 280 | 280 | } |
| 281 | 281 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $this->maybe_validate_vat(); |
| 284 | 284 | |
| 285 | 285 | // Fired when we are done processing a submission. |
| 286 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
| 286 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
| 287 | 287 | |
| 288 | 288 | // Remove invalid discount. |
| 289 | 289 | $this->maybe_remove_discount(); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return bool |
| 318 | 318 | */ |
| 319 | 319 | public function has_invoice() { |
| 320 | - return ! empty( $this->invoice ); |
|
| 320 | + return !empty($this->invoice); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -329,8 +329,8 @@ discard block |
||
| 329 | 329 | public function get_vat_number() { |
| 330 | 330 | |
| 331 | 331 | // Retrieve from the posted data. |
| 332 | - if ( ! empty( $this->data['wpinv_vat_number'] ) ) { |
|
| 333 | - return wpinv_clean( $this->data['wpinv_vat_number'] ); |
|
| 332 | + if (!empty($this->data['wpinv_vat_number'])) { |
|
| 333 | + return wpinv_clean($this->data['wpinv_vat_number']); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Retrieve from the invoice. |
@@ -346,8 +346,8 @@ discard block |
||
| 346 | 346 | public function get_company() { |
| 347 | 347 | |
| 348 | 348 | // Retrieve from the posted data. |
| 349 | - if ( ! empty( $this->data['wpinv_company'] ) ) { |
|
| 350 | - return wpinv_clean( $this->data['wpinv_company'] ); |
|
| 349 | + if (!empty($this->data['wpinv_company'])) { |
|
| 350 | + return wpinv_clean($this->data['wpinv_company']); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // Retrieve from the invoice. |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | public function get_currency() { |
| 364 | - if ( $this->has_invoice() ) { |
|
| 364 | + if ($this->has_invoice()) { |
|
| 365 | 365 | return $this->invoice->get_currency(); |
| 366 | 366 | } |
| 367 | 367 | return wpinv_get_currency(); |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @since 1.0.19 |
| 384 | 384 | */ |
| 385 | - public function is_required_field_set( $field ) { |
|
| 386 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
| 385 | + public function is_required_field_set($field) { |
|
| 386 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | ///////// Items ////////////// |
@@ -394,31 +394,31 @@ discard block |
||
| 394 | 394 | * @since 1.0.19 |
| 395 | 395 | * @param GetPaid_Form_Item $item |
| 396 | 396 | */ |
| 397 | - public function add_item( $item ) { |
|
| 397 | + public function add_item($item) { |
|
| 398 | 398 | |
| 399 | 399 | // Make sure that it is available for purchase. |
| 400 | - if ( ! $item->can_purchase() ) { |
|
| 400 | + if (!$item->can_purchase()) { |
|
| 401 | 401 | return; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | // Do we have a recurring item? |
| 405 | - if ( $item->is_recurring() ) { |
|
| 405 | + if ($item->is_recurring()) { |
|
| 406 | 406 | |
| 407 | - if ( $this->has_recurring ) { |
|
| 408 | - $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' ); |
|
| 407 | + if ($this->has_recurring) { |
|
| 408 | + $this->last_error = __('You can only buy one recurring item at a time.', 'invoicing'); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $this->has_recurring = true; |
| 412 | 412 | |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $this->items[ $item->get_id() ] = $item; |
|
| 415 | + $this->items[$item->get_id()] = $item; |
|
| 416 | 416 | |
| 417 | 417 | $this->subtotal_amount += $item->get_sub_total(); |
| 418 | 418 | |
| 419 | - $this->process_item_discount( $item ); |
|
| 419 | + $this->process_item_discount($item); |
|
| 420 | 420 | |
| 421 | - $this->process_item_tax( $item ); |
|
| 421 | + $this->process_item_tax($item); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -426,8 +426,8 @@ discard block |
||
| 426 | 426 | * |
| 427 | 427 | * @since 1.0.19 |
| 428 | 428 | */ |
| 429 | - public function get_item( $item_id ) { |
|
| 430 | - return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null; |
|
| 429 | + public function get_item($item_id) { |
|
| 430 | + return isset($this->items[$item_id]) ? $this->items[$item_id] : null; |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -447,15 +447,15 @@ discard block |
||
| 447 | 447 | * |
| 448 | 448 | * @since 1.0.19 |
| 449 | 449 | */ |
| 450 | - public function add_tax( $name, $amount ) { |
|
| 451 | - $amount = (float) wpinv_sanitize_amount( $amount ); |
|
| 450 | + public function add_tax($name, $amount) { |
|
| 451 | + $amount = (float) wpinv_sanitize_amount($amount); |
|
| 452 | 452 | |
| 453 | 453 | $this->total_tax_amount += $amount; |
| 454 | 454 | |
| 455 | - if ( isset( $this->taxes[ $name ] ) ) { |
|
| 456 | - $this->taxes[ $name ] += $amount; |
|
| 455 | + if (isset($this->taxes[$name])) { |
|
| 456 | + $this->taxes[$name] += $amount; |
|
| 457 | 457 | } else { |
| 458 | - $this->taxes[ $name ] = $amount; |
|
| 458 | + $this->taxes[$name] = $amount; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | } |
@@ -469,11 +469,11 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | $use_taxes = wpinv_use_taxes(); |
| 471 | 471 | |
| 472 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
| 472 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
| 473 | 473 | $use_taxes = false; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
| 476 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
| 477 | 477 | |
| 478 | 478 | } |
| 479 | 479 | |
@@ -483,23 +483,23 @@ discard block |
||
| 483 | 483 | * @since 1.0.19 |
| 484 | 484 | * @param GetPaid_Form_Item $item |
| 485 | 485 | */ |
| 486 | - public function process_item_tax( $item ) { |
|
| 486 | + public function process_item_tax($item) { |
|
| 487 | 487 | |
| 488 | 488 | // Abort early if we're not using taxes. |
| 489 | - if ( ! $this->use_taxes() ) { |
|
| 489 | + if (!$this->use_taxes()) { |
|
| 490 | 490 | return; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - $rate = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() ); |
|
| 493 | + $rate = wpinv_get_tax_rate($this->country, $this->state, $item->get_id()); |
|
| 494 | 494 | $price = $item->get_sub_total(); |
| 495 | 495 | |
| 496 | - if ( wpinv_prices_include_tax() ) { |
|
| 497 | - $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
| 496 | + if (wpinv_prices_include_tax()) { |
|
| 497 | + $item_tax = $price - ($price - $price * $rate * 0.01); |
|
| 498 | 498 | } else { |
| 499 | 499 | $item_tax = $price * $rate * 0.01; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - $this->add_tax( 'Tax', $item_tax ); |
|
| 502 | + $this->add_tax('Tax', $item_tax); |
|
| 503 | 503 | |
| 504 | 504 | } |
| 505 | 505 | |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | * |
| 518 | 518 | * @since 1.0.19 |
| 519 | 519 | */ |
| 520 | - public function get_tax( $name ) { |
|
| 521 | - return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0; |
|
| 520 | + public function get_tax($name) { |
|
| 521 | + return isset($this->taxes[$name]) ? $this->taxes[$name] : 0; |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -537,15 +537,15 @@ discard block |
||
| 537 | 537 | * |
| 538 | 538 | * @since 1.0.19 |
| 539 | 539 | */ |
| 540 | - public function add_discount( $name, $amount ) { |
|
| 541 | - $amount = wpinv_sanitize_amount( $amount ); |
|
| 540 | + public function add_discount($name, $amount) { |
|
| 541 | + $amount = wpinv_sanitize_amount($amount); |
|
| 542 | 542 | |
| 543 | 543 | $this->total_discount_amount += $amount; |
| 544 | 544 | |
| 545 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
| 546 | - $this->discounts[ $name ] += $amount; |
|
| 545 | + if (isset($this->discounts[$name])) { |
|
| 546 | + $this->discounts[$name] += $amount; |
|
| 547 | 547 | } else { |
| 548 | - $this->discounts[ $name ] = $amount; |
|
| 548 | + $this->discounts[$name] = $amount; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | } |
@@ -555,11 +555,11 @@ discard block |
||
| 555 | 555 | * |
| 556 | 556 | * @since 1.0.19 |
| 557 | 557 | */ |
| 558 | - public function remove_discount( $name ) { |
|
| 558 | + public function remove_discount($name) { |
|
| 559 | 559 | |
| 560 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
| 561 | - $this->total_discount_amount -= $this->discounts[ $name ]; |
|
| 562 | - unset( $this->discounts[ $name ] ); |
|
| 560 | + if (isset($this->discounts[$name])) { |
|
| 561 | + $this->total_discount_amount -= $this->discounts[$name]; |
|
| 562 | + unset($this->discounts[$name]); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | * @return bool |
| 572 | 572 | */ |
| 573 | 573 | public function has_discount_code() { |
| 574 | - return ! empty( $this->discount ); |
|
| 574 | + return !empty($this->discount); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
@@ -592,32 +592,32 @@ discard block |
||
| 592 | 592 | public function maybe_prepare_discount() { |
| 593 | 593 | |
| 594 | 594 | // Do we have a discount? |
| 595 | - if ( empty( $this->data['discount'] ) ) { |
|
| 595 | + if (empty($this->data['discount'])) { |
|
| 596 | 596 | return; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | // Fetch the discount. |
| 600 | - $discount = wpinv_get_discount_obj( $this->data['discount'] ); |
|
| 600 | + $discount = wpinv_get_discount_obj($this->data['discount']); |
|
| 601 | 601 | |
| 602 | 602 | // Ensure it is active. |
| 603 | - if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) { |
|
| 603 | + if (!$discount->exists() || !$discount->is_active() || !$discount->has_started() || $discount->is_expired()) { |
|
| 604 | 604 | $this->is_discount_valid = false; |
| 605 | - $this->last_error = __( 'Invalid or expired discount code', 'invoicing' ); |
|
| 605 | + $this->last_error = __('Invalid or expired discount code', 'invoicing'); |
|
| 606 | 606 | return; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // For single use discounts... |
| 610 | - if ( $discount->is_single_use ) { |
|
| 610 | + if ($discount->is_single_use) { |
|
| 611 | 611 | |
| 612 | - if ( ! $this->has_billing_email() ) { |
|
| 612 | + if (!$this->has_billing_email()) { |
|
| 613 | 613 | $this->is_discount_valid = false; |
| 614 | - $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' ); |
|
| 614 | + $this->last_error = __('You need to enter your billing email before applying this discount', 'invoicing'); |
|
| 615 | 615 | return; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) { |
|
| 618 | + if (!$discount->is_valid_for_user($this->get_billing_email())) { |
|
| 619 | 619 | $this->is_discount_valid = false; |
| 620 | - $this->last_error = __( 'You have already used this discount', 'invoicing' ); |
|
| 620 | + $this->last_error = __('You have already used this discount', 'invoicing'); |
|
| 621 | 621 | return; |
| 622 | 622 | } |
| 623 | 623 | |
@@ -636,35 +636,35 @@ discard block |
||
| 636 | 636 | public function maybe_remove_discount() { |
| 637 | 637 | |
| 638 | 638 | // Do we have a discount? |
| 639 | - if ( empty( $this->has_discount_code() ) ) { |
|
| 639 | + if (empty($this->has_discount_code())) { |
|
| 640 | 640 | return; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | // Fetch the discount amount. |
| 644 | - $amount = $this->get_discount( 'Discount' ); |
|
| 644 | + $amount = $this->get_discount('Discount'); |
|
| 645 | 645 | |
| 646 | 646 | // Abort early if this is a "zero" discount. |
| 647 | - if ( empty( $amount ) ) { |
|
| 647 | + if (empty($amount)) { |
|
| 648 | 648 | return; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax(); |
| 652 | 652 | |
| 653 | - if ( ! $this->discount->is_minimum_amount_met( $total ) ) { |
|
| 653 | + if (!$this->discount->is_minimum_amount_met($total)) { |
|
| 654 | 654 | $this->is_discount_valid = false; |
| 655 | - $min = wpinv_price( wpinv_format_amount( $$this->discount->min_total ) ); |
|
| 656 | - $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ); |
|
| 655 | + $min = wpinv_price(wpinv_format_amount($$this->discount->min_total)); |
|
| 656 | + $this->last_error = sprintf(__('The minimum total for using this discount is %s', 'invoicing'), $min); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - if ( ! $this->discount->is_maximum_amount_met( $total ) ) { |
|
| 659 | + if (!$this->discount->is_maximum_amount_met($total)) { |
|
| 660 | 660 | $this->is_discount_valid = false; |
| 661 | - $max = wpinv_price( wpinv_format_amount( $$this->discount->max_total ) ); |
|
| 662 | - $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ); |
|
| 661 | + $max = wpinv_price(wpinv_format_amount($$this->discount->max_total)); |
|
| 662 | + $this->last_error = sprintf(__('The maximum total for using this discount is %s', 'invoicing'), $max); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - if ( ! $this->is_discount_valid ) { |
|
| 665 | + if (!$this->is_discount_valid) { |
|
| 666 | 666 | $this->discount = null; |
| 667 | - $this->remove_discount( 'Discount' ); |
|
| 667 | + $this->remove_discount('Discount'); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | } |
@@ -675,22 +675,22 @@ discard block |
||
| 675 | 675 | * @since 1.0.19 |
| 676 | 676 | * @param GetPaid_Form_Item $item |
| 677 | 677 | */ |
| 678 | - public function process_item_discount( $item ) { |
|
| 678 | + public function process_item_discount($item) { |
|
| 679 | 679 | |
| 680 | 680 | // Abort early if there is no discount. |
| 681 | - if ( ! $this->has_discount_code() ) { |
|
| 681 | + if (!$this->has_discount_code()) { |
|
| 682 | 682 | return; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // Ensure that it is valid for this item. |
| 686 | - if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
| 686 | + if (!$this->discount->is_valid_for_items(array($item->get_id()))) { |
|
| 687 | 687 | return; |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | // Fetch the discounted amount. |
| 691 | - $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() ); |
|
| 691 | + $discount = $this->discount->get_discounted_amount($item->get_price() * $item->get_quantity()); |
|
| 692 | 692 | |
| 693 | - $this->add_discount( 'Discount', $discount ); |
|
| 693 | + $this->add_discount('Discount', $discount); |
|
| 694 | 694 | |
| 695 | 695 | } |
| 696 | 696 | |
@@ -708,8 +708,8 @@ discard block |
||
| 708 | 708 | * |
| 709 | 709 | * @since 1.0.19 |
| 710 | 710 | */ |
| 711 | - public function get_discount( $name ) { |
|
| 712 | - return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0; |
|
| 711 | + public function get_discount($name) { |
|
| 712 | + return isset($this->discounts[$name]) ? $this->discounts[$name] : 0; |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | /** |
@@ -728,15 +728,15 @@ discard block |
||
| 728 | 728 | * |
| 729 | 729 | * @since 1.0.19 |
| 730 | 730 | */ |
| 731 | - public function add_fee( $name, $amount ) { |
|
| 732 | - $amount = wpinv_sanitize_amount( $amount ); |
|
| 731 | + public function add_fee($name, $amount) { |
|
| 732 | + $amount = wpinv_sanitize_amount($amount); |
|
| 733 | 733 | |
| 734 | 734 | $this->total_fees_amount += $amount; |
| 735 | 735 | |
| 736 | - if ( isset( $this->fees[ $name ] ) ) { |
|
| 737 | - $this->fees[ $name ] += $amount; |
|
| 736 | + if (isset($this->fees[$name])) { |
|
| 737 | + $this->fees[$name] += $amount; |
|
| 738 | 738 | } else { |
| 739 | - $this->fees[ $name ] = $amount; |
|
| 739 | + $this->fees[$name] = $amount; |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | } |
@@ -755,8 +755,8 @@ discard block |
||
| 755 | 755 | * |
| 756 | 756 | * @since 1.0.19 |
| 757 | 757 | */ |
| 758 | - public function get_fee( $name ) { |
|
| 759 | - return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0; |
|
| 758 | + public function get_fee($name) { |
|
| 759 | + return isset($this->fees[$name]) ? $this->fees[$name] : 0; |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | */ |
| 778 | 778 | public function get_total() { |
| 779 | 779 | $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
| 780 | - $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this ); |
|
| 781 | - return wpinv_sanitize_amount( $total ); |
|
| 780 | + $total = apply_filters('getpaid_get_submission_total_amount', $total, $this); |
|
| 781 | + return wpinv_sanitize_amount($total); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | /** |
@@ -789,11 +789,11 @@ discard block |
||
| 789 | 789 | public function get_payment_details() { |
| 790 | 790 | $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
| 791 | 791 | |
| 792 | - if ( $this->has_recurring ) { |
|
| 792 | + if ($this->has_recurring) { |
|
| 793 | 793 | $collect = true; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this ); |
|
| 796 | + $collect = apply_filters('getpaid_submission_collect_payment_details', $collect, $this); |
|
| 797 | 797 | return $collect; |
| 798 | 798 | } |
| 799 | 799 | |
@@ -803,8 +803,8 @@ discard block |
||
| 803 | 803 | * @since 1.0.19 |
| 804 | 804 | */ |
| 805 | 805 | public function get_billing_email() { |
| 806 | - $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email']; |
|
| 807 | - return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this ); |
|
| 806 | + $billing_email = empty($this->data['billing_email']) ? '' : $this->data['billing_email']; |
|
| 807 | + return apply_filters('getpaid_get_submission_billing_email', $billing_email, $this); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | /** |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | */ |
| 815 | 815 | public function has_billing_email() { |
| 816 | 816 | $billing_email = $this->get_billing_email(); |
| 817 | - return ! empty( $billing_email ); |
|
| 817 | + return !empty($billing_email); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
@@ -825,16 +825,16 @@ discard block |
||
| 825 | 825 | public function maybe_validate_vat() { |
| 826 | 826 | |
| 827 | 827 | // Make sure that taxes are enabled. |
| 828 | - if ( ! wpinv_use_taxes() ) { |
|
| 828 | + if (!wpinv_use_taxes()) { |
|
| 829 | 829 | return; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | // Check if we have a digital VAT rule. |
| 833 | 833 | $has_digital = false; |
| 834 | 834 | |
| 835 | - foreach ( $this->get_items() as $item ) { |
|
| 835 | + foreach ($this->get_items() as $item) { |
|
| 836 | 836 | |
| 837 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
| 837 | + if ('digital' == $item->get_vat_rule()) { |
|
| 838 | 838 | $has_digital = true; |
| 839 | 839 | break; |
| 840 | 840 | } |
@@ -845,14 +845,14 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | // Check if we require vat. |
| 847 | 847 | $requires_vat = ( |
| 848 | - ( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) |
|
| 849 | - || ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) |
|
| 848 | + (getpaid_is_eu_state($this->country) && (getpaid_is_eu_state(wpinv_get_default_country()) || $has_digital)) |
|
| 849 | + || (getpaid_is_gst_country($this->country) && getpaid_is_gst_country(wpinv_get_default_country())) |
|
| 850 | 850 | ); |
| 851 | 851 | |
| 852 | 852 | $this->requires_vat = $requires_vat; |
| 853 | 853 | |
| 854 | 854 | // Abort if we are not calculating the taxes. |
| 855 | - if ( ! $has_digital && ! $requires_vat ) { |
|
| 855 | + if (!$has_digital && !$requires_vat) { |
|
| 856 | 856 | return; |
| 857 | 857 | } |
| 858 | 858 | |
@@ -860,23 +860,23 @@ discard block |
||
| 860 | 860 | $vat_number = $this->get_vat_number(); |
| 861 | 861 | $company = $this->get_company(); |
| 862 | 862 | $ip_country = WPInv_EUVat::get_country_by_ip(); |
| 863 | - $is_eu = getpaid_is_eu_state( $this->country ); |
|
| 864 | - $is_ip_eu = getpaid_is_eu_state( $ip_country ); |
|
| 865 | - $is_non_eu = ! $is_eu && ! $is_ip_eu; |
|
| 866 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 863 | + $is_eu = getpaid_is_eu_state($this->country); |
|
| 864 | + $is_ip_eu = getpaid_is_eu_state($ip_country); |
|
| 865 | + $is_non_eu = !$is_eu && !$is_ip_eu; |
|
| 866 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
| 867 | 867 | |
| 868 | 868 | // If we're preventing business to consumer purchases... |
| 869 | - if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) { |
|
| 869 | + if (!empty($prevent_b2c) && !$is_non_eu && (empty($vat_number) || !$requires_vat)) { |
|
| 870 | 870 | |
| 871 | - if ( $is_eu ) { |
|
| 871 | + if ($is_eu) { |
|
| 872 | 872 | $this->last_error = wp_sprintf( |
| 873 | - __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
| 873 | + __('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'), |
|
| 874 | 874 | getpaid_vat_name() |
| 875 | 875 | ); |
| 876 | - } else if ( $has_digital && $is_ip_eu ) { |
|
| 876 | + } else if ($has_digital && $is_ip_eu) { |
|
| 877 | 877 | |
| 878 | 878 | $this->last_error = wp_sprintf( |
| 879 | - __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), |
|
| 879 | + __('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), |
|
| 880 | 880 | getpaid_vat_name() |
| 881 | 881 | ); |
| 882 | 882 | |
@@ -885,13 +885,13 @@ discard block |
||
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | // Abort if we are not validating vat. |
| 888 | - if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) { |
|
| 888 | + if (!$is_eu || !$requires_vat || empty($vat_number)) { |
|
| 889 | 889 | return; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country ); |
|
| 892 | + $is_valid = WPInv_EUVat::validate_vat_number($vat_number, $company, $this->country); |
|
| 893 | 893 | |
| 894 | - if ( is_string( $is_valid ) ) { |
|
| 894 | + if (is_string($is_valid)) { |
|
| 895 | 895 | $this->last_error = $is_valid; |
| 896 | 896 | } |
| 897 | 897 | |
@@ -13,539 +13,539 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | abstract class GetPaid_Payment_Gateway { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Set if the place checkout button should be renamed on selection. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $checkout_button_text; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Boolean whether the method is enabled. |
|
| 25 | - * |
|
| 26 | - * @var bool |
|
| 27 | - */ |
|
| 28 | - public $enabled = true; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Payment method id. |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public $id; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Payment method order. |
|
| 39 | - * |
|
| 40 | - * @var int |
|
| 41 | - */ |
|
| 42 | - public $order = 10; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Payment method title for the frontend. |
|
| 46 | - * |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 49 | - public $title; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Payment method description for the frontend. |
|
| 53 | - * |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - public $description; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Gateway title. |
|
| 60 | - * |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 63 | - public $method_title = ''; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Gateway description. |
|
| 67 | - * |
|
| 68 | - * @var string |
|
| 69 | - */ |
|
| 70 | - public $method_description = ''; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Countries this gateway is allowed for. |
|
| 74 | - * |
|
| 75 | - * @var array |
|
| 76 | - */ |
|
| 77 | - public $countries; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Currencies this gateway is allowed for. |
|
| 81 | - * |
|
| 82 | - * @var array |
|
| 83 | - */ |
|
| 84 | - public $currencies; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Currencies this gateway is not allowed for. |
|
| 88 | - * |
|
| 89 | - * @var array |
|
| 90 | - */ |
|
| 91 | - public $exclude_currencies; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Maximum transaction amount, zero does not define a maximum. |
|
| 95 | - * |
|
| 96 | - * @var int |
|
| 97 | - */ |
|
| 98 | - public $max_amount = 0; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Optional URL to view a transaction. |
|
| 102 | - * |
|
| 103 | - * @var string |
|
| 104 | - */ |
|
| 105 | - public $view_transaction_url = ''; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Optional URL to view a subscription. |
|
| 109 | - * |
|
| 110 | - * @var string |
|
| 111 | - */ |
|
| 112 | - public $view_subscription_url = ''; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Optional label to show for "new payment method" in the payment |
|
| 116 | - * method/token selection radio selection. |
|
| 117 | - * |
|
| 118 | - * @var string |
|
| 119 | - */ |
|
| 120 | - public $new_method_label = ''; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Contains a users saved tokens for this gateway. |
|
| 124 | - * |
|
| 125 | - * @var array |
|
| 126 | - */ |
|
| 127 | - protected $tokens = array(); |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * An array of features that this gateway supports. |
|
| 131 | - * |
|
| 132 | - * @var array |
|
| 133 | - */ |
|
| 134 | - protected $supports = array(); |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Class constructor. |
|
| 138 | - */ |
|
| 139 | - public function __construct() { |
|
| 140 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 141 | - |
|
| 142 | - // Register gateway. |
|
| 143 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 144 | - |
|
| 145 | - // Enable Subscriptions. |
|
| 146 | - if ( $this->supports( 'subscription' ) ) { |
|
| 147 | - add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // Gateway settings. |
|
| 151 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 152 | - |
|
| 153 | - // Process payment. |
|
| 154 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 155 | - |
|
| 156 | - // Change the checkout button text. |
|
| 157 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
| 158 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // Check if a gateway is valid for a given currency. |
|
| 162 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 163 | - |
|
| 164 | - // Generate the transaction url. |
|
| 165 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 166 | - |
|
| 167 | - // Generate the subscription url. |
|
| 168 | - add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
| 169 | - |
|
| 170 | - // Confirm payments. |
|
| 171 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 172 | - |
|
| 173 | - // Verify IPNs. |
|
| 174 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 175 | - |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Checks if this gateway is a given gateway. |
|
| 180 | - * |
|
| 181 | - * @since 1.0.19 |
|
| 182 | - * @return bool |
|
| 183 | - */ |
|
| 184 | - public function is( $gateway ) { |
|
| 185 | - return $gateway == $this->id; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Returns a users saved tokens for this gateway. |
|
| 190 | - * |
|
| 191 | - * @since 1.0.19 |
|
| 192 | - * @return array |
|
| 193 | - */ |
|
| 194 | - public function get_tokens() { |
|
| 195 | - |
|
| 196 | - if ( count( $this->tokens ) > 0 ) { |
|
| 197 | - return $this->tokens; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) ) { |
|
| 201 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 202 | - |
|
| 203 | - if ( is_array( $tokens ) ) { |
|
| 204 | - $this->tokens = $tokens; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - return $this->tokens; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Return the title for admin screens. |
|
| 214 | - * |
|
| 215 | - * @return string |
|
| 216 | - */ |
|
| 217 | - public function get_method_title() { |
|
| 218 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * Return the description for admin screens. |
|
| 223 | - * |
|
| 224 | - * @return string |
|
| 225 | - */ |
|
| 226 | - public function get_method_description() { |
|
| 227 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Get the success url. |
|
| 232 | - * |
|
| 233 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 234 | - * @return string |
|
| 235 | - */ |
|
| 236 | - public function get_return_url( $invoice ) { |
|
| 237 | - |
|
| 238 | - // Payment success url |
|
| 239 | - $return_url = add_query_arg( |
|
| 240 | - array( |
|
| 241 | - 'payment-confirm' => $this->id, |
|
| 242 | - 'invoice_key' => $invoice->get_key(), |
|
| 243 | - 'utm_nooverride' => 1 |
|
| 244 | - ), |
|
| 245 | - wpinv_get_success_page_uri() |
|
| 246 | - ); |
|
| 247 | - |
|
| 248 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Confirms payments when rendering the success page. |
|
| 253 | - * |
|
| 254 | - * @param string $content Success page content. |
|
| 255 | - * @return string |
|
| 256 | - */ |
|
| 257 | - public function get_confirm_payment( $content ) { |
|
| 16 | + /** |
|
| 17 | + * Set if the place checkout button should be renamed on selection. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $checkout_button_text; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Boolean whether the method is enabled. |
|
| 25 | + * |
|
| 26 | + * @var bool |
|
| 27 | + */ |
|
| 28 | + public $enabled = true; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Payment method id. |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public $id; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Payment method order. |
|
| 39 | + * |
|
| 40 | + * @var int |
|
| 41 | + */ |
|
| 42 | + public $order = 10; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Payment method title for the frontend. |
|
| 46 | + * |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | + public $title; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Payment method description for the frontend. |
|
| 53 | + * |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + public $description; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Gateway title. |
|
| 60 | + * |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | + public $method_title = ''; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Gateway description. |
|
| 67 | + * |
|
| 68 | + * @var string |
|
| 69 | + */ |
|
| 70 | + public $method_description = ''; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Countries this gateway is allowed for. |
|
| 74 | + * |
|
| 75 | + * @var array |
|
| 76 | + */ |
|
| 77 | + public $countries; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Currencies this gateway is allowed for. |
|
| 81 | + * |
|
| 82 | + * @var array |
|
| 83 | + */ |
|
| 84 | + public $currencies; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Currencies this gateway is not allowed for. |
|
| 88 | + * |
|
| 89 | + * @var array |
|
| 90 | + */ |
|
| 91 | + public $exclude_currencies; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Maximum transaction amount, zero does not define a maximum. |
|
| 95 | + * |
|
| 96 | + * @var int |
|
| 97 | + */ |
|
| 98 | + public $max_amount = 0; |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Optional URL to view a transaction. |
|
| 102 | + * |
|
| 103 | + * @var string |
|
| 104 | + */ |
|
| 105 | + public $view_transaction_url = ''; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Optional URL to view a subscription. |
|
| 109 | + * |
|
| 110 | + * @var string |
|
| 111 | + */ |
|
| 112 | + public $view_subscription_url = ''; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Optional label to show for "new payment method" in the payment |
|
| 116 | + * method/token selection radio selection. |
|
| 117 | + * |
|
| 118 | + * @var string |
|
| 119 | + */ |
|
| 120 | + public $new_method_label = ''; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Contains a users saved tokens for this gateway. |
|
| 124 | + * |
|
| 125 | + * @var array |
|
| 126 | + */ |
|
| 127 | + protected $tokens = array(); |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * An array of features that this gateway supports. |
|
| 131 | + * |
|
| 132 | + * @var array |
|
| 133 | + */ |
|
| 134 | + protected $supports = array(); |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Class constructor. |
|
| 138 | + */ |
|
| 139 | + public function __construct() { |
|
| 140 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 141 | + |
|
| 142 | + // Register gateway. |
|
| 143 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 144 | + |
|
| 145 | + // Enable Subscriptions. |
|
| 146 | + if ( $this->supports( 'subscription' ) ) { |
|
| 147 | + add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // Gateway settings. |
|
| 151 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 152 | + |
|
| 153 | + // Process payment. |
|
| 154 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 155 | + |
|
| 156 | + // Change the checkout button text. |
|
| 157 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
| 158 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // Check if a gateway is valid for a given currency. |
|
| 162 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 163 | + |
|
| 164 | + // Generate the transaction url. |
|
| 165 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 166 | + |
|
| 167 | + // Generate the subscription url. |
|
| 168 | + add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
| 169 | + |
|
| 170 | + // Confirm payments. |
|
| 171 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 172 | + |
|
| 173 | + // Verify IPNs. |
|
| 174 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 175 | + |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Checks if this gateway is a given gateway. |
|
| 180 | + * |
|
| 181 | + * @since 1.0.19 |
|
| 182 | + * @return bool |
|
| 183 | + */ |
|
| 184 | + public function is( $gateway ) { |
|
| 185 | + return $gateway == $this->id; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Returns a users saved tokens for this gateway. |
|
| 190 | + * |
|
| 191 | + * @since 1.0.19 |
|
| 192 | + * @return array |
|
| 193 | + */ |
|
| 194 | + public function get_tokens() { |
|
| 195 | + |
|
| 196 | + if ( count( $this->tokens ) > 0 ) { |
|
| 197 | + return $this->tokens; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) ) { |
|
| 201 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 202 | + |
|
| 203 | + if ( is_array( $tokens ) ) { |
|
| 204 | + $this->tokens = $tokens; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + return $this->tokens; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Return the title for admin screens. |
|
| 214 | + * |
|
| 215 | + * @return string |
|
| 216 | + */ |
|
| 217 | + public function get_method_title() { |
|
| 218 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * Return the description for admin screens. |
|
| 223 | + * |
|
| 224 | + * @return string |
|
| 225 | + */ |
|
| 226 | + public function get_method_description() { |
|
| 227 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Get the success url. |
|
| 232 | + * |
|
| 233 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 234 | + * @return string |
|
| 235 | + */ |
|
| 236 | + public function get_return_url( $invoice ) { |
|
| 237 | + |
|
| 238 | + // Payment success url |
|
| 239 | + $return_url = add_query_arg( |
|
| 240 | + array( |
|
| 241 | + 'payment-confirm' => $this->id, |
|
| 242 | + 'invoice_key' => $invoice->get_key(), |
|
| 243 | + 'utm_nooverride' => 1 |
|
| 244 | + ), |
|
| 245 | + wpinv_get_success_page_uri() |
|
| 246 | + ); |
|
| 247 | + |
|
| 248 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Confirms payments when rendering the success page. |
|
| 253 | + * |
|
| 254 | + * @param string $content Success page content. |
|
| 255 | + * @return string |
|
| 256 | + */ |
|
| 257 | + public function get_confirm_payment( $content ) { |
|
| 258 | 258 | |
| 259 | - // Retrieve the invoice. |
|
| 260 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
| 261 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 259 | + // Retrieve the invoice. |
|
| 260 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
| 261 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 262 | 262 | |
| 263 | - // Ensure that it exists and that it is pending payment. |
|
| 264 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 265 | - return $content; |
|
| 266 | - } |
|
| 263 | + // Ensure that it exists and that it is pending payment. |
|
| 264 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 265 | + return $content; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - // Can the user view this invoice?? |
|
| 269 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 270 | - return $content; |
|
| 271 | - } |
|
| 268 | + // Can the user view this invoice?? |
|
| 269 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 270 | + return $content; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - // Show payment processing indicator. |
|
| 274 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Processes ipns and marks payments as complete. |
|
| 279 | - * |
|
| 280 | - * @return void |
|
| 281 | - */ |
|
| 282 | - public function verify_ipn() {} |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
| 286 | - * |
|
| 287 | - * @param string $transaction_url transaction url. |
|
| 288 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 289 | - * @return string transaction URL, or empty string. |
|
| 290 | - */ |
|
| 291 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 292 | - |
|
| 293 | - $transaction_id = $invoice->get_transaction_id(); |
|
| 294 | - |
|
| 295 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 296 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 297 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 298 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - return $transaction_url; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
| 306 | - * |
|
| 307 | - * @param string $subscription_url transaction url. |
|
| 308 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 309 | - * @return string subscription URL, or empty string. |
|
| 310 | - */ |
|
| 311 | - public function filter_subscription_url( $subscription_url, $invoice ) { |
|
| 312 | - |
|
| 313 | - $profile_id = $invoice->get_subscription_id(); |
|
| 314 | - |
|
| 315 | - if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 316 | - |
|
| 317 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 318 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 319 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 320 | - |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - return $subscription_url; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * Check if the gateway is available for use. |
|
| 328 | - * |
|
| 329 | - * @return bool |
|
| 330 | - */ |
|
| 331 | - public function is_available() { |
|
| 332 | - return ! empty( $this->enabled ); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Return the gateway's title. |
|
| 337 | - * |
|
| 338 | - * @return string |
|
| 339 | - */ |
|
| 340 | - public function get_title() { |
|
| 341 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Return the gateway's description. |
|
| 346 | - * |
|
| 347 | - * @return string |
|
| 348 | - */ |
|
| 349 | - public function get_description() { |
|
| 350 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Process Payment. |
|
| 355 | - * |
|
| 356 | - * |
|
| 357 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 358 | - * @param array $submission_data Posted checkout fields. |
|
| 359 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 360 | - * @return void |
|
| 361 | - */ |
|
| 362 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 363 | - // Process the payment then either redirect to the success page or the gateway. |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * Process refund. |
|
| 368 | - * |
|
| 369 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
| 370 | - * a passed in amount. |
|
| 371 | - * |
|
| 372 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 373 | - * @param float $amount Refund amount. |
|
| 374 | - * @param string $reason Refund reason. |
|
| 375 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
| 376 | - */ |
|
| 377 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 378 | - return false; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Displays the payment fields, credit cards etc. |
|
| 383 | - * |
|
| 384 | - * @param int $invoice_id 0 or invoice id. |
|
| 385 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
| 386 | - */ |
|
| 387 | - public function payment_fields( $invoice_id, $form ) {} |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Check if a gateway supports a given feature. |
|
| 391 | - * |
|
| 392 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
| 393 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
| 394 | - * |
|
| 395 | - * @param string $feature string The name of a feature to test support for. |
|
| 396 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
| 397 | - * @since 1.0.19 |
|
| 398 | - */ |
|
| 399 | - public function supports( $feature ) { |
|
| 400 | - return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * Grab and display our saved payment methods. |
|
| 405 | - * |
|
| 406 | - * @since 1.0.19 |
|
| 407 | - */ |
|
| 408 | - public function saved_payment_methods() { |
|
| 409 | - $html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">'; |
|
| 410 | - |
|
| 411 | - foreach ( $this->get_tokens() as $token ) { |
|
| 412 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - $html .= $this->get_new_payment_method_option_html(); |
|
| 416 | - $html .= '</ul>'; |
|
| 417 | - |
|
| 418 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * Gets saved payment method HTML from a token. |
|
| 423 | - * |
|
| 424 | - * @since 1.0.19 |
|
| 425 | - * @param array $token Payment Token. |
|
| 426 | - * @return string Generated payment method HTML |
|
| 427 | - */ |
|
| 428 | - public function get_saved_payment_method_option_html( $token ) { |
|
| 429 | - |
|
| 430 | - return sprintf( |
|
| 431 | - '<li class="getpaid-payment-method form-group"> |
|
| 273 | + // Show payment processing indicator. |
|
| 274 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Processes ipns and marks payments as complete. |
|
| 279 | + * |
|
| 280 | + * @return void |
|
| 281 | + */ |
|
| 282 | + public function verify_ipn() {} |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
| 286 | + * |
|
| 287 | + * @param string $transaction_url transaction url. |
|
| 288 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 289 | + * @return string transaction URL, or empty string. |
|
| 290 | + */ |
|
| 291 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 292 | + |
|
| 293 | + $transaction_id = $invoice->get_transaction_id(); |
|
| 294 | + |
|
| 295 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 296 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 297 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 298 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + return $transaction_url; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
| 306 | + * |
|
| 307 | + * @param string $subscription_url transaction url. |
|
| 308 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 309 | + * @return string subscription URL, or empty string. |
|
| 310 | + */ |
|
| 311 | + public function filter_subscription_url( $subscription_url, $invoice ) { |
|
| 312 | + |
|
| 313 | + $profile_id = $invoice->get_subscription_id(); |
|
| 314 | + |
|
| 315 | + if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 316 | + |
|
| 317 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 318 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 319 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 320 | + |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + return $subscription_url; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * Check if the gateway is available for use. |
|
| 328 | + * |
|
| 329 | + * @return bool |
|
| 330 | + */ |
|
| 331 | + public function is_available() { |
|
| 332 | + return ! empty( $this->enabled ); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Return the gateway's title. |
|
| 337 | + * |
|
| 338 | + * @return string |
|
| 339 | + */ |
|
| 340 | + public function get_title() { |
|
| 341 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Return the gateway's description. |
|
| 346 | + * |
|
| 347 | + * @return string |
|
| 348 | + */ |
|
| 349 | + public function get_description() { |
|
| 350 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Process Payment. |
|
| 355 | + * |
|
| 356 | + * |
|
| 357 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 358 | + * @param array $submission_data Posted checkout fields. |
|
| 359 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 360 | + * @return void |
|
| 361 | + */ |
|
| 362 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 363 | + // Process the payment then either redirect to the success page or the gateway. |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * Process refund. |
|
| 368 | + * |
|
| 369 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
| 370 | + * a passed in amount. |
|
| 371 | + * |
|
| 372 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 373 | + * @param float $amount Refund amount. |
|
| 374 | + * @param string $reason Refund reason. |
|
| 375 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
| 376 | + */ |
|
| 377 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 378 | + return false; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Displays the payment fields, credit cards etc. |
|
| 383 | + * |
|
| 384 | + * @param int $invoice_id 0 or invoice id. |
|
| 385 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
| 386 | + */ |
|
| 387 | + public function payment_fields( $invoice_id, $form ) {} |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Check if a gateway supports a given feature. |
|
| 391 | + * |
|
| 392 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
| 393 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
| 394 | + * |
|
| 395 | + * @param string $feature string The name of a feature to test support for. |
|
| 396 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
| 397 | + * @since 1.0.19 |
|
| 398 | + */ |
|
| 399 | + public function supports( $feature ) { |
|
| 400 | + return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * Grab and display our saved payment methods. |
|
| 405 | + * |
|
| 406 | + * @since 1.0.19 |
|
| 407 | + */ |
|
| 408 | + public function saved_payment_methods() { |
|
| 409 | + $html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">'; |
|
| 410 | + |
|
| 411 | + foreach ( $this->get_tokens() as $token ) { |
|
| 412 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + $html .= $this->get_new_payment_method_option_html(); |
|
| 416 | + $html .= '</ul>'; |
|
| 417 | + |
|
| 418 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * Gets saved payment method HTML from a token. |
|
| 423 | + * |
|
| 424 | + * @since 1.0.19 |
|
| 425 | + * @param array $token Payment Token. |
|
| 426 | + * @return string Generated payment method HTML |
|
| 427 | + */ |
|
| 428 | + public function get_saved_payment_method_option_html( $token ) { |
|
| 429 | + |
|
| 430 | + return sprintf( |
|
| 431 | + '<li class="getpaid-payment-method form-group"> |
|
| 432 | 432 | <label> |
| 433 | 433 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
| 434 | 434 | <span>%3$s</span> |
| 435 | 435 | </label> |
| 436 | 436 | </li>', |
| 437 | - esc_attr( $this->id ), |
|
| 438 | - esc_attr( $token['id'] ), |
|
| 439 | - esc_html( $token['name'] ), |
|
| 440 | - checked( empty( $token['default'] ), false, false ) |
|
| 441 | - ); |
|
| 437 | + esc_attr( $this->id ), |
|
| 438 | + esc_attr( $token['id'] ), |
|
| 439 | + esc_html( $token['name'] ), |
|
| 440 | + checked( empty( $token['default'] ), false, false ) |
|
| 441 | + ); |
|
| 442 | 442 | |
| 443 | - } |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - /** |
|
| 446 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
| 447 | - * |
|
| 448 | - * @since 1.0.19 |
|
| 449 | - */ |
|
| 450 | - public function get_new_payment_method_option_html() { |
|
| 445 | + /** |
|
| 446 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
| 447 | + * |
|
| 448 | + * @since 1.0.19 |
|
| 449 | + */ |
|
| 450 | + public function get_new_payment_method_option_html() { |
|
| 451 | 451 | |
| 452 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 452 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 453 | 453 | |
| 454 | - return sprintf( |
|
| 455 | - '<li class="getpaid-new-payment-method"> |
|
| 454 | + return sprintf( |
|
| 455 | + '<li class="getpaid-new-payment-method"> |
|
| 456 | 456 | <label> |
| 457 | 457 | <input name="getpaid-%1$s-payment-method" type="radio" value="new" style="width:auto;" /> |
| 458 | 458 | <span>%2$s</span> |
| 459 | 459 | </label> |
| 460 | 460 | </li>', |
| 461 | - esc_attr( $this->id ), |
|
| 462 | - esc_html( $label ) |
|
| 463 | - ); |
|
| 464 | - |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * Outputs a checkbox for saving a new payment method to the database. |
|
| 469 | - * |
|
| 470 | - * @since 1.0.19 |
|
| 471 | - */ |
|
| 472 | - public function save_payment_method_checkbox() { |
|
| 461 | + esc_attr( $this->id ), |
|
| 462 | + esc_html( $label ) |
|
| 463 | + ); |
|
| 464 | + |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * Outputs a checkbox for saving a new payment method to the database. |
|
| 469 | + * |
|
| 470 | + * @since 1.0.19 |
|
| 471 | + */ |
|
| 472 | + public function save_payment_method_checkbox() { |
|
| 473 | 473 | |
| 474 | - return sprintf( |
|
| 475 | - '<p class="form-group getpaid-save-payment-method"> |
|
| 474 | + return sprintf( |
|
| 475 | + '<p class="form-group getpaid-save-payment-method"> |
|
| 476 | 476 | <label> |
| 477 | 477 | <input name="getpaid-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" /> |
| 478 | 478 | <span>%2$s</span> |
| 479 | 479 | </label> |
| 480 | 480 | </p>', |
| 481 | - esc_attr( $this->id ), |
|
| 482 | - esc_html__( 'Save payment method', 'invoicing' ) |
|
| 483 | - ); |
|
| 481 | + esc_attr( $this->id ), |
|
| 482 | + esc_html__( 'Save payment method', 'invoicing' ) |
|
| 483 | + ); |
|
| 484 | 484 | |
| 485 | - } |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | - /** |
|
| 488 | - * Registers the gateway. |
|
| 489 | - * |
|
| 490 | - * @return array |
|
| 491 | - */ |
|
| 492 | - public function register_gateway( $gateways ) { |
|
| 487 | + /** |
|
| 488 | + * Registers the gateway. |
|
| 489 | + * |
|
| 490 | + * @return array |
|
| 491 | + */ |
|
| 492 | + public function register_gateway( $gateways ) { |
|
| 493 | 493 | |
| 494 | - $gateways[ $this->id ] = array( |
|
| 494 | + $gateways[ $this->id ] = array( |
|
| 495 | 495 | |
| 496 | - 'admin_label' => $this->method_title, |
|
| 496 | + 'admin_label' => $this->method_title, |
|
| 497 | 497 | 'checkout_label' => $this->title, |
| 498 | - 'ordering' => $this->order, |
|
| 499 | - |
|
| 500 | - ); |
|
| 501 | - |
|
| 502 | - return $gateways; |
|
| 503 | - |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * Checks whether or not this is a sandbox request. |
|
| 508 | - * |
|
| 509 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
| 510 | - * @return bool |
|
| 511 | - */ |
|
| 512 | - public function is_sandbox( $invoice = null ) { |
|
| 513 | - |
|
| 514 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 515 | - return $invoice->get_mode() == 'test'; |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - return wpinv_is_test_mode( $this->id ); |
|
| 519 | - |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * Renames the checkout button |
|
| 524 | - * |
|
| 525 | - * @return string |
|
| 526 | - */ |
|
| 527 | - public function rename_checkout_button() { |
|
| 528 | - return $this->checkout_button_text; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * Validate gateway currency |
|
| 533 | - * |
|
| 534 | - * @return bool |
|
| 535 | - */ |
|
| 536 | - public function validate_currency( $validation, $currency ) { |
|
| 537 | - |
|
| 538 | - // Required currencies. |
|
| 539 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 540 | - return false; |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - // Excluded currencies. |
|
| 544 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 545 | - return false; |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - return $validation; |
|
| 549 | - } |
|
| 498 | + 'ordering' => $this->order, |
|
| 499 | + |
|
| 500 | + ); |
|
| 501 | + |
|
| 502 | + return $gateways; |
|
| 503 | + |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * Checks whether or not this is a sandbox request. |
|
| 508 | + * |
|
| 509 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
| 510 | + * @return bool |
|
| 511 | + */ |
|
| 512 | + public function is_sandbox( $invoice = null ) { |
|
| 513 | + |
|
| 514 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 515 | + return $invoice->get_mode() == 'test'; |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + return wpinv_is_test_mode( $this->id ); |
|
| 519 | + |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * Renames the checkout button |
|
| 524 | + * |
|
| 525 | + * @return string |
|
| 526 | + */ |
|
| 527 | + public function rename_checkout_button() { |
|
| 528 | + return $this->checkout_button_text; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * Validate gateway currency |
|
| 533 | + * |
|
| 534 | + * @return bool |
|
| 535 | + */ |
|
| 536 | + public function validate_currency( $validation, $currency ) { |
|
| 537 | + |
|
| 538 | + // Required currencies. |
|
| 539 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 540 | + return false; |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + // Excluded currencies. |
|
| 544 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 545 | + return false; |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + return $validation; |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | 551 | } |
@@ -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 | * Abstaract Payment Gateway class. |
@@ -137,41 +137,41 @@ discard block |
||
| 137 | 137 | * Class constructor. |
| 138 | 138 | */ |
| 139 | 139 | public function __construct() { |
| 140 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 140 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
| 141 | 141 | |
| 142 | 142 | // Register gateway. |
| 143 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 143 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
| 144 | 144 | |
| 145 | 145 | // Enable Subscriptions. |
| 146 | - if ( $this->supports( 'subscription' ) ) { |
|
| 147 | - add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
| 146 | + if ($this->supports('subscription')) { |
|
| 147 | + add_filter("wpinv_{$this->id}_support_subscription", '__return_true'); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Gateway settings. |
| 151 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 151 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
| 152 | 152 | |
| 153 | 153 | // Process payment. |
| 154 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 154 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
| 155 | 155 | |
| 156 | 156 | // Change the checkout button text. |
| 157 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
| 158 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 157 | + if (!empty($this->checkout_button_text)) { |
|
| 158 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Check if a gateway is valid for a given currency. |
| 162 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 162 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
| 163 | 163 | |
| 164 | 164 | // Generate the transaction url. |
| 165 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 165 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
| 166 | 166 | |
| 167 | 167 | // Generate the subscription url. |
| 168 | - add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
| 168 | + add_filter("getpaid_gateway_{$this->id}_subscription_url", array($this, 'filter_subscription_url'), 10, 2); |
|
| 169 | 169 | |
| 170 | 170 | // Confirm payments. |
| 171 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 171 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
| 172 | 172 | |
| 173 | 173 | // Verify IPNs. |
| 174 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 174 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
| 175 | 175 | |
| 176 | 176 | } |
| 177 | 177 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @since 1.0.19 |
| 182 | 182 | * @return bool |
| 183 | 183 | */ |
| 184 | - public function is( $gateway ) { |
|
| 184 | + public function is($gateway) { |
|
| 185 | 185 | return $gateway == $this->id; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function get_tokens() { |
| 195 | 195 | |
| 196 | - if ( count( $this->tokens ) > 0 ) { |
|
| 196 | + if (count($this->tokens) > 0) { |
|
| 197 | 197 | return $this->tokens; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) ) { |
|
| 201 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 200 | + if (is_user_logged_in() && $this->supports('tokens')) { |
|
| 201 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
| 202 | 202 | |
| 203 | - if ( is_array( $tokens ) ) { |
|
| 203 | + if (is_array($tokens)) { |
|
| 204 | 204 | $this->tokens = $tokens; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | 217 | public function get_method_title() { |
| 218 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 218 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @return string |
| 225 | 225 | */ |
| 226 | 226 | public function get_method_description() { |
| 227 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 227 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param WPInv_Invoice $invoice Invoice object. |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | - public function get_return_url( $invoice ) { |
|
| 236 | + public function get_return_url($invoice) { |
|
| 237 | 237 | |
| 238 | 238 | // Payment success url |
| 239 | 239 | $return_url = add_query_arg( |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | wpinv_get_success_page_uri() |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 248 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -254,24 +254,24 @@ discard block |
||
| 254 | 254 | * @param string $content Success page content. |
| 255 | 255 | * @return string |
| 256 | 256 | */ |
| 257 | - public function get_confirm_payment( $content ) { |
|
| 257 | + public function get_confirm_payment($content) { |
|
| 258 | 258 | |
| 259 | 259 | // Retrieve the invoice. |
| 260 | 260 | $invoice_id = getpaid_get_current_invoice_id(); |
| 261 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 261 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 262 | 262 | |
| 263 | 263 | // Ensure that it exists and that it is pending payment. |
| 264 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 264 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
| 265 | 265 | return $content; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Can the user view this invoice?? |
| 269 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 269 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
| 270 | 270 | return $content; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // Show payment processing indicator. |
| 274 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 274 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -288,14 +288,14 @@ discard block |
||
| 288 | 288 | * @param WPInv_Invoice $invoice Invoice object. |
| 289 | 289 | * @return string transaction URL, or empty string. |
| 290 | 290 | */ |
| 291 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 291 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
| 292 | 292 | |
| 293 | - $transaction_id = $invoice->get_transaction_id(); |
|
| 293 | + $transaction_id = $invoice->get_transaction_id(); |
|
| 294 | 294 | |
| 295 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 296 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 297 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 298 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 295 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
| 296 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
| 297 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
| 298 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | return $transaction_url; |
@@ -308,15 +308,15 @@ discard block |
||
| 308 | 308 | * @param WPInv_Invoice $invoice Invoice object. |
| 309 | 309 | * @return string subscription URL, or empty string. |
| 310 | 310 | */ |
| 311 | - public function filter_subscription_url( $subscription_url, $invoice ) { |
|
| 311 | + public function filter_subscription_url($subscription_url, $invoice) { |
|
| 312 | 312 | |
| 313 | - $profile_id = $invoice->get_subscription_id(); |
|
| 313 | + $profile_id = $invoice->get_subscription_id(); |
|
| 314 | 314 | |
| 315 | - if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 315 | + if (!empty($this->view_subscription_url) && !empty($profile_id)) { |
|
| 316 | 316 | |
| 317 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 318 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 319 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 317 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
| 318 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
| 319 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
| 320 | 320 | |
| 321 | 321 | } |
| 322 | 322 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @return bool |
| 330 | 330 | */ |
| 331 | 331 | public function is_available() { |
| 332 | - return ! empty( $this->enabled ); |
|
| 332 | + return !empty($this->enabled); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | * @return string |
| 339 | 339 | */ |
| 340 | 340 | public function get_title() { |
| 341 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 341 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @return string |
| 348 | 348 | */ |
| 349 | 349 | public function get_description() { |
| 350 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 350 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 360 | 360 | * @return void |
| 361 | 361 | */ |
| 362 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 362 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 363 | 363 | // Process the payment then either redirect to the success page or the gateway. |
| 364 | 364 | } |
| 365 | 365 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * @param string $reason Refund reason. |
| 375 | 375 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
| 376 | 376 | */ |
| 377 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 377 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * @param int $invoice_id 0 or invoice id. |
| 385 | 385 | * @param GetPaid_Payment_Form $form Current payment form. |
| 386 | 386 | */ |
| 387 | - public function payment_fields( $invoice_id, $form ) {} |
|
| 387 | + public function payment_fields($invoice_id, $form) {} |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * Check if a gateway supports a given feature. |
@@ -396,8 +396,8 @@ discard block |
||
| 396 | 396 | * @return bool True if the gateway supports the feature, false otherwise. |
| 397 | 397 | * @since 1.0.19 |
| 398 | 398 | */ |
| 399 | - public function supports( $feature ) { |
|
| 400 | - return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
| 399 | + public function supports($feature) { |
|
| 400 | + return apply_filters('getpaid_payment_gateway_supports', in_array($feature, $this->supports), $feature, $this); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
@@ -406,16 +406,16 @@ discard block |
||
| 406 | 406 | * @since 1.0.19 |
| 407 | 407 | */ |
| 408 | 408 | public function saved_payment_methods() { |
| 409 | - $html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">'; |
|
| 409 | + $html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr(count($this->get_tokens())) . '">'; |
|
| 410 | 410 | |
| 411 | - foreach ( $this->get_tokens() as $token ) { |
|
| 412 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 411 | + foreach ($this->get_tokens() as $token) { |
|
| 412 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | $html .= $this->get_new_payment_method_option_html(); |
| 416 | 416 | $html .= '</ul>'; |
| 417 | 417 | |
| 418 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 418 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | * @param array $token Payment Token. |
| 426 | 426 | * @return string Generated payment method HTML |
| 427 | 427 | */ |
| 428 | - public function get_saved_payment_method_option_html( $token ) { |
|
| 428 | + public function get_saved_payment_method_option_html($token) { |
|
| 429 | 429 | |
| 430 | 430 | return sprintf( |
| 431 | 431 | '<li class="getpaid-payment-method form-group"> |
@@ -434,10 +434,10 @@ discard block |
||
| 434 | 434 | <span>%3$s</span> |
| 435 | 435 | </label> |
| 436 | 436 | </li>', |
| 437 | - esc_attr( $this->id ), |
|
| 438 | - esc_attr( $token['id'] ), |
|
| 439 | - esc_html( $token['name'] ), |
|
| 440 | - checked( empty( $token['default'] ), false, false ) |
|
| 437 | + esc_attr($this->id), |
|
| 438 | + esc_attr($token['id']), |
|
| 439 | + esc_html($token['name']), |
|
| 440 | + checked(empty($token['default']), false, false) |
|
| 441 | 441 | ); |
| 442 | 442 | |
| 443 | 443 | } |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | public function get_new_payment_method_option_html() { |
| 451 | 451 | |
| 452 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 452 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
| 453 | 453 | |
| 454 | 454 | return sprintf( |
| 455 | 455 | '<li class="getpaid-new-payment-method"> |
@@ -458,8 +458,8 @@ discard block |
||
| 458 | 458 | <span>%2$s</span> |
| 459 | 459 | </label> |
| 460 | 460 | </li>', |
| 461 | - esc_attr( $this->id ), |
|
| 462 | - esc_html( $label ) |
|
| 461 | + esc_attr($this->id), |
|
| 462 | + esc_html($label) |
|
| 463 | 463 | ); |
| 464 | 464 | |
| 465 | 465 | } |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | <span>%2$s</span> |
| 479 | 479 | </label> |
| 480 | 480 | </p>', |
| 481 | - esc_attr( $this->id ), |
|
| 482 | - esc_html__( 'Save payment method', 'invoicing' ) |
|
| 481 | + esc_attr($this->id), |
|
| 482 | + esc_html__('Save payment method', 'invoicing') |
|
| 483 | 483 | ); |
| 484 | 484 | |
| 485 | 485 | } |
@@ -489,9 +489,9 @@ discard block |
||
| 489 | 489 | * |
| 490 | 490 | * @return array |
| 491 | 491 | */ |
| 492 | - public function register_gateway( $gateways ) { |
|
| 492 | + public function register_gateway($gateways) { |
|
| 493 | 493 | |
| 494 | - $gateways[ $this->id ] = array( |
|
| 494 | + $gateways[$this->id] = array( |
|
| 495 | 495 | |
| 496 | 496 | 'admin_label' => $this->method_title, |
| 497 | 497 | 'checkout_label' => $this->title, |
@@ -509,13 +509,13 @@ discard block |
||
| 509 | 509 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
| 510 | 510 | * @return bool |
| 511 | 511 | */ |
| 512 | - public function is_sandbox( $invoice = null ) { |
|
| 512 | + public function is_sandbox($invoice = null) { |
|
| 513 | 513 | |
| 514 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 514 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
| 515 | 515 | return $invoice->get_mode() == 'test'; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - return wpinv_is_test_mode( $this->id ); |
|
| 518 | + return wpinv_is_test_mode($this->id); |
|
| 519 | 519 | |
| 520 | 520 | } |
| 521 | 521 | |
@@ -533,15 +533,15 @@ discard block |
||
| 533 | 533 | * |
| 534 | 534 | * @return bool |
| 535 | 535 | */ |
| 536 | - public function validate_currency( $validation, $currency ) { |
|
| 536 | + public function validate_currency($validation, $currency) { |
|
| 537 | 537 | |
| 538 | 538 | // Required currencies. |
| 539 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 539 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
| 540 | 540 | return false; |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | // Excluded currencies. |
| 544 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 544 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
| 545 | 545 | return false; |
| 546 | 546 | } |
| 547 | 547 | |
@@ -13,30 +13,30 @@ discard block |
||
| 13 | 13 | class GetPaid_Manual_Gateway extends GetPaid_Payment_Gateway { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $id = 'manual'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * An array of features that this gateway supports. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 23 | + * An array of features that this gateway supports. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | 27 | protected $supports = array( 'subscription' ); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Payment method order. |
|
| 31 | - * |
|
| 32 | - * @var int |
|
| 33 | - */ |
|
| 34 | - public $order = 11; |
|
| 30 | + * Payment method order. |
|
| 31 | + * |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | + public $order = 11; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Class constructor. |
|
| 38 | - */ |
|
| 39 | - public function __construct() { |
|
| 37 | + * Class constructor. |
|
| 38 | + */ |
|
| 39 | + public function __construct() { |
|
| 40 | 40 | parent::__construct(); |
| 41 | 41 | |
| 42 | 42 | $this->title = __( 'Manual Payment', 'invoicing' ); |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * Process Payment. |
|
| 50 | - * |
|
| 51 | - * |
|
| 52 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 53 | - * @param array $submission_data Posted checkout fields. |
|
| 54 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 49 | + * Process Payment. |
|
| 50 | + * |
|
| 51 | + * |
|
| 52 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 53 | + * @param array $submission_data Posted checkout fields. |
|
| 54 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 58 | 58 | |
| 59 | 59 | // Mark it as paid. |
| 60 | 60 | $invoice->mark_paid(); |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Starts a manual subscription profile. |
|
| 72 | - * |
|
| 73 | - * |
|
| 74 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 75 | - */ |
|
| 76 | - public function start_manual_subscription_profile( $invoice ) { |
|
| 71 | + * Starts a manual subscription profile. |
|
| 72 | + * |
|
| 73 | + * |
|
| 74 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 75 | + */ |
|
| 76 | + public function start_manual_subscription_profile( $invoice ) { |
|
| 77 | 77 | |
| 78 | 78 | // Retrieve the subscription. |
| 79 | 79 | $subscription = wpinv_get_subscription( $invoice ); |
@@ -100,12 +100,12 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | - * Renews a manual subscription profile. |
|
| 104 | - * |
|
| 105 | - * |
|
| 106 | - * @param int $invoice_id Invoice. |
|
| 107 | - */ |
|
| 108 | - public function renew_manual_subscription_profile( $invoice_id ) { |
|
| 103 | + * Renews a manual subscription profile. |
|
| 104 | + * |
|
| 105 | + * |
|
| 106 | + * @param int $invoice_id Invoice. |
|
| 107 | + */ |
|
| 108 | + public function renew_manual_subscription_profile( $invoice_id ) { |
|
| 109 | 109 | |
| 110 | 110 | // Retrieve the subscription. |
| 111 | 111 | $subscription = wpinv_get_subscription( $invoice_id ); |
@@ -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 | * Manual Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription' ); |
|
| 27 | + protected $supports = array('subscription'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | public function __construct() { |
| 40 | 40 | parent::__construct(); |
| 41 | 41 | |
| 42 | - $this->title = __( 'Manual Payment', 'invoicing' ); |
|
| 43 | - $this->method_title = __( 'Manual Payment', 'invoicing' ); |
|
| 42 | + $this->title = __('Manual Payment', 'invoicing'); |
|
| 43 | + $this->method_title = __('Manual Payment', 'invoicing'); |
|
| 44 | 44 | |
| 45 | - add_action( 'wpinv_renew_manual_subscription_profile', array( $this, 'renew_manual_subscription_profile' ) ); |
|
| 45 | + add_action('wpinv_renew_manual_subscription_profile', array($this, 'renew_manual_subscription_profile')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 57 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 58 | 58 | |
| 59 | 59 | // Mark it as paid. |
| 60 | 60 | $invoice->mark_paid(); |
| 61 | 61 | |
| 62 | 62 | // (Maybe) set recurring hooks. |
| 63 | - $this->start_manual_subscription_profile( $invoice ); |
|
| 63 | + $this->start_manual_subscription_profile($invoice); |
|
| 64 | 64 | |
| 65 | 65 | // Send to the success page. |
| 66 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 66 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -73,19 +73,19 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @param WPInv_Invoice $invoice Invoice. |
| 75 | 75 | */ |
| 76 | - public function start_manual_subscription_profile( $invoice ) { |
|
| 76 | + public function start_manual_subscription_profile($invoice) { |
|
| 77 | 77 | |
| 78 | 78 | // Retrieve the subscription. |
| 79 | - $subscription = wpinv_get_subscription( $invoice ); |
|
| 80 | - if ( empty( $subscription ) ) { |
|
| 79 | + $subscription = wpinv_get_subscription($invoice); |
|
| 80 | + if (empty($subscription)) { |
|
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Schedule an action to run when the subscription expires. |
| 85 | 85 | $action_id = as_schedule_single_action( |
| 86 | - strtotime( $subscription->expiration ), |
|
| 86 | + strtotime($subscription->expiration), |
|
| 87 | 87 | 'wpinv_renew_manual_subscription_profile', |
| 88 | - array( $invoice->get_id() ), |
|
| 88 | + array($invoice->get_id()), |
|
| 89 | 89 | 'invoicing' |
| 90 | 90 | ); |
| 91 | 91 | |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param int $invoice_id Invoice. |
| 107 | 107 | */ |
| 108 | - public function renew_manual_subscription_profile( $invoice_id ) { |
|
| 108 | + public function renew_manual_subscription_profile($invoice_id) { |
|
| 109 | 109 | |
| 110 | 110 | // Retrieve the subscription. |
| 111 | - $subscription = wpinv_get_subscription( $invoice_id ); |
|
| 112 | - if ( empty( $subscription ) ) { |
|
| 111 | + $subscription = wpinv_get_subscription($invoice_id); |
|
| 112 | + if (empty($subscription)) { |
|
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -117,34 +117,34 @@ discard block |
||
| 117 | 117 | $times_billed = $subscription->get_times_billed(); |
| 118 | 118 | $max_bills = $subscription->bill_times; |
| 119 | 119 | |
| 120 | - if ( empty( $max_bills ) || $max_bills > $times_billed ) { |
|
| 120 | + if (empty($max_bills) || $max_bills > $times_billed) { |
|
| 121 | 121 | |
| 122 | 122 | // Retrieve the invoice. |
| 123 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 123 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 124 | 124 | |
| 125 | 125 | // Renew the subscription. |
| 126 | - $subscription->add_payment( array( |
|
| 126 | + $subscription->add_payment(array( |
|
| 127 | 127 | 'amount' => $subscription->recurring_amount, |
| 128 | 128 | 'transaction_id' => $invoice->generate_key(), |
| 129 | 129 | 'gateway' => $this->id |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Renew/Complete the subscription. |
| 135 | 135 | $subscription->renew(); |
| 136 | 136 | |
| 137 | - if ( 'completed' != $subscription->status ) { |
|
| 137 | + if ('completed' != $subscription->status) { |
|
| 138 | 138 | |
| 139 | 139 | // Schedule an action to run when the subscription expires. |
| 140 | 140 | $action_id = as_schedule_single_action( |
| 141 | - strtotime( $subscription->expiration ), |
|
| 141 | + strtotime($subscription->expiration), |
|
| 142 | 142 | 'wpinv_renew_manual_subscription_profile', |
| 143 | - array( $invoice_id ), |
|
| 143 | + array($invoice_id), |
|
| 144 | 144 | 'invoicing' |
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - $subscription->update( array( 'profile_id' => $action_id, ) ); |
|
| 147 | + $subscription->update(array('profile_id' => $action_id,)); |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
@@ -13,72 +13,72 @@ discard block |
||
| 13 | 13 | class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $id = 'paypal'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * An array of features that this gateway supports. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 23 | + * An array of features that this gateway supports. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | 27 | protected $supports = array( 'subscription' ); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Payment method order. |
|
| 31 | - * |
|
| 32 | - * @var int |
|
| 33 | - */ |
|
| 30 | + * Payment method order. |
|
| 31 | + * |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | 34 | public $order = 1; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Stores line items to send to PayPal. |
|
| 38 | - * |
|
| 39 | - * @var array |
|
| 40 | - */ |
|
| 37 | + * Stores line items to send to PayPal. |
|
| 38 | + * |
|
| 39 | + * @var array |
|
| 40 | + */ |
|
| 41 | 41 | protected $line_items = array(); |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Endpoint for requests from PayPal. |
|
| 45 | - * |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - protected $notify_url; |
|
| 44 | + * Endpoint for requests from PayPal. |
|
| 45 | + * |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + protected $notify_url; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Endpoint for requests to PayPal. |
|
| 52 | - * |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 50 | + /** |
|
| 51 | + * Endpoint for requests to PayPal. |
|
| 52 | + * |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | 55 | protected $endpoint; |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * Currencies this gateway is allowed for. |
|
| 59 | - * |
|
| 60 | - * @var array |
|
| 61 | - */ |
|
| 62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 58 | + * Currencies this gateway is allowed for. |
|
| 59 | + * |
|
| 60 | + * @var array |
|
| 61 | + */ |
|
| 62 | + public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * URL to view a transaction. |
|
| 66 | - * |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 65 | + * URL to view a transaction. |
|
| 66 | + * |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | 69 | public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s'; |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * URL to view a subscription. |
|
| 73 | - * |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
| 72 | + * URL to view a subscription. |
|
| 73 | + * |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Class constructor. |
|
| 80 | - */ |
|
| 81 | - public function __construct() { |
|
| 79 | + * Class constructor. |
|
| 80 | + */ |
|
| 81 | + public function __construct() { |
|
| 82 | 82 | |
| 83 | 83 | $this->title = __( 'PayPal Standard', 'invoicing' ); |
| 84 | 84 | $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * Process Payment. |
|
| 96 | - * |
|
| 97 | - * |
|
| 98 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 99 | - * @param array $submission_data Posted checkout fields. |
|
| 100 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 101 | - * @return array |
|
| 102 | - */ |
|
| 103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 95 | + * Process Payment. |
|
| 96 | + * |
|
| 97 | + * |
|
| 98 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 99 | + * @param array $submission_data Posted checkout fields. |
|
| 100 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 101 | + * @return array |
|
| 102 | + */ |
|
| 103 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 104 | 104 | |
| 105 | 105 | // Get redirect url. |
| 106 | 106 | $paypal_redirect = $this->get_request_url( $invoice ); |
@@ -123,15 +123,15 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * Get the PayPal request URL for an invoice. |
|
| 127 | - * |
|
| 128 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - public function get_request_url( $invoice ) { |
|
| 126 | + * Get the PayPal request URL for an invoice. |
|
| 127 | + * |
|
| 128 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + public function get_request_url( $invoice ) { |
|
| 132 | 132 | |
| 133 | 133 | // Endpoint for this request |
| 134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 134 | + $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 135 | 135 | |
| 136 | 136 | // Retrieve paypal args. |
| 137 | 137 | $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
@@ -144,44 +144,44 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | return add_query_arg( $paypal_args, $this->endpoint ); |
| 146 | 146 | |
| 147 | - } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Get PayPal Args for passing to PP. |
|
| 151 | - * |
|
| 152 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 153 | - * @return array |
|
| 154 | - */ |
|
| 155 | - protected function get_paypal_args( $invoice ) { |
|
| 150 | + * Get PayPal Args for passing to PP. |
|
| 151 | + * |
|
| 152 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 153 | + * @return array |
|
| 154 | + */ |
|
| 155 | + protected function get_paypal_args( $invoice ) { |
|
| 156 | 156 | |
| 157 | 157 | // Whether or not to send the line items as one item. |
| 158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice ); |
|
| 159 | - |
|
| 160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 161 | - $force_one_line_item = true; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $paypal_args = apply_filters( |
|
| 165 | - 'getpaid_paypal_args', |
|
| 166 | - array_merge( |
|
| 167 | - $this->get_transaction_args( $invoice ), |
|
| 168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 169 | - ), |
|
| 170 | - $invoice |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 158 | + $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice ); |
|
| 159 | + |
|
| 160 | + if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 161 | + $force_one_line_item = true; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $paypal_args = apply_filters( |
|
| 165 | + 'getpaid_paypal_args', |
|
| 166 | + array_merge( |
|
| 167 | + $this->get_transaction_args( $invoice ), |
|
| 168 | + $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 169 | + ), |
|
| 170 | + $invoice |
|
| 171 | + ); |
|
| 172 | + |
|
| 173 | + return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Get transaction args for paypal request. |
|
| 178 | - * |
|
| 179 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | - * @return array |
|
| 181 | - */ |
|
| 182 | - protected function get_transaction_args( $invoice ) { |
|
| 177 | + * Get transaction args for paypal request. |
|
| 178 | + * |
|
| 179 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | + * @return array |
|
| 181 | + */ |
|
| 182 | + protected function get_transaction_args( $invoice ) { |
|
| 183 | 183 | |
| 184 | - return array( |
|
| 184 | + return array( |
|
| 185 | 185 | 'cmd' => '_cart', |
| 186 | 186 | 'business' => wpinv_get_option( 'paypal_email', false ), |
| 187 | 187 | 'no_shipping' => '1', |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | - * Get line item args for paypal request. |
|
| 210 | - * |
|
| 211 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 212 | - * @param bool $force_one_line_item Create only one item for this invoice. |
|
| 213 | - * @return array |
|
| 214 | - */ |
|
| 215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 209 | + * Get line item args for paypal request. |
|
| 210 | + * |
|
| 211 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 212 | + * @param bool $force_one_line_item Create only one item for this invoice. |
|
| 213 | + * @return array |
|
| 214 | + */ |
|
| 215 | + protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 216 | 216 | |
| 217 | 217 | // Maybe send invoice as a single item. |
| 218 | - if ( $force_one_line_item ) { |
|
| 218 | + if ( $force_one_line_item ) { |
|
| 219 | 219 | return $this->get_line_item_args_single_item( $invoice ); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -235,129 +235,129 @@ discard block |
||
| 235 | 235 | $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 238 | + return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * Get line item args for paypal request as a single line item. |
|
| 244 | - * |
|
| 245 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 246 | - * @return array |
|
| 247 | - */ |
|
| 248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
| 249 | - $this->delete_line_items(); |
|
| 243 | + * Get line item args for paypal request as a single line item. |
|
| 244 | + * |
|
| 245 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 246 | + * @return array |
|
| 247 | + */ |
|
| 248 | + protected function get_line_item_args_single_item( $invoice ) { |
|
| 249 | + $this->delete_line_items(); |
|
| 250 | 250 | |
| 251 | 251 | $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
| 252 | - $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() ); |
|
| 252 | + $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() ); |
|
| 253 | 253 | |
| 254 | - return $this->get_line_items(); |
|
| 254 | + return $this->get_line_items(); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * Return all line items. |
|
| 259 | - */ |
|
| 260 | - protected function get_line_items() { |
|
| 261 | - return $this->line_items; |
|
| 262 | - } |
|
| 258 | + * Return all line items. |
|
| 259 | + */ |
|
| 260 | + protected function get_line_items() { |
|
| 261 | + return $this->line_items; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Remove all line items. |
|
| 266 | - */ |
|
| 267 | - protected function delete_line_items() { |
|
| 268 | - $this->line_items = array(); |
|
| 265 | + * Remove all line items. |
|
| 266 | + */ |
|
| 267 | + protected function delete_line_items() { |
|
| 268 | + $this->line_items = array(); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | - * Prepare line items to send to paypal. |
|
| 273 | - * |
|
| 274 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 275 | - */ |
|
| 276 | - protected function prepare_line_items( $invoice ) { |
|
| 277 | - $this->delete_line_items(); |
|
| 278 | - |
|
| 279 | - // Items. |
|
| 280 | - foreach ( $invoice->get_items() as $item ) { |
|
| 281 | - $amount = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total(); |
|
| 282 | - $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
| 283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 272 | + * Prepare line items to send to paypal. |
|
| 273 | + * |
|
| 274 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 275 | + */ |
|
| 276 | + protected function prepare_line_items( $invoice ) { |
|
| 277 | + $this->delete_line_items(); |
|
| 278 | + |
|
| 279 | + // Items. |
|
| 280 | + foreach ( $invoice->get_items() as $item ) { |
|
| 281 | + $amount = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total(); |
|
| 282 | + $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
| 283 | + $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Fees. |
| 287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 287 | + foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 288 | 288 | $this->add_line_item( $fee, 1, $data['amount'] ); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | - * Add PayPal Line Item. |
|
| 295 | - * |
|
| 296 | - * @param string $item_name Item name. |
|
| 297 | - * @param int $quantity Item quantity. |
|
| 298 | - * @param float $amount Amount. |
|
| 299 | - * @param string $item_number Item number. |
|
| 300 | - */ |
|
| 301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 303 | - |
|
| 304 | - $item = apply_filters( |
|
| 305 | - 'getpaid_paypal_line_item', |
|
| 306 | - array( |
|
| 307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 308 | - 'quantity' => (int) $quantity, |
|
| 309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 310 | - 'item_number' => $item_number, |
|
| 311 | - ), |
|
| 312 | - $item_name, |
|
| 313 | - $quantity, |
|
| 314 | - $amount, |
|
| 315 | - $item_number |
|
| 316 | - ); |
|
| 317 | - |
|
| 318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 294 | + * Add PayPal Line Item. |
|
| 295 | + * |
|
| 296 | + * @param string $item_name Item name. |
|
| 297 | + * @param int $quantity Item quantity. |
|
| 298 | + * @param float $amount Amount. |
|
| 299 | + * @param string $item_number Item number. |
|
| 300 | + */ |
|
| 301 | + protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | + $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 303 | + |
|
| 304 | + $item = apply_filters( |
|
| 305 | + 'getpaid_paypal_line_item', |
|
| 306 | + array( |
|
| 307 | + 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 308 | + 'quantity' => (int) $quantity, |
|
| 309 | + 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 310 | + 'item_number' => $item_number, |
|
| 311 | + ), |
|
| 312 | + $item_name, |
|
| 313 | + $quantity, |
|
| 314 | + $amount, |
|
| 315 | + $item_number |
|
| 316 | + ); |
|
| 317 | + |
|
| 318 | + $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 319 | 319 | $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
| 320 | 320 | |
| 321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
| 322 | - $this->line_items[ 'amount_' . $index ] = $item['amount']; |
|
| 323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 322 | + $this->line_items[ 'amount_' . $index ] = $item['amount']; |
|
| 323 | + $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | - * If the default request with line items is too long, generate a new one with only one line item. |
|
| 328 | - * |
|
| 329 | - * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
| 330 | - * |
|
| 331 | - * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
| 332 | - * @param array $paypal_args Arguments sent to Paypal in the request. |
|
| 333 | - * @return array |
|
| 334 | - */ |
|
| 335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 336 | - $max_paypal_length = 2083; |
|
| 337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 338 | - |
|
| 339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 340 | - return $paypal_args; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return apply_filters( |
|
| 344 | - 'getpaid_paypal_args', |
|
| 345 | - array_merge( |
|
| 346 | - $this->get_transaction_args( $invoice ), |
|
| 347 | - $this->get_line_item_args( $invoice, true ) |
|
| 348 | - ), |
|
| 349 | - $invoice |
|
| 350 | - ); |
|
| 327 | + * If the default request with line items is too long, generate a new one with only one line item. |
|
| 328 | + * |
|
| 329 | + * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
| 330 | + * |
|
| 331 | + * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
| 332 | + * @param array $paypal_args Arguments sent to Paypal in the request. |
|
| 333 | + * @return array |
|
| 334 | + */ |
|
| 335 | + protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 336 | + $max_paypal_length = 2083; |
|
| 337 | + $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 338 | + |
|
| 339 | + if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 340 | + return $paypal_args; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return apply_filters( |
|
| 344 | + 'getpaid_paypal_args', |
|
| 345 | + array_merge( |
|
| 346 | + $this->get_transaction_args( $invoice ), |
|
| 347 | + $this->get_line_item_args( $invoice, true ) |
|
| 348 | + ), |
|
| 349 | + $invoice |
|
| 350 | + ); |
|
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | - * Processes recurring invoices. |
|
| 356 | - * |
|
| 357 | - * @param array $paypal_args PayPal args. |
|
| 358 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 359 | - */ |
|
| 360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
| 355 | + * Processes recurring invoices. |
|
| 356 | + * |
|
| 357 | + * @param array $paypal_args PayPal args. |
|
| 358 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 359 | + */ |
|
| 360 | + public function process_subscription( $paypal_args, $invoice ) { |
|
| 361 | 361 | |
| 362 | 362 | // Make sure this is a subscription. |
| 363 | 363 | if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) { |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
| 384 | 384 | |
| 385 | - // Trial period length. |
|
| 386 | - $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
| 385 | + // Trial period length. |
|
| 386 | + $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
| 387 | 387 | |
| 388 | - // Trial period. |
|
| 389 | - $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
| 388 | + // Trial period. |
|
| 389 | + $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
| 390 | 390 | |
| 391 | 391 | } else if ( $initial_amount != $recurring_amount ) { |
| 392 | 392 | |
@@ -409,40 +409,40 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // We have a recurring payment |
| 412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 412 | + if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 413 | 413 | |
| 414 | - // Subscription price |
|
| 415 | - $paypal_args['a3'] = $recurring_amount; |
|
| 414 | + // Subscription price |
|
| 415 | + $paypal_args['a3'] = $recurring_amount; |
|
| 416 | 416 | |
| 417 | - // Subscription duration |
|
| 418 | - $paypal_args['p3'] = $interval; |
|
| 417 | + // Subscription duration |
|
| 418 | + $paypal_args['p3'] = $interval; |
|
| 419 | 419 | |
| 420 | - // Subscription period |
|
| 421 | - $paypal_args['t3'] = $period; |
|
| 420 | + // Subscription period |
|
| 421 | + $paypal_args['t3'] = $period; |
|
| 422 | 422 | |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Recurring payments |
| 426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 426 | + if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 427 | 427 | |
| 428 | - // Non-recurring payments |
|
| 429 | - $paypal_args['src'] = 0; |
|
| 428 | + // Non-recurring payments |
|
| 429 | + $paypal_args['src'] = 0; |
|
| 430 | 430 | |
| 431 | - } else { |
|
| 431 | + } else { |
|
| 432 | 432 | |
| 433 | - $paypal_args['src'] = 1; |
|
| 433 | + $paypal_args['src'] = 1; |
|
| 434 | 434 | |
| 435 | - if ( $bill_times > 0 ) { |
|
| 435 | + if ( $bill_times > 0 ) { |
|
| 436 | 436 | |
| 437 | - // An initial period is being used to charge a sign-up fee |
|
| 438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 439 | - $bill_times--; |
|
| 440 | - } |
|
| 437 | + // An initial period is being used to charge a sign-up fee |
|
| 438 | + if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 439 | + $bill_times--; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | // Make sure it's not over the max of 52 |
| 443 | 443 | $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
| 444 | 444 | |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | // Force return URL so that order description & instructions display |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return apply_filters( |
| 461 | - 'getpaid_paypal_subscription_args', |
|
| 462 | - $paypal_args, |
|
| 463 | - $invoice |
|
| 461 | + 'getpaid_paypal_subscription_args', |
|
| 462 | + $paypal_args, |
|
| 463 | + $invoice |
|
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | - * Processes ipns and marks payments as complete. |
|
| 470 | - * |
|
| 471 | - * @return void |
|
| 472 | - */ |
|
| 473 | - public function verify_ipn() { |
|
| 469 | + * Processes ipns and marks payments as complete. |
|
| 470 | + * |
|
| 471 | + * @return void |
|
| 472 | + */ |
|
| 473 | + public function verify_ipn() { |
|
| 474 | 474 | |
| 475 | 475 | // Validate the IPN. |
| 476 | 476 | if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
| 477 | - wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) ); |
|
| 478 | - } |
|
| 477 | + wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) ); |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | 480 | // Process the IPN. |
| 481 | 481 | $posted = wp_unslash( $_POST ); |
@@ -483,13 +483,13 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | if ( $invoice && $this->id == $invoice->get_gateway() ) { |
| 485 | 485 | |
| 486 | - $posted['payment_status'] = strtolower( $posted['payment_status'] ); |
|
| 486 | + $posted['payment_status'] = strtolower( $posted['payment_status'] ); |
|
| 487 | 487 | |
| 488 | 488 | wpinv_error_log( 'Found invoice #' . $invoice->get_number() ); |
| 489 | 489 | wpinv_error_log( 'Payment status:' . $posted['payment_status'] ); |
| 490 | 490 | |
| 491 | - if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) { |
|
| 492 | - call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted ); |
|
| 491 | + if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) { |
|
| 492 | + call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted ); |
|
| 493 | 493 | } else { |
| 494 | 494 | wpinv_error_log( 'Aborting, Invalid type:' . $posted['txn_type'] ); |
| 495 | 495 | } |
@@ -501,33 +501,33 @@ discard block |
||
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
| 504 | - * Check PayPal IPN validity. |
|
| 505 | - */ |
|
| 506 | - public function validate_ipn() { |
|
| 507 | - |
|
| 508 | - wpinv_error_log( 'Validating PayPal IPN response' ); |
|
| 509 | - |
|
| 510 | - // Get received values from post data. |
|
| 511 | - $validate_ipn = wp_unslash( $_POST ); |
|
| 512 | - $validate_ipn['cmd'] = '_notify-validate'; |
|
| 513 | - |
|
| 514 | - // Send back post vars to paypal. |
|
| 515 | - $params = array( |
|
| 516 | - 'body' => $validate_ipn, |
|
| 517 | - 'timeout' => 60, |
|
| 518 | - 'httpversion' => '1.1', |
|
| 519 | - 'compress' => false, |
|
| 520 | - 'decompress' => false, |
|
| 521 | - 'user-agent' => 'GetPaid/' . WPINV_VERSION, |
|
| 522 | - ); |
|
| 504 | + * Check PayPal IPN validity. |
|
| 505 | + */ |
|
| 506 | + public function validate_ipn() { |
|
| 507 | + |
|
| 508 | + wpinv_error_log( 'Validating PayPal IPN response' ); |
|
| 509 | + |
|
| 510 | + // Get received values from post data. |
|
| 511 | + $validate_ipn = wp_unslash( $_POST ); |
|
| 512 | + $validate_ipn['cmd'] = '_notify-validate'; |
|
| 513 | + |
|
| 514 | + // Send back post vars to paypal. |
|
| 515 | + $params = array( |
|
| 516 | + 'body' => $validate_ipn, |
|
| 517 | + 'timeout' => 60, |
|
| 518 | + 'httpversion' => '1.1', |
|
| 519 | + 'compress' => false, |
|
| 520 | + 'decompress' => false, |
|
| 521 | + 'user-agent' => 'GetPaid/' . WPINV_VERSION, |
|
| 522 | + ); |
|
| 523 | 523 | |
| 524 | - // Post back to get a response. |
|
| 525 | - $response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
| 524 | + // Post back to get a response. |
|
| 525 | + $response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
| 526 | 526 | |
| 527 | 527 | // Check to see if the request was valid. |
| 528 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) { |
|
| 528 | + if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) { |
|
| 529 | 529 | wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' ); |
| 530 | - return true; |
|
| 530 | + return true; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | if ( is_wp_error( $response ) ) { |
@@ -541,63 +541,63 @@ discard block |
||
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
| 544 | - * Check currency from IPN matches the invoice. |
|
| 545 | - * |
|
| 546 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 547 | - * @param string $currency currency to validate. |
|
| 548 | - */ |
|
| 549 | - protected function validate_ipn_currency( $invoice, $currency ) { |
|
| 550 | - if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) { |
|
| 544 | + * Check currency from IPN matches the invoice. |
|
| 545 | + * |
|
| 546 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 547 | + * @param string $currency currency to validate. |
|
| 548 | + */ |
|
| 549 | + protected function validate_ipn_currency( $invoice, $currency ) { |
|
| 550 | + if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) { |
|
| 551 | 551 | wpinv_record_gateway_error( 'IPN Error', "Currencies do not match: {$currency} instead of {$invoice->get_currency()}" ); |
| 552 | 552 | |
| 553 | - /* translators: %s: currency code. */ |
|
| 554 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) ); |
|
| 555 | - exit; |
|
| 556 | - } |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * Check payment amount from IPN matches the invoice. |
|
| 561 | - * |
|
| 562 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 563 | - * @param float $amount amount to validate. |
|
| 564 | - */ |
|
| 565 | - protected function validate_ipn_amount( $invoice, $amount ) { |
|
| 566 | - if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) { |
|
| 553 | + /* translators: %s: currency code. */ |
|
| 554 | + $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) ); |
|
| 555 | + exit; |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * Check payment amount from IPN matches the invoice. |
|
| 561 | + * |
|
| 562 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 563 | + * @param float $amount amount to validate. |
|
| 564 | + */ |
|
| 565 | + protected function validate_ipn_amount( $invoice, $amount ) { |
|
| 566 | + if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) { |
|
| 567 | 567 | wpinv_record_gateway_error( 'IPN Error', "Amounts do not match: {$amount} instead of {$invoice->get_total()}" ); |
| 568 | 568 | |
| 569 | - /* translators: %s: Amount. */ |
|
| 570 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) ); |
|
| 571 | - exit; |
|
| 572 | - } |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * Verify receiver email from PayPal. |
|
| 577 | - * |
|
| 578 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 579 | - * @param string $receiver_email Email to validate. |
|
| 580 | - */ |
|
| 581 | - protected function validate_ipn_receiver_email( $invoice, $receiver_email ) { |
|
| 569 | + /* translators: %s: Amount. */ |
|
| 570 | + $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) ); |
|
| 571 | + exit; |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * Verify receiver email from PayPal. |
|
| 577 | + * |
|
| 578 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 579 | + * @param string $receiver_email Email to validate. |
|
| 580 | + */ |
|
| 581 | + protected function validate_ipn_receiver_email( $invoice, $receiver_email ) { |
|
| 582 | 582 | $paypal_email = wpinv_get_option( 'paypal_email' ); |
| 583 | 583 | |
| 584 | - if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) { |
|
| 584 | + if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) { |
|
| 585 | 585 | wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" ); |
| 586 | 586 | |
| 587 | - /* translators: %s: email address . */ |
|
| 588 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) ); |
|
| 589 | - exit; |
|
| 587 | + /* translators: %s: email address . */ |
|
| 588 | + $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) ); |
|
| 589 | + exit; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - } |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | 594 | /** |
| 595 | - * Handles one time payments. |
|
| 596 | - * |
|
| 597 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 598 | - * @param array $posted Posted data. |
|
| 599 | - */ |
|
| 600 | - protected function ipn_txn_web_accept( $invoice, $posted ) { |
|
| 595 | + * Handles one time payments. |
|
| 596 | + * |
|
| 597 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 598 | + * @param array $posted Posted data. |
|
| 599 | + */ |
|
| 600 | + protected function ipn_txn_web_accept( $invoice, $posted ) { |
|
| 601 | 601 | |
| 602 | 602 | // Collect payment details |
| 603 | 603 | $payment_status = strtolower( $posted['payment_status'] ); |
@@ -658,27 +658,27 @@ discard block |
||
| 658 | 658 | // Process failures. |
| 659 | 659 | |
| 660 | 660 | /* translators: %s: payment status. */ |
| 661 | - $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) ); |
|
| 662 | - |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * Handles one time payments. |
|
| 667 | - * |
|
| 668 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 669 | - * @param array $posted Posted data. |
|
| 670 | - */ |
|
| 671 | - protected function ipn_txn_cart( $invoice, $posted ) { |
|
| 672 | - $this->ipn_txn_web_accept( $invoice, $posted ); |
|
| 661 | + $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) ); |
|
| 662 | + |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * Handles one time payments. |
|
| 667 | + * |
|
| 668 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 669 | + * @param array $posted Posted data. |
|
| 670 | + */ |
|
| 671 | + protected function ipn_txn_cart( $invoice, $posted ) { |
|
| 672 | + $this->ipn_txn_web_accept( $invoice, $posted ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** |
| 676 | - * Handles subscription sign ups. |
|
| 677 | - * |
|
| 678 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 679 | - * @param array $posted Posted data. |
|
| 680 | - */ |
|
| 681 | - protected function ipn_txn_subscr_signup( $invoice, $posted ) { |
|
| 676 | + * Handles subscription sign ups. |
|
| 677 | + * |
|
| 678 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 679 | + * @param array $posted Posted data. |
|
| 680 | + */ |
|
| 681 | + protected function ipn_txn_subscr_signup( $invoice, $posted ) { |
|
| 682 | 682 | |
| 683 | 683 | // Make sure the invoice has a subscription. |
| 684 | 684 | $subscription = wpinv_get_subscription( $invoice ); |
@@ -717,12 +717,12 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | /** |
| 720 | - * Handles subscription renewals. |
|
| 721 | - * |
|
| 722 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 723 | - * @param array $posted Posted data. |
|
| 724 | - */ |
|
| 725 | - protected function ipn_txn_subscr_payment( $invoice, $posted ) { |
|
| 720 | + * Handles subscription renewals. |
|
| 721 | + * |
|
| 722 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 723 | + * @param array $posted Posted data. |
|
| 724 | + */ |
|
| 725 | + protected function ipn_txn_subscr_payment( $invoice, $posted ) { |
|
| 726 | 726 | |
| 727 | 727 | // Make sure the invoice has a subscription. |
| 728 | 728 | $subscription = wpinv_get_subscription( $invoice ); |
@@ -765,12 +765,12 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
| 768 | - * Handles subscription cancelations. |
|
| 769 | - * |
|
| 770 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 771 | - * @param array $posted Posted data. |
|
| 772 | - */ |
|
| 773 | - protected function ipn_txn_subscr_cancel( $invoice, $posted ) { |
|
| 768 | + * Handles subscription cancelations. |
|
| 769 | + * |
|
| 770 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 771 | + * @param array $posted Posted data. |
|
| 772 | + */ |
|
| 773 | + protected function ipn_txn_subscr_cancel( $invoice, $posted ) { |
|
| 774 | 774 | |
| 775 | 775 | if ( $subscription = wpinv_get_subscription( $invoice ) ) { |
| 776 | 776 | $subscription->cancel(); |
@@ -779,12 +779,12 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
| 782 | - * Handles subscription completions. |
|
| 783 | - * |
|
| 784 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 785 | - * @param array $posted Posted data. |
|
| 786 | - */ |
|
| 787 | - protected function ipn_txn_subscr_eot( $invoice, $posted ) { |
|
| 782 | + * Handles subscription completions. |
|
| 783 | + * |
|
| 784 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 785 | + * @param array $posted Posted data. |
|
| 786 | + */ |
|
| 787 | + protected function ipn_txn_subscr_eot( $invoice, $posted ) { |
|
| 788 | 788 | |
| 789 | 789 | if ( $subscription = wpinv_get_subscription( $invoice ) ) { |
| 790 | 790 | $subscription->complete(); |
@@ -793,12 +793,12 @@ discard block |
||
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
| 796 | - * Handles subscription fails. |
|
| 797 | - * |
|
| 798 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 799 | - * @param array $posted Posted data. |
|
| 800 | - */ |
|
| 801 | - protected function ipn_txn_subscr_failed( $invoice, $posted ) { |
|
| 796 | + * Handles subscription fails. |
|
| 797 | + * |
|
| 798 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 799 | + * @param array $posted Posted data. |
|
| 800 | + */ |
|
| 801 | + protected function ipn_txn_subscr_failed( $invoice, $posted ) { |
|
| 802 | 802 | |
| 803 | 803 | if ( $subscription = wpinv_get_subscription( $invoice ) ) { |
| 804 | 804 | $subscription->failing(); |
@@ -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 | * Paypal Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription' ); |
|
| 27 | + protected $supports = array('subscription'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @var array |
| 61 | 61 | */ |
| 62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 62 | + public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR'); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * URL to view a transaction. |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function __construct() { |
| 82 | 82 | |
| 83 | - $this->title = __( 'PayPal Standard', 'invoicing' ); |
|
| 84 | - $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
|
| 85 | - $this->order_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
|
| 86 | - $this->notify_url = wpinv_get_ipn_url( 'paypal' ); |
|
| 83 | + $this->title = __('PayPal Standard', 'invoicing'); |
|
| 84 | + $this->method_title = __('PayPal Standard', 'invoicing'); |
|
| 85 | + $this->order_button_text = __('Proceed to PayPal', 'invoicing'); |
|
| 86 | + $this->notify_url = wpinv_get_ipn_url('paypal'); |
|
| 87 | 87 | |
| 88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 89 | - add_filter( 'wpinv_gateway_description', array( $this, 'sandbox_notice' ), 10, 2 ); |
|
| 88 | + add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2); |
|
| 89 | + add_filter('wpinv_gateway_description', array($this, 'sandbox_notice'), 10, 2); |
|
| 90 | 90 | |
| 91 | 91 | parent::__construct(); |
| 92 | 92 | } |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 101 | 101 | * @return array |
| 102 | 102 | */ |
| 103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 103 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 104 | 104 | |
| 105 | 105 | // Get redirect url. |
| 106 | - $paypal_redirect = $this->get_request_url( $invoice ); |
|
| 106 | + $paypal_redirect = $this->get_request_url($invoice); |
|
| 107 | 107 | |
| 108 | 108 | // Add a note about the request url. |
| 109 | 109 | $invoice->add_note( |
| 110 | 110 | sprintf( |
| 111 | - __( 'Redirecting to PayPal: %s', 'invoicing' ), |
|
| 112 | - esc_url( $paypal_redirect ) |
|
| 111 | + __('Redirecting to PayPal: %s', 'invoicing'), |
|
| 112 | + esc_url($paypal_redirect) |
|
| 113 | 113 | ), |
| 114 | 114 | false, |
| 115 | 115 | false, |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | // Redirect to PayPal |
| 120 | - wp_redirect( $paypal_redirect ); |
|
| 120 | + wp_redirect($paypal_redirect); |
|
| 121 | 121 | exit; |
| 122 | 122 | |
| 123 | 123 | } |
@@ -128,21 +128,21 @@ discard block |
||
| 128 | 128 | * @param WPInv_Invoice $invoice Invoice object. |
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | - public function get_request_url( $invoice ) { |
|
| 131 | + public function get_request_url($invoice) { |
|
| 132 | 132 | |
| 133 | 133 | // Endpoint for this request |
| 134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 134 | + $this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 135 | 135 | |
| 136 | 136 | // Retrieve paypal args. |
| 137 | - $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
|
| 137 | + $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode'); |
|
| 138 | 138 | |
| 139 | - if ( $invoice->is_recurring() ) { |
|
| 139 | + if ($invoice->is_recurring()) { |
|
| 140 | 140 | $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US'; |
| 141 | 141 | } else { |
| 142 | 142 | $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US'; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return add_query_arg( $paypal_args, $this->endpoint ); |
|
| 145 | + return add_query_arg($paypal_args, $this->endpoint); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -152,25 +152,25 @@ discard block |
||
| 152 | 152 | * @param WPInv_Invoice $invoice Invoice object. |
| 153 | 153 | * @return array |
| 154 | 154 | */ |
| 155 | - protected function get_paypal_args( $invoice ) { |
|
| 155 | + protected function get_paypal_args($invoice) { |
|
| 156 | 156 | |
| 157 | 157 | // Whether or not to send the line items as one item. |
| 158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice ); |
|
| 158 | + $force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', false, $invoice); |
|
| 159 | 159 | |
| 160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 160 | + if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) { |
|
| 161 | 161 | $force_one_line_item = true; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $paypal_args = apply_filters( |
| 165 | 165 | 'getpaid_paypal_args', |
| 166 | 166 | array_merge( |
| 167 | - $this->get_transaction_args( $invoice ), |
|
| 168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 167 | + $this->get_transaction_args($invoice), |
|
| 168 | + $this->get_line_item_args($invoice, $force_one_line_item) |
|
| 169 | 169 | ), |
| 170 | 170 | $invoice |
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 173 | + return $this->fix_request_length($invoice, $paypal_args); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | * @param WPInv_Invoice $invoice Invoice object. |
| 180 | 180 | * @return array |
| 181 | 181 | */ |
| 182 | - protected function get_transaction_args( $invoice ) { |
|
| 182 | + protected function get_transaction_args($invoice) { |
|
| 183 | 183 | |
| 184 | 184 | return array( |
| 185 | 185 | 'cmd' => '_cart', |
| 186 | - 'business' => wpinv_get_option( 'paypal_email', false ), |
|
| 186 | + 'business' => wpinv_get_option('paypal_email', false), |
|
| 187 | 187 | 'no_shipping' => '1', |
| 188 | 188 | 'shipping' => '0', |
| 189 | 189 | 'no_note' => '1', |
@@ -191,16 +191,16 @@ discard block |
||
| 191 | 191 | 'rm' => is_ssl() ? 2 : 1, |
| 192 | 192 | 'upload' => 1, |
| 193 | 193 | 'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal |
| 194 | - 'return' => esc_url_raw( $this->get_return_url( $invoice ) ), |
|
| 195 | - 'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ), |
|
| 196 | - 'notify_url' => getpaid_limit_length( $this->notify_url, 255 ), |
|
| 197 | - 'invoice' => getpaid_limit_length( $invoice->get_number(), 127 ), |
|
| 194 | + 'return' => esc_url_raw($this->get_return_url($invoice)), |
|
| 195 | + 'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()), |
|
| 196 | + 'notify_url' => getpaid_limit_length($this->notify_url, 255), |
|
| 197 | + 'invoice' => getpaid_limit_length($invoice->get_number(), 127), |
|
| 198 | 198 | 'custom' => $invoice->get_id(), |
| 199 | - 'first_name' => getpaid_limit_length( $invoice->get_first_name(), 32 ), |
|
| 200 | - 'last_name' => getpaid_limit_length( $invoice->get_last_name(), 64 ), |
|
| 201 | - 'country' => getpaid_limit_length( $invoice->get_country(), 2 ), |
|
| 202 | - 'email' => getpaid_limit_length( $invoice->get_email(), 127 ), |
|
| 203 | - 'cbt' => get_bloginfo( 'name' ) |
|
| 199 | + 'first_name' => getpaid_limit_length($invoice->get_first_name(), 32), |
|
| 200 | + 'last_name' => getpaid_limit_length($invoice->get_last_name(), 64), |
|
| 201 | + 'country' => getpaid_limit_length($invoice->get_country(), 2), |
|
| 202 | + 'email' => getpaid_limit_length($invoice->get_email(), 127), |
|
| 203 | + 'cbt' => get_bloginfo('name') |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | } |
@@ -212,30 +212,30 @@ discard block |
||
| 212 | 212 | * @param bool $force_one_line_item Create only one item for this invoice. |
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 215 | + protected function get_line_item_args($invoice, $force_one_line_item = false) { |
|
| 216 | 216 | |
| 217 | 217 | // Maybe send invoice as a single item. |
| 218 | - if ( $force_one_line_item ) { |
|
| 219 | - return $this->get_line_item_args_single_item( $invoice ); |
|
| 218 | + if ($force_one_line_item) { |
|
| 219 | + return $this->get_line_item_args_single_item($invoice); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // Send each line item individually. |
| 223 | 223 | $line_item_args = array(); |
| 224 | 224 | |
| 225 | 225 | // Prepare line items. |
| 226 | - $this->prepare_line_items( $invoice ); |
|
| 226 | + $this->prepare_line_items($invoice); |
|
| 227 | 227 | |
| 228 | 228 | // Add taxes to the cart |
| 229 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
| 230 | - $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 ); |
|
| 229 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
| 230 | + $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Add discount. |
| 234 | - if ( $invoice->get_total_discount() > 0 ) { |
|
| 235 | - $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
|
| 234 | + if ($invoice->get_total_discount() > 0) { |
|
| 235 | + $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 238 | + return array_merge($line_item_args, $this->get_line_items()); |
|
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
@@ -245,11 +245,11 @@ discard block |
||
| 245 | 245 | * @param WPInv_Invoice $invoice Invoice object. |
| 246 | 246 | * @return array |
| 247 | 247 | */ |
| 248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
| 248 | + protected function get_line_item_args_single_item($invoice) { |
|
| 249 | 249 | $this->delete_line_items(); |
| 250 | 250 | |
| 251 | - $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 252 | - $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() ); |
|
| 251 | + $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 252 | + $this->add_line_item($item_name, 1, wpinv_sanitize_amount((float) $invoice->get_total(), 2), $invoice->get_id()); |
|
| 253 | 253 | |
| 254 | 254 | return $this->get_line_items(); |
| 255 | 255 | } |
@@ -273,19 +273,19 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @param WPInv_Invoice $invoice Invoice object. |
| 275 | 275 | */ |
| 276 | - protected function prepare_line_items( $invoice ) { |
|
| 276 | + protected function prepare_line_items($invoice) { |
|
| 277 | 277 | $this->delete_line_items(); |
| 278 | 278 | |
| 279 | 279 | // Items. |
| 280 | - foreach ( $invoice->get_items() as $item ) { |
|
| 280 | + foreach ($invoice->get_items() as $item) { |
|
| 281 | 281 | $amount = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total(); |
| 282 | 282 | $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
| 283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 283 | + $this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id()); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Fees. |
| 287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 288 | - $this->add_line_item( $fee, 1, $data['amount'] ); |
|
| 287 | + foreach ($invoice->get_fees() as $fee => $data) { |
|
| 288 | + $this->add_line_item($fee, 1, $data['amount']); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
@@ -298,15 +298,15 @@ discard block |
||
| 298 | 298 | * @param float $amount Amount. |
| 299 | 299 | * @param string $item_number Item number. |
| 300 | 300 | */ |
| 301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 301 | + protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') { |
|
| 302 | + $index = (count($this->line_items) / 4) + 1; |
|
| 303 | 303 | |
| 304 | 304 | $item = apply_filters( |
| 305 | 305 | 'getpaid_paypal_line_item', |
| 306 | 306 | array( |
| 307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 307 | + 'item_name' => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'), |
|
| 308 | 308 | 'quantity' => (int) $quantity, |
| 309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 309 | + 'amount' => wpinv_sanitize_amount((float) $amount, 2), |
|
| 310 | 310 | 'item_number' => $item_number, |
| 311 | 311 | ), |
| 312 | 312 | $item_name, |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | $item_number |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 319 | - $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
|
| 318 | + $this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127); |
|
| 319 | + $this->line_items['quantity_' . $index] = $item['quantity']; |
|
| 320 | 320 | |
| 321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
| 322 | - $this->line_items[ 'amount_' . $index ] = $item['amount']; |
|
| 323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 322 | + $this->line_items['amount_' . $index] = $item['amount']; |
|
| 323 | + $this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * @param array $paypal_args Arguments sent to Paypal in the request. |
| 333 | 333 | * @return array |
| 334 | 334 | */ |
| 335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 335 | + protected function fix_request_length($invoice, $paypal_args) { |
|
| 336 | 336 | $max_paypal_length = 2083; |
| 337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 337 | + $query_candidate = http_build_query($paypal_args, '', '&'); |
|
| 338 | 338 | |
| 339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 339 | + if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) { |
|
| 340 | 340 | return $paypal_args; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | return apply_filters( |
| 344 | 344 | 'getpaid_paypal_args', |
| 345 | 345 | array_merge( |
| 346 | - $this->get_transaction_args( $invoice ), |
|
| 347 | - $this->get_line_item_args( $invoice, true ) |
|
| 346 | + $this->get_transaction_args($invoice), |
|
| 347 | + $this->get_line_item_args($invoice, true) |
|
| 348 | 348 | ), |
| 349 | 349 | $invoice |
| 350 | 350 | ); |
@@ -357,10 +357,10 @@ discard block |
||
| 357 | 357 | * @param array $paypal_args PayPal args. |
| 358 | 358 | * @param WPInv_Invoice $invoice Invoice object. |
| 359 | 359 | */ |
| 360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
| 360 | + public function process_subscription($paypal_args, $invoice) { |
|
| 361 | 361 | |
| 362 | 362 | // Make sure this is a subscription. |
| 363 | - if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) { |
|
| 363 | + if (!$invoice->is_recurring() || !$subscription = wpinv_get_subscription($invoice)) { |
|
| 364 | 364 | return $paypal_args; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -368,17 +368,17 @@ discard block |
||
| 368 | 368 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
| 369 | 369 | |
| 370 | 370 | // Subscription name. |
| 371 | - $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 371 | + $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 372 | 372 | |
| 373 | 373 | // Get subscription args. |
| 374 | - $period = strtoupper( substr( $subscription->period, 0, 1) ); |
|
| 374 | + $period = strtoupper(substr($subscription->period, 0, 1)); |
|
| 375 | 375 | $interval = (int) $subscription->frequency; |
| 376 | 376 | $bill_times = (int) $subscription->bill_times; |
| 377 | - $initial_amount = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 ); |
|
| 378 | - $recurring_amount = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 ); |
|
| 379 | - $subscription_item = $invoice->get_recurring( true ); |
|
| 377 | + $initial_amount = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2); |
|
| 378 | + $recurring_amount = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2); |
|
| 379 | + $subscription_item = $invoice->get_recurring(true); |
|
| 380 | 380 | |
| 381 | - if ( $subscription_item->has_free_trial() ) { |
|
| 381 | + if ($subscription_item->has_free_trial()) { |
|
| 382 | 382 | |
| 383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
| 384 | 384 | |
@@ -388,28 +388,28 @@ discard block |
||
| 388 | 388 | // Trial period. |
| 389 | 389 | $paypal_args['t1'] = $subscription_item->get_trial_period(); |
| 390 | 390 | |
| 391 | - } else if ( $initial_amount != $recurring_amount ) { |
|
| 391 | + } else if ($initial_amount != $recurring_amount) { |
|
| 392 | 392 | |
| 393 | 393 | // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period. |
| 394 | 394 | |
| 395 | - if ( 1 == $bill_times ) { |
|
| 395 | + if (1 == $bill_times) { |
|
| 396 | 396 | $param_number = 3; |
| 397 | 397 | } else { |
| 398 | 398 | $param_number = 1; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $paypal_args[ 'a' . $param_number ] = $initial_amount ? 0 : $initial_amount; |
|
| 401 | + $paypal_args['a' . $param_number] = $initial_amount ? 0 : $initial_amount; |
|
| 402 | 402 | |
| 403 | 403 | // Sign Up interval |
| 404 | - $paypal_args[ 'p' . $param_number ] = $interval; |
|
| 404 | + $paypal_args['p' . $param_number] = $interval; |
|
| 405 | 405 | |
| 406 | 406 | // Sign Up unit of duration |
| 407 | - $paypal_args[ 't' . $param_number ] = $period; |
|
| 407 | + $paypal_args['t' . $param_number] = $period; |
|
| 408 | 408 | |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // We have a recurring payment |
| 412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 412 | + if (!isset($param_number) || 1 == $param_number) { |
|
| 413 | 413 | |
| 414 | 414 | // Subscription price |
| 415 | 415 | $paypal_args['a3'] = $recurring_amount; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Recurring payments |
| 426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 426 | + if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) { |
|
| 427 | 427 | |
| 428 | 428 | // Non-recurring payments |
| 429 | 429 | $paypal_args['src'] = 0; |
@@ -432,15 +432,15 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $paypal_args['src'] = 1; |
| 434 | 434 | |
| 435 | - if ( $bill_times > 0 ) { |
|
| 435 | + if ($bill_times > 0) { |
|
| 436 | 436 | |
| 437 | 437 | // An initial period is being used to charge a sign-up fee |
| 438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 438 | + if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) { |
|
| 439 | 439 | $bill_times--; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Make sure it's not over the max of 52 |
| 443 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
| 443 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
| 444 | 444 | |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | $paypal_args['rm'] = 2; |
| 450 | 450 | |
| 451 | 451 | // Get rid of redudant items. |
| 452 | - foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) { |
|
| 452 | + foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) { |
|
| 453 | 453 | |
| 454 | - if ( isset( $paypal_args[ $arg ] ) ) { |
|
| 455 | - unset( $paypal_args[ $arg ] ); |
|
| 454 | + if (isset($paypal_args[$arg])) { |
|
| 455 | + unset($paypal_args[$arg]); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | } |
@@ -473,25 +473,25 @@ discard block |
||
| 473 | 473 | public function verify_ipn() { |
| 474 | 474 | |
| 475 | 475 | // Validate the IPN. |
| 476 | - if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
|
| 477 | - wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) ); |
|
| 476 | + if (empty($_POST) || !$this->validate_ipn()) { |
|
| 477 | + wp_die('PayPal IPN Request Failure', 'PayPal IPN', array('response' => 500)); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | // Process the IPN. |
| 481 | - $posted = wp_unslash( $_POST ); |
|
| 482 | - $invoice = wpinv_get_invoice( $posted['custom'] ); |
|
| 481 | + $posted = wp_unslash($_POST); |
|
| 482 | + $invoice = wpinv_get_invoice($posted['custom']); |
|
| 483 | 483 | |
| 484 | - if ( $invoice && $this->id == $invoice->get_gateway() ) { |
|
| 484 | + if ($invoice && $this->id == $invoice->get_gateway()) { |
|
| 485 | 485 | |
| 486 | - $posted['payment_status'] = strtolower( $posted['payment_status'] ); |
|
| 486 | + $posted['payment_status'] = strtolower($posted['payment_status']); |
|
| 487 | 487 | |
| 488 | - wpinv_error_log( 'Found invoice #' . $invoice->get_number() ); |
|
| 489 | - wpinv_error_log( 'Payment status:' . $posted['payment_status'] ); |
|
| 488 | + wpinv_error_log('Found invoice #' . $invoice->get_number()); |
|
| 489 | + wpinv_error_log('Payment status:' . $posted['payment_status']); |
|
| 490 | 490 | |
| 491 | - if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) { |
|
| 492 | - call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted ); |
|
| 491 | + if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) { |
|
| 492 | + call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted); |
|
| 493 | 493 | } else { |
| 494 | - wpinv_error_log( 'Aborting, Invalid type:' . $posted['txn_type'] ); |
|
| 494 | + wpinv_error_log('Aborting, Invalid type:' . $posted['txn_type']); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | } |
@@ -505,10 +505,10 @@ discard block |
||
| 505 | 505 | */ |
| 506 | 506 | public function validate_ipn() { |
| 507 | 507 | |
| 508 | - wpinv_error_log( 'Validating PayPal IPN response' ); |
|
| 508 | + wpinv_error_log('Validating PayPal IPN response'); |
|
| 509 | 509 | |
| 510 | 510 | // Get received values from post data. |
| 511 | - $validate_ipn = wp_unslash( $_POST ); |
|
| 511 | + $validate_ipn = wp_unslash($_POST); |
|
| 512 | 512 | $validate_ipn['cmd'] = '_notify-validate'; |
| 513 | 513 | |
| 514 | 514 | // Send back post vars to paypal. |
@@ -522,18 +522,18 @@ discard block |
||
| 522 | 522 | ); |
| 523 | 523 | |
| 524 | 524 | // Post back to get a response. |
| 525 | - $response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
| 525 | + $response = wp_safe_remote_post($this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params); |
|
| 526 | 526 | |
| 527 | 527 | // Check to see if the request was valid. |
| 528 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) { |
|
| 529 | - wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' ); |
|
| 528 | + if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) { |
|
| 529 | + wpinv_error_log($response['body'], 'Received valid response from PayPal IPN'); |
|
| 530 | 530 | return true; |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - if ( is_wp_error( $response ) ) { |
|
| 534 | - wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' ); |
|
| 533 | + if (is_wp_error($response)) { |
|
| 534 | + wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN'); |
|
| 535 | 535 | } else { |
| 536 | - wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' ); |
|
| 536 | + wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN'); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | return false; |
@@ -546,12 +546,12 @@ discard block |
||
| 546 | 546 | * @param WPInv_Invoice $invoice Invoice object. |
| 547 | 547 | * @param string $currency currency to validate. |
| 548 | 548 | */ |
| 549 | - protected function validate_ipn_currency( $invoice, $currency ) { |
|
| 550 | - if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) { |
|
| 551 | - wpinv_record_gateway_error( 'IPN Error', "Currencies do not match: {$currency} instead of {$invoice->get_currency()}" ); |
|
| 549 | + protected function validate_ipn_currency($invoice, $currency) { |
|
| 550 | + if (strtolower($invoice->get_currency()) !== strtolower($currency)) { |
|
| 551 | + wpinv_record_gateway_error('IPN Error', "Currencies do not match: {$currency} instead of {$invoice->get_currency()}"); |
|
| 552 | 552 | |
| 553 | 553 | /* translators: %s: currency code. */ |
| 554 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) ); |
|
| 554 | + $invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency)); |
|
| 555 | 555 | exit; |
| 556 | 556 | } |
| 557 | 557 | } |
@@ -562,12 +562,12 @@ discard block |
||
| 562 | 562 | * @param WPInv_Invoice $invoice Invoice object. |
| 563 | 563 | * @param float $amount amount to validate. |
| 564 | 564 | */ |
| 565 | - protected function validate_ipn_amount( $invoice, $amount ) { |
|
| 566 | - if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) { |
|
| 567 | - wpinv_record_gateway_error( 'IPN Error', "Amounts do not match: {$amount} instead of {$invoice->get_total()}" ); |
|
| 565 | + protected function validate_ipn_amount($invoice, $amount) { |
|
| 566 | + if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) { |
|
| 567 | + wpinv_record_gateway_error('IPN Error', "Amounts do not match: {$amount} instead of {$invoice->get_total()}"); |
|
| 568 | 568 | |
| 569 | 569 | /* translators: %s: Amount. */ |
| 570 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) ); |
|
| 570 | + $invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount)); |
|
| 571 | 571 | exit; |
| 572 | 572 | } |
| 573 | 573 | } |
@@ -578,14 +578,14 @@ discard block |
||
| 578 | 578 | * @param WPInv_Invoice $invoice Invoice object. |
| 579 | 579 | * @param string $receiver_email Email to validate. |
| 580 | 580 | */ |
| 581 | - protected function validate_ipn_receiver_email( $invoice, $receiver_email ) { |
|
| 582 | - $paypal_email = wpinv_get_option( 'paypal_email' ); |
|
| 581 | + protected function validate_ipn_receiver_email($invoice, $receiver_email) { |
|
| 582 | + $paypal_email = wpinv_get_option('paypal_email'); |
|
| 583 | 583 | |
| 584 | - if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) { |
|
| 585 | - wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" ); |
|
| 584 | + if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) { |
|
| 585 | + wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}"); |
|
| 586 | 586 | |
| 587 | 587 | /* translators: %s: email address . */ |
| 588 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) ); |
|
| 588 | + $invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email)); |
|
| 589 | 589 | exit; |
| 590 | 590 | } |
| 591 | 591 | |
@@ -597,57 +597,57 @@ discard block |
||
| 597 | 597 | * @param WPInv_Invoice $invoice Invoice object. |
| 598 | 598 | * @param array $posted Posted data. |
| 599 | 599 | */ |
| 600 | - protected function ipn_txn_web_accept( $invoice, $posted ) { |
|
| 600 | + protected function ipn_txn_web_accept($invoice, $posted) { |
|
| 601 | 601 | |
| 602 | 602 | // Collect payment details |
| 603 | - $payment_status = strtolower( $posted['payment_status'] ); |
|
| 604 | - $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] ); |
|
| 603 | + $payment_status = strtolower($posted['payment_status']); |
|
| 604 | + $business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']); |
|
| 605 | 605 | |
| 606 | - $this->validate_ipn_receiver_email( $invoice, $business_email ); |
|
| 607 | - $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
| 606 | + $this->validate_ipn_receiver_email($invoice, $business_email); |
|
| 607 | + $this->validate_ipn_currency($invoice, $posted['mc_currency']); |
|
| 608 | 608 | |
| 609 | 609 | // Update the transaction id. |
| 610 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
| 611 | - $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) ); |
|
| 610 | + if (!empty($posted['txn_id'])) { |
|
| 611 | + $invoice->set_transaction_id(wpinv_clean($posted['txn_id'])); |
|
| 612 | 612 | $invoice->save(); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // Process a refund. |
| 616 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 616 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
| 617 | 617 | |
| 618 | - update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 ); |
|
| 618 | + update_post_meta($invoice->get_id(), 'refunded_remotely', 1); |
|
| 619 | 619 | |
| 620 | - if ( ! $invoice->is_refunded() ) { |
|
| 621 | - $invoice->update_status( 'wpi-refunded', $posted['reason_code'] ); |
|
| 620 | + if (!$invoice->is_refunded()) { |
|
| 621 | + $invoice->update_status('wpi-refunded', $posted['reason_code']); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | exit; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // Process payments. |
| 628 | - if ( $payment_status == 'completed' ) { |
|
| 628 | + if ($payment_status == 'completed') { |
|
| 629 | 629 | |
| 630 | - if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) { |
|
| 631 | - wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already complete.' ); |
|
| 630 | + if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) { |
|
| 631 | + wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already complete.'); |
|
| 632 | 632 | exit; |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - $this->validate_ipn_amount( $invoice, $posted['mc_gross'] ); |
|
| 635 | + $this->validate_ipn_amount($invoice, $posted['mc_gross']); |
|
| 636 | 636 | |
| 637 | - if ( 'completed' === $payment_status || 'pending' === $payment_status ) { |
|
| 637 | + if ('completed' === $payment_status || 'pending' === $payment_status) { |
|
| 638 | 638 | |
| 639 | 639 | $note = ''; |
| 640 | 640 | |
| 641 | - if ( ! empty( $posted['mc_fee'] ) ) { |
|
| 642 | - $note = sprintf( __( 'PayPal Transaction Fee %s', 'invoicing' ), wpinv_clean( $posted['mc_fee'] ) ); |
|
| 641 | + if (!empty($posted['mc_fee'])) { |
|
| 642 | + $note = sprintf(__('PayPal Transaction Fee %s', 'invoicing'), wpinv_clean($posted['mc_fee'])); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? wpinv_clean( $posted['txn_id'] ) : '' ), $note ); |
|
| 645 | + $invoice->mark_paid((!empty($posted['txn_id']) ? wpinv_clean($posted['txn_id']) : ''), $note); |
|
| 646 | 646 | |
| 647 | 647 | } else { |
| 648 | 648 | |
| 649 | 649 | /* translators: %s: pending reason. */ |
| 650 | - $invoice->update_status( 'wpi_processing', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) ); |
|
| 650 | + $invoice->update_status('wpi_processing', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason'])); |
|
| 651 | 651 | |
| 652 | 652 | } |
| 653 | 653 | |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | // Process failures. |
| 659 | 659 | |
| 660 | 660 | /* translators: %s: payment status. */ |
| 661 | - $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) ); |
|
| 661 | + $invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), wpinv_clean($posted['payment_status']))); |
|
| 662 | 662 | |
| 663 | 663 | } |
| 664 | 664 | |
@@ -668,8 +668,8 @@ discard block |
||
| 668 | 668 | * @param WPInv_Invoice $invoice Invoice object. |
| 669 | 669 | * @param array $posted Posted data. |
| 670 | 670 | */ |
| 671 | - protected function ipn_txn_cart( $invoice, $posted ) { |
|
| 672 | - $this->ipn_txn_web_accept( $invoice, $posted ); |
|
| 671 | + protected function ipn_txn_cart($invoice, $posted) { |
|
| 672 | + $this->ipn_txn_web_accept($invoice, $posted); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** |
@@ -678,39 +678,39 @@ discard block |
||
| 678 | 678 | * @param WPInv_Invoice $invoice Invoice object. |
| 679 | 679 | * @param array $posted Posted data. |
| 680 | 680 | */ |
| 681 | - protected function ipn_txn_subscr_signup( $invoice, $posted ) { |
|
| 681 | + protected function ipn_txn_subscr_signup($invoice, $posted) { |
|
| 682 | 682 | |
| 683 | 683 | // Make sure the invoice has a subscription. |
| 684 | - $subscription = wpinv_get_subscription( $invoice ); |
|
| 684 | + $subscription = wpinv_get_subscription($invoice); |
|
| 685 | 685 | |
| 686 | - if ( empty( $subscription ) ) { |
|
| 687 | - wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' ); |
|
| 686 | + if (empty($subscription)) { |
|
| 687 | + wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found'); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | // Update the subscription ids. |
| 691 | 691 | $subscription->update( |
| 692 | 692 | array( |
| 693 | - 'profile_id' => sanitize_text_field( $posted['subscr_id'] ), |
|
| 693 | + 'profile_id' => sanitize_text_field($posted['subscr_id']), |
|
| 694 | 694 | ) |
| 695 | 695 | ); |
| 696 | 696 | |
| 697 | 697 | // Set the transaction id. |
| 698 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
| 699 | - $invoice->set_transaction_id( $posted['txn_id'] ); |
|
| 698 | + if (!empty($posted['txn_id'])) { |
|
| 699 | + $invoice->set_transaction_id($posted['txn_id']); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | // Update the payment status. |
| 703 | 703 | $invoice->mark_paid(); |
| 704 | 704 | |
| 705 | - $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true ); |
|
| 705 | + $invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true); |
|
| 706 | 706 | |
| 707 | 707 | // Use the action id as the subscription id. |
| 708 | - $duration = strtotime( $subscription->expiration ) - strtotime( $subscription->created ); |
|
| 708 | + $duration = strtotime($subscription->expiration) - strtotime($subscription->created); |
|
| 709 | 709 | $subscription->update( |
| 710 | 710 | array( |
| 711 | 711 | 'status' => 'trialling' == $subscription->status ? 'trialling' : 'active', |
| 712 | - 'created' => current_time( 'mysql' ), |
|
| 713 | - 'expiration' => date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ), |
|
| 712 | + 'created' => current_time('mysql'), |
|
| 713 | + 'expiration' => date('Y-m-d H:i:s', (current_time('timestamp') + $duration)), |
|
| 714 | 714 | ) |
| 715 | 715 | ); |
| 716 | 716 | |
@@ -722,25 +722,25 @@ discard block |
||
| 722 | 722 | * @param WPInv_Invoice $invoice Invoice object. |
| 723 | 723 | * @param array $posted Posted data. |
| 724 | 724 | */ |
| 725 | - protected function ipn_txn_subscr_payment( $invoice, $posted ) { |
|
| 725 | + protected function ipn_txn_subscr_payment($invoice, $posted) { |
|
| 726 | 726 | |
| 727 | 727 | // Make sure the invoice has a subscription. |
| 728 | - $subscription = wpinv_get_subscription( $invoice ); |
|
| 728 | + $subscription = wpinv_get_subscription($invoice); |
|
| 729 | 729 | |
| 730 | - if ( empty( $subscription ) ) { |
|
| 731 | - wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' ); |
|
| 730 | + if (empty($subscription)) { |
|
| 731 | + wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found'); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
| 734 | + $this->validate_ipn_currency($invoice, $posted['mc_currency']); |
|
| 735 | 735 | |
| 736 | 736 | // Abort if the payment is already recorded. |
| 737 | - if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) { |
|
| 737 | + if (wpinv_get_id_by_transaction_id($posted['txn_id'])) { |
|
| 738 | 738 | return; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | // Abort if this is the first payment. |
| 742 | - if ( date( 'Ynd', $subscription->created ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) { |
|
| 743 | - $invoice->set_transaction_id( $posted['txn_id'] ); |
|
| 742 | + if (date('Ynd', $subscription->created) == date('Ynd', strtotime($posted['payment_date']))) { |
|
| 743 | + $invoice->set_transaction_id($posted['txn_id']); |
|
| 744 | 744 | $invoice->save(); |
| 745 | 745 | return; |
| 746 | 746 | } |
@@ -751,14 +751,14 @@ discard block |
||
| 751 | 751 | 'gateway' => $this->id, |
| 752 | 752 | ); |
| 753 | 753 | |
| 754 | - $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) ); |
|
| 754 | + $invoice = wpinv_get_invoice($subscription->add_payment($args)); |
|
| 755 | 755 | |
| 756 | - if ( empty( $invoice ) ) { |
|
| 756 | + if (empty($invoice)) { |
|
| 757 | 757 | return; |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true ); |
|
| 761 | - $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true ); |
|
| 760 | + $invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true); |
|
| 761 | + $invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true); |
|
| 762 | 762 | |
| 763 | 763 | $subscription->renew(); |
| 764 | 764 | |
@@ -770,9 +770,9 @@ discard block |
||
| 770 | 770 | * @param WPInv_Invoice $invoice Invoice object. |
| 771 | 771 | * @param array $posted Posted data. |
| 772 | 772 | */ |
| 773 | - protected function ipn_txn_subscr_cancel( $invoice, $posted ) { |
|
| 773 | + protected function ipn_txn_subscr_cancel($invoice, $posted) { |
|
| 774 | 774 | |
| 775 | - if ( $subscription = wpinv_get_subscription( $invoice ) ) { |
|
| 775 | + if ($subscription = wpinv_get_subscription($invoice)) { |
|
| 776 | 776 | $subscription->cancel(); |
| 777 | 777 | } |
| 778 | 778 | |
@@ -784,9 +784,9 @@ discard block |
||
| 784 | 784 | * @param WPInv_Invoice $invoice Invoice object. |
| 785 | 785 | * @param array $posted Posted data. |
| 786 | 786 | */ |
| 787 | - protected function ipn_txn_subscr_eot( $invoice, $posted ) { |
|
| 787 | + protected function ipn_txn_subscr_eot($invoice, $posted) { |
|
| 788 | 788 | |
| 789 | - if ( $subscription = wpinv_get_subscription( $invoice ) ) { |
|
| 789 | + if ($subscription = wpinv_get_subscription($invoice)) { |
|
| 790 | 790 | $subscription->complete(); |
| 791 | 791 | } |
| 792 | 792 | |
@@ -798,9 +798,9 @@ discard block |
||
| 798 | 798 | * @param WPInv_Invoice $invoice Invoice object. |
| 799 | 799 | * @param array $posted Posted data. |
| 800 | 800 | */ |
| 801 | - protected function ipn_txn_subscr_failed( $invoice, $posted ) { |
|
| 801 | + protected function ipn_txn_subscr_failed($invoice, $posted) { |
|
| 802 | 802 | |
| 803 | - if ( $subscription = wpinv_get_subscription( $invoice ) ) { |
|
| 803 | + if ($subscription = wpinv_get_subscription($invoice)) { |
|
| 804 | 804 | $subscription->failing(); |
| 805 | 805 | } |
| 806 | 806 | |
@@ -809,10 +809,10 @@ discard block |
||
| 809 | 809 | /** |
| 810 | 810 | * Displays a notice on the checkout page if sandbox is enabled. |
| 811 | 811 | */ |
| 812 | - public function sandbox_notice( $description, $gateway ) { |
|
| 813 | - if ( 'paypal' == $gateway && wpinv_is_test_mode( 'paypal' ) ) { |
|
| 812 | + public function sandbox_notice($description, $gateway) { |
|
| 813 | + if ('paypal' == $gateway && wpinv_is_test_mode('paypal')) { |
|
| 814 | 814 | $description .= '<br>' . sprintf( |
| 815 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 815 | + __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
| 816 | 816 | '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
| 817 | 817 | '</a>' |
| 818 | 818 | ); |
@@ -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,11 +77,11 @@ 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 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
| 84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param string $post_type The post type to check for. |
| 92 | 92 | */ |
| 93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
| 94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
| 93 | +function getpaid_is_invoice_post_type($post_type) { |
|
| 94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 103 | 103 | */ |
| 104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
| 105 | - $data[ 'invoice_id' ] = 0; |
|
| 106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
| 105 | + $data['invoice_id'] = 0; |
|
| 106 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
| 113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 115 | 115 | */ |
| 116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
| 116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
| 117 | 117 | |
| 118 | 118 | // Backwards compatibility. |
| 119 | - if ( ! empty( $data['ID'] ) ) { |
|
| 119 | + if (!empty($data['ID'])) { |
|
| 120 | 120 | $data['invoice_id'] = $data['ID']; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Do we have an invoice id? |
| 124 | - if ( empty( $data['invoice_id'] ) ) { |
|
| 125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
| 124 | + if (empty($data['invoice_id'])) { |
|
| 125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Retrieve the invoice. |
| 129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
| 129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
| 130 | 130 | |
| 131 | 131 | // And abort if it does not exist. |
| 132 | - if ( empty( $invoice ) ) { |
|
| 133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
| 132 | + if (empty($invoice)) { |
|
| 133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Do not update totals for paid / refunded invoices. |
| 137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 138 | 138 | |
| 139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
| 140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
| 139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
| 140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 145 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
| 153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 155 | 155 | */ |
| 156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
| 156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
| 157 | 157 | |
| 158 | 158 | // Ensure that we have invoice data. |
| 159 | - if ( empty( $data ) ) { |
|
| 159 | + if (empty($data)) { |
|
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // The invoice id will be provided when updating an invoice. |
| 164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
| 164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
| 165 | 165 | |
| 166 | 166 | // Retrieve the invoice. |
| 167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
| 167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
| 168 | 168 | |
| 169 | 169 | // Do we have an error? |
| 170 | - if ( ! empty( $invoice->last_error ) ) { |
|
| 171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
| 170 | + if (!empty($invoice->last_error)) { |
|
| 171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Backwards compatibility (billing address). |
| 175 | - if ( ! empty( $data['user_info'] ) ) { |
|
| 175 | + if (!empty($data['user_info'])) { |
|
| 176 | 176 | |
| 177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
| 177 | + foreach ($data['user_info'] as $key => $value) { |
|
| 178 | 178 | |
| 179 | - if ( $key == 'discounts' ) { |
|
| 179 | + if ($key == 'discounts') { |
|
| 180 | 180 | $value = (array) $value; |
| 181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
| 181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
| 182 | 182 | } else { |
| 183 | - $data[ $key ] = $value; |
|
| 183 | + $data[$key] = $value; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Backwards compatibility. |
| 191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
| 191 | + if (!empty($data['payment_details'])) { |
|
| 192 | 192 | |
| 193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
| 194 | - $data[ $key ] = $value; |
|
| 193 | + foreach ($data['payment_details'] as $key => $value) { |
|
| 194 | + $data[$key] = $value; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Set up the owner of the invoice. |
| 200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
| 200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
| 201 | 201 | |
| 202 | 202 | // Make sure the user exists. |
| 203 | - if ( ! get_userdata( $user_id ) ) { |
|
| 204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
| 203 | + if (!get_userdata($user_id)) { |
|
| 204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $address = wpinv_get_user_address( $user_id ); |
|
| 207 | + $address = wpinv_get_user_address($user_id); |
|
| 208 | 208 | |
| 209 | - foreach ( $address as $key => $value ) { |
|
| 209 | + foreach ($address as $key => $value) { |
|
| 210 | 210 | |
| 211 | - if ( $value == '' ) { |
|
| 212 | - $address[ $key ] = null; |
|
| 211 | + if ($value == '') { |
|
| 212 | + $address[$key] = null; |
|
| 213 | 213 | } else { |
| 214 | - $address[ $key ] = wpinv_clean( $value ); |
|
| 214 | + $address[$key] = wpinv_clean($value); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
| 222 | 222 | array( |
| 223 | 223 | |
| 224 | 224 | // Basic info. |
| 225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
| 226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
| 227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
| 228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
| 229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
| 230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
| 231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
| 232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
| 233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
| 234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
| 235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
| 236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
| 237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
| 225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
| 226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
| 227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
| 228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
| 229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
| 230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
| 231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
| 232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
| 233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
| 234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
| 235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
| 236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
| 237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
| 238 | 238 | |
| 239 | 239 | // Payment info. |
| 240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
| 241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
| 242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
| 243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
| 244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
| 245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
| 246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
| 247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
| 248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
| 249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
| 250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
| 251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
| 240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
| 241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
| 242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
| 243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
| 244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
| 245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
| 246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
| 247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
| 248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
| 249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
| 250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
| 251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | // Billing details. |
| 255 | 255 | 'user_id' => $data['user_id'], |
| 256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
| 257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
| 258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
| 259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
| 260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
| 261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
| 262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
| 263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
| 264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
| 265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
| 266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
| 256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
| 257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
| 258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
| 259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
| 260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
| 261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
| 262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
| 263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
| 264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
| 265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
| 266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
| 267 | 267 | |
| 268 | 268 | ) |
| 269 | 269 | |
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | // Backwards compatibililty. |
| 273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
| 273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
| 274 | 274 | $data['items'] = array(); |
| 275 | 275 | |
| 276 | - foreach( $data['cart_details'] as $_item ) { |
|
| 276 | + foreach ($data['cart_details'] as $_item) { |
|
| 277 | 277 | |
| 278 | 278 | // Ensure that we have an item id. |
| 279 | - if ( empty( $_item['id'] ) ) { |
|
| 279 | + if (empty($_item['id'])) { |
|
| 280 | 280 | continue; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // Retrieve the item. |
| 284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
| 284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
| 285 | 285 | |
| 286 | 286 | // Ensure that it is purchasable. |
| 287 | - if ( ! $item->can_purchase() ) { |
|
| 287 | + if (!$item->can_purchase()) { |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Set quantity. |
| 292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
| 293 | - $item->set_quantity( $_item['quantity'] ); |
|
| 292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
| 293 | + $item->set_quantity($_item['quantity']); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Set price. |
| 297 | - if ( isset( $_item['item_price'] ) ) { |
|
| 298 | - $item->set_price( $_item['item_price'] ); |
|
| 297 | + if (isset($_item['item_price'])) { |
|
| 298 | + $item->set_price($_item['item_price']); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( isset( $_item['custom_price'] ) ) { |
|
| 302 | - $item->set_price( $_item['custom_price'] ); |
|
| 301 | + if (isset($_item['custom_price'])) { |
|
| 302 | + $item->set_price($_item['custom_price']); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Set name. |
| 306 | - if ( ! empty( $_item['name'] ) ) { |
|
| 307 | - $item->set_name( $_item['name'] ); |
|
| 306 | + if (!empty($_item['name'])) { |
|
| 307 | + $item->set_name($_item['name']); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Set description. |
| 311 | - if ( isset( $_item['description'] ) ) { |
|
| 312 | - $item->set_custom_description( $_item['description'] ); |
|
| 311 | + if (isset($_item['description'])) { |
|
| 312 | + $item->set_custom_description($_item['description']); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Set meta. |
| 316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
| 316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
| 317 | 317 | |
| 318 | - $item->set_item_meta( $_item['meta'] ); |
|
| 318 | + $item->set_item_meta($_item['meta']); |
|
| 319 | 319 | |
| 320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
| 321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
| 320 | + if (isset($_item['meta']['description'])) { |
|
| 321 | + $item->set_custom_description($_item['meta']['description']); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Add invoice items. |
| 332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
| 332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
| 333 | 333 | |
| 334 | - $invoice->set_items( array() ); |
|
| 334 | + $invoice->set_items(array()); |
|
| 335 | 335 | |
| 336 | - foreach ( $data['items'] as $item ) { |
|
| 336 | + foreach ($data['items'] as $item) { |
|
| 337 | 337 | |
| 338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
| 339 | - $invoice->add_item( $item ); |
|
| 338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
| 339 | + $invoice->add_item($item); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | } |
@@ -346,30 +346,30 @@ discard block |
||
| 346 | 346 | // Save the invoice. |
| 347 | 347 | $invoice->save(); |
| 348 | 348 | |
| 349 | - if ( ! $invoice->get_id() ) { |
|
| 350 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
| 349 | + if (!$invoice->get_id()) { |
|
| 350 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // Add private note. |
| 354 | - if ( ! empty( $data['private_note'] ) ) { |
|
| 355 | - $invoice->add_note( $data['private_note'] ); |
|
| 354 | + if (!empty($data['private_note'])) { |
|
| 355 | + $invoice->add_note($data['private_note']); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | // User notes. |
| 359 | - if ( !empty( $data['user_note'] ) ) { |
|
| 360 | - $invoice->add_note( $data['user_note'], true ); |
|
| 359 | + if (!empty($data['user_note'])) { |
|
| 360 | + $invoice->add_note($data['user_note'], true); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // Created via. |
| 364 | - if ( isset( $data['created_via'] ) ) { |
|
| 365 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
| 364 | + if (isset($data['created_via'])) { |
|
| 365 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Backwards compatiblity. |
| 369 | - if ( $invoice->is_quote() ) { |
|
| 369 | + if ($invoice->is_quote()) { |
|
| 370 | 370 | |
| 371 | - if ( isset( $data['valid_until'] ) ) { |
|
| 372 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
| 371 | + if (isset($data['valid_until'])) { |
|
| 372 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
| 373 | 373 | } |
| 374 | 374 | return $invoice; |
| 375 | 375 | |
@@ -384,18 +384,18 @@ discard block |
||
| 384 | 384 | * @param $bool $deprecated |
| 385 | 385 | * @return WPInv_Invoice|null |
| 386 | 386 | */ |
| 387 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
| 387 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
| 388 | 388 | |
| 389 | 389 | // If we are retrieving the invoice from the cart... |
| 390 | - if ( $deprecated && empty( $invoice ) ) { |
|
| 390 | + if ($deprecated && empty($invoice)) { |
|
| 391 | 391 | $invoice = (int) getpaid_get_current_invoice_id(); |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // Retrieve the invoice. |
| 395 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 395 | + $invoice = new WPInv_Invoice($invoice); |
|
| 396 | 396 | |
| 397 | 397 | // Check if it exists. |
| 398 | - if ( $invoice->get_id() != 0 ) { |
|
| 398 | + if ($invoice->get_id() != 0) { |
|
| 399 | 399 | return $invoice; |
| 400 | 400 | } |
| 401 | 401 | |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | * @param array $args Args to search for. |
| 409 | 409 | * @return WPInv_Invoice[]|int[]|object |
| 410 | 410 | */ |
| 411 | -function wpinv_get_invoices( $args ) { |
|
| 411 | +function wpinv_get_invoices($args) { |
|
| 412 | 412 | |
| 413 | 413 | // Prepare args. |
| 414 | 414 | $args = wp_parse_args( |
| 415 | 415 | $args, |
| 416 | 416 | array( |
| 417 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 417 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 418 | 418 | 'type' => 'wpi_invoice', |
| 419 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 419 | + 'limit' => get_option('posts_per_page'), |
|
| 420 | 420 | 'return' => 'objects', |
| 421 | 421 | ) |
| 422 | 422 | ); |
@@ -434,24 +434,24 @@ discard block |
||
| 434 | 434 | 'post__in' => 'include', |
| 435 | 435 | ); |
| 436 | 436 | |
| 437 | - foreach ( $map_legacy as $to => $from ) { |
|
| 438 | - if ( isset( $args[ $from ] ) ) { |
|
| 439 | - $args[ $to ] = $args[ $from ]; |
|
| 440 | - unset( $args[ $from ] ); |
|
| 437 | + foreach ($map_legacy as $to => $from) { |
|
| 438 | + if (isset($args[$from])) { |
|
| 439 | + $args[$to] = $args[$from]; |
|
| 440 | + unset($args[$from]); |
|
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // Backwards compatibility. |
| 445 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
| 445 | + if (!empty($args['email']) && empty($args['user'])) { |
|
| 446 | 446 | $args['user'] = $args['email']; |
| 447 | - unset( $args['email'] ); |
|
| 447 | + unset($args['email']); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Handle cases where the user is set as an email. |
| 451 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
| 452 | - $user = get_user_by( 'email', $args['user'] ); |
|
| 451 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
| 452 | + $user = get_user_by('email', $args['user']); |
|
| 453 | 453 | |
| 454 | - if ( $user ) { |
|
| 454 | + if ($user) { |
|
| 455 | 455 | $args['author'] = $user->user_email; |
| 456 | 456 | } |
| 457 | 457 | |
@@ -462,31 +462,31 @@ discard block |
||
| 462 | 462 | |
| 463 | 463 | // Show all posts. |
| 464 | 464 | $paginate = true; |
| 465 | - if ( isset( $args['paginate'] ) ) { |
|
| 465 | + if (isset($args['paginate'])) { |
|
| 466 | 466 | |
| 467 | 467 | $paginate = $args['paginate']; |
| 468 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
| 469 | - unset( $args['paginate'] ); |
|
| 468 | + $args['no_found_rows'] = empty($args['paginate']); |
|
| 469 | + unset($args['paginate']); |
|
| 470 | 470 | |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // Whether to return objects or fields. |
| 474 | 474 | $return = $args['return']; |
| 475 | - unset( $args['return'] ); |
|
| 475 | + unset($args['return']); |
|
| 476 | 476 | |
| 477 | 477 | // Get invoices. |
| 478 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
| 478 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
| 479 | 479 | |
| 480 | 480 | // Prepare the results. |
| 481 | - if ( 'objects' === $return ) { |
|
| 482 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
| 483 | - } elseif ( 'self' === $return ) { |
|
| 481 | + if ('objects' === $return) { |
|
| 482 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
| 483 | + } elseif ('self' === $return) { |
|
| 484 | 484 | return $invoices; |
| 485 | 485 | } else { |
| 486 | 486 | $results = $invoices->posts; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - if ( $paginate ) { |
|
| 489 | + if ($paginate) { |
|
| 490 | 490 | return (object) array( |
| 491 | 491 | 'invoices' => $results, |
| 492 | 492 | 'total' => $invoices->found_posts, |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | * @param string $transaction_id The transaction id to check. |
| 505 | 505 | * @return int Invoice id on success or 0 on failure |
| 506 | 506 | */ |
| 507 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
| 508 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
| 507 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
| 508 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | /** |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | * @param string $invoice_number The invoice number to check. |
| 515 | 515 | * @return int Invoice id on success or 0 on failure |
| 516 | 516 | */ |
| 517 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
| 518 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
| 517 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
| 518 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -524,8 +524,8 @@ discard block |
||
| 524 | 524 | * @param string $invoice_key The invoice key to check. |
| 525 | 525 | * @return int Invoice id on success or 0 on failure |
| 526 | 526 | */ |
| 527 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
| 528 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
| 527 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
| 528 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -535,20 +535,20 @@ discard block |
||
| 535 | 535 | * @param string $type Optionally filter by type i.e customer|system |
| 536 | 536 | * @return WPInv_Invoice|null |
| 537 | 537 | */ |
| 538 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
| 538 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
| 539 | 539 | global $invoicing; |
| 540 | 540 | |
| 541 | 541 | // Prepare the invoice. |
| 542 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 543 | - if ( ! $invoice->exists() ) { |
|
| 542 | + $invoice = new WPInv_Invoice($invoice); |
|
| 543 | + if (!$invoice->exists()) { |
|
| 544 | 544 | return NULL; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | // Fetch notes. |
| 548 | - $notes = $invoicing->notes->get_invoice_notes( $invoice->get_id(), $type ); |
|
| 548 | + $notes = $invoicing->notes->get_invoice_notes($invoice->get_id(), $type); |
|
| 549 | 549 | |
| 550 | 550 | // Filter the notes. |
| 551 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
| 551 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -558,27 +558,27 @@ discard block |
||
| 558 | 558 | $columns = array( |
| 559 | 559 | |
| 560 | 560 | 'invoice-number' => array( |
| 561 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
| 561 | + 'title' => __('Invoice', 'invoicing'), |
|
| 562 | 562 | 'class' => 'text-left' |
| 563 | 563 | ), |
| 564 | 564 | |
| 565 | 565 | 'created-date' => array( |
| 566 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
| 566 | + 'title' => __('Created Date', 'invoicing'), |
|
| 567 | 567 | 'class' => 'text-left' |
| 568 | 568 | ), |
| 569 | 569 | |
| 570 | 570 | 'payment-date' => array( |
| 571 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
| 571 | + 'title' => __('Payment Date', 'invoicing'), |
|
| 572 | 572 | 'class' => 'text-left' |
| 573 | 573 | ), |
| 574 | 574 | |
| 575 | 575 | 'invoice-status' => array( |
| 576 | - 'title' => __( 'Status', 'invoicing' ), |
|
| 576 | + 'title' => __('Status', 'invoicing'), |
|
| 577 | 577 | 'class' => 'text-center' |
| 578 | 578 | ), |
| 579 | 579 | |
| 580 | 580 | 'invoice-total' => array( |
| 581 | - 'title' => __( 'Total', 'invoicing' ), |
|
| 581 | + 'title' => __('Total', 'invoicing'), |
|
| 582 | 582 | 'class' => 'text-right' |
| 583 | 583 | ), |
| 584 | 584 | |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | ); |
| 591 | 591 | |
| 592 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
| 592 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
@@ -599,54 +599,54 @@ discard block |
||
| 599 | 599 | |
| 600 | 600 | // Find the invoice. |
| 601 | 601 | $invoice_id = getpaid_get_current_invoice_id(); |
| 602 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 602 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 603 | 603 | |
| 604 | 604 | // Abort if non was found. |
| 605 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
| 605 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
| 606 | 606 | |
| 607 | 607 | return aui()->alert( |
| 608 | 608 | array( |
| 609 | 609 | 'type' => 'warning', |
| 610 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
| 610 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
| 611 | 611 | ) |
| 612 | 612 | ); |
| 613 | 613 | |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | // Can the user view this invoice? |
| 617 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
| 617 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
| 618 | 618 | |
| 619 | 619 | return aui()->alert( |
| 620 | 620 | array( |
| 621 | 621 | 'type' => 'warning', |
| 622 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
| 622 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
| 623 | 623 | ) |
| 624 | 624 | ); |
| 625 | 625 | |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | // Load the template. |
| 629 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
| 629 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
| 630 | 630 | |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | /** |
| 634 | 634 | * Displays the invoice history. |
| 635 | 635 | */ |
| 636 | -function getpaid_invoice_history( $user_id = 0 ) { |
|
| 636 | +function getpaid_invoice_history($user_id = 0) { |
|
| 637 | 637 | |
| 638 | 638 | // Ensure that we have a user id. |
| 639 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
| 639 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
| 640 | 640 | $user_id = get_current_user_id(); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | // View user id. |
| 644 | - if ( empty( $user_id ) ) { |
|
| 644 | + if (empty($user_id)) { |
|
| 645 | 645 | |
| 646 | 646 | return aui()->alert( |
| 647 | 647 | array( |
| 648 | 648 | 'type' => 'warning', |
| 649 | - 'content' => __( 'You must be logged in to view your invoice history.', 'invoicing' ), |
|
| 649 | + 'content' => __('You must be logged in to view your invoice history.', 'invoicing'), |
|
| 650 | 650 | ) |
| 651 | 651 | ); |
| 652 | 652 | |
@@ -656,89 +656,89 @@ discard block |
||
| 656 | 656 | $invoices = wpinv_get_invoices( |
| 657 | 657 | |
| 658 | 658 | array( |
| 659 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 659 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
| 660 | 660 | 'user' => $user_id, |
| 661 | 661 | 'paginate' => true, |
| 662 | 662 | ) |
| 663 | 663 | |
| 664 | 664 | ); |
| 665 | 665 | |
| 666 | - if ( empty( $invoices->total ) ) { |
|
| 666 | + if (empty($invoices->total)) { |
|
| 667 | 667 | |
| 668 | 668 | return aui()->alert( |
| 669 | 669 | array( |
| 670 | 670 | 'type' => 'info', |
| 671 | - 'content' => __( 'No invoices found.', 'invoicing' ), |
|
| 671 | + 'content' => __('No invoices found.', 'invoicing'), |
|
| 672 | 672 | ) |
| 673 | 673 | ); |
| 674 | 674 | |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | // Load the template. |
| 678 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices' ) ); |
|
| 678 | + return wpinv_get_template_html('invoice-history.php', compact('invoices')); |
|
| 679 | 679 | |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | function wpinv_pay_for_invoice() { |
| 683 | 683 | global $wpinv_euvat; |
| 684 | 684 | |
| 685 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
| 685 | + if (isset($_GET['invoice_key'])) { |
|
| 686 | 686 | $checkout_uri = wpinv_get_checkout_uri(); |
| 687 | - $invoice_key = sanitize_text_field( $_GET['invoice_key'] ); |
|
| 687 | + $invoice_key = sanitize_text_field($_GET['invoice_key']); |
|
| 688 | 688 | |
| 689 | - if ( empty( $invoice_key ) ) { |
|
| 690 | - wpinv_set_error( 'invalid_invoice', __( 'Invoice not found', 'invoicing' ) ); |
|
| 691 | - wp_redirect( $checkout_uri ); |
|
| 689 | + if (empty($invoice_key)) { |
|
| 690 | + wpinv_set_error('invalid_invoice', __('Invoice not found', 'invoicing')); |
|
| 691 | + wp_redirect($checkout_uri); |
|
| 692 | 692 | exit(); |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - do_action( 'wpinv_check_pay_for_invoice', $invoice_key ); |
|
| 695 | + do_action('wpinv_check_pay_for_invoice', $invoice_key); |
|
| 696 | 696 | |
| 697 | - $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 698 | - $user_can_view = wpinv_can_view_receipt( $invoice_key ); |
|
| 699 | - if ( $user_can_view && isset( $_GET['invoice-id'] ) ) { |
|
| 700 | - $invoice_id = (int)$_GET['invoice-id']; |
|
| 701 | - $user_can_view = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false; |
|
| 697 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 698 | + $user_can_view = wpinv_can_view_receipt($invoice_key); |
|
| 699 | + if ($user_can_view && isset($_GET['invoice-id'])) { |
|
| 700 | + $invoice_id = (int) $_GET['invoice-id']; |
|
| 701 | + $user_can_view = $invoice_key == wpinv_get_payment_key((int) $_GET['invoice-id']) ? true : false; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - if ( $invoice_id && $user_can_view && ( $invoice = wpinv_get_invoice( $invoice_id ) ) ) { |
|
| 705 | - if ( $invoice->needs_payment() ) { |
|
| 704 | + if ($invoice_id && $user_can_view && ($invoice = wpinv_get_invoice($invoice_id))) { |
|
| 705 | + if ($invoice->needs_payment()) { |
|
| 706 | 706 | $data = array(); |
| 707 | 707 | $data['invoice_id'] = $invoice_id; |
| 708 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 708 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 709 | 709 | |
| 710 | - wpinv_set_checkout_session( $data ); |
|
| 710 | + wpinv_set_checkout_session($data); |
|
| 711 | 711 | |
| 712 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
| 712 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
| 713 | 713 | $_POST['country'] = $wpinv_euvat->get_country_by_ip(); |
| 714 | 714 | $_POST['state'] = $_POST['country'] == $invoice->country ? $invoice->state : ''; |
| 715 | 715 | |
| 716 | - wpinv_recalculate_tax( true ); |
|
| 716 | + wpinv_recalculate_tax(true); |
|
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | } else { |
| 720 | 720 | $checkout_uri = $invoice->get_view_url(); |
| 721 | 721 | } |
| 722 | 722 | } else { |
| 723 | - wpinv_set_error( 'invalid_invoice', __( 'You are not allowed to view this invoice', 'invoicing' ) ); |
|
| 723 | + wpinv_set_error('invalid_invoice', __('You are not allowed to view this invoice', 'invoicing')); |
|
| 724 | 724 | |
| 725 | - $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
| 725 | + $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - if(wp_redirect( $checkout_uri )){ |
|
| 728 | + if (wp_redirect($checkout_uri)) { |
|
| 729 | 729 | exit; |
| 730 | 730 | }; |
| 731 | 731 | wpinv_die(); |
| 732 | 732 | } |
| 733 | 733 | } |
| 734 | -add_action( 'wpinv_pay_for_invoice', 'wpinv_pay_for_invoice' ); |
|
| 734 | +add_action('wpinv_pay_for_invoice', 'wpinv_pay_for_invoice'); |
|
| 735 | 735 | |
| 736 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
| 737 | - if ( empty( $status_display ) ) { |
|
| 738 | - $status_display = wpinv_status_nicename( $status ); |
|
| 736 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
| 737 | + if (empty($status_display)) { |
|
| 738 | + $status_display = wpinv_status_nicename($status); |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - switch ( $status ) { |
|
| 741 | + switch ($status) { |
|
| 742 | 742 | case 'publish' : |
| 743 | 743 | case 'wpi-renewal' : |
| 744 | 744 | $class = 'label-success'; |
@@ -763,159 +763,159 @@ discard block |
||
| 763 | 763 | |
| 764 | 764 | $label = '<span class="label label-inv-' . $status . ' ' . $class . '">' . $status_display . '</span>'; |
| 765 | 765 | |
| 766 | - return apply_filters( 'wpinv_invoice_status_label', $label, $status, $status_display ); |
|
| 766 | + return apply_filters('wpinv_invoice_status_label', $label, $status, $status_display); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
| 770 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
| 771 | - if ( null !== $check ) { |
|
| 769 | +function wpinv_format_invoice_number($number, $type = '') { |
|
| 770 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
| 771 | + if (null !== $check) { |
|
| 772 | 772 | return $check; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - if ( !empty( $number ) && !is_numeric( $number ) ) { |
|
| 775 | + if (!empty($number) && !is_numeric($number)) { |
|
| 776 | 776 | return $number; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - $padd = wpinv_get_option( 'invoice_number_padd' ); |
|
| 780 | - $prefix = wpinv_get_option( 'invoice_number_prefix' ); |
|
| 781 | - $postfix = wpinv_get_option( 'invoice_number_postfix' ); |
|
| 779 | + $padd = wpinv_get_option('invoice_number_padd'); |
|
| 780 | + $prefix = wpinv_get_option('invoice_number_prefix'); |
|
| 781 | + $postfix = wpinv_get_option('invoice_number_postfix'); |
|
| 782 | 782 | |
| 783 | - $padd = absint( $padd ); |
|
| 784 | - $formatted_number = absint( $number ); |
|
| 783 | + $padd = absint($padd); |
|
| 784 | + $formatted_number = absint($number); |
|
| 785 | 785 | |
| 786 | - if ( $padd > 0 ) { |
|
| 787 | - $formatted_number = zeroise( $formatted_number, $padd ); |
|
| 786 | + if ($padd > 0) { |
|
| 787 | + $formatted_number = zeroise($formatted_number, $padd); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | $formatted_number = $prefix . $formatted_number . $postfix; |
| 791 | 791 | |
| 792 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
| 792 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
| 796 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
| 797 | - if ( null !== $check ) { |
|
| 795 | +function wpinv_get_next_invoice_number($type = '') { |
|
| 796 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
| 797 | + if (null !== $check) { |
|
| 798 | 798 | return $check; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if ( !wpinv_sequential_number_active() ) { |
|
| 801 | + if (!wpinv_sequential_number_active()) { |
|
| 802 | 802 | return false; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - $number = $last_number = get_option( 'wpinv_last_invoice_number', 0 ); |
|
| 806 | - $start = wpinv_get_option( 'invoice_sequence_start', 1 ); |
|
| 807 | - if ( !absint( $start ) > 0 ) { |
|
| 805 | + $number = $last_number = get_option('wpinv_last_invoice_number', 0); |
|
| 806 | + $start = wpinv_get_option('invoice_sequence_start', 1); |
|
| 807 | + if (!absint($start) > 0) { |
|
| 808 | 808 | $start = 1; |
| 809 | 809 | } |
| 810 | 810 | $increment_number = true; |
| 811 | 811 | $save_number = false; |
| 812 | 812 | |
| 813 | - if ( !empty( $number ) && !is_numeric( $number ) && $number == wpinv_format_invoice_number( $number ) ) { |
|
| 814 | - $number = wpinv_clean_invoice_number( $number ); |
|
| 813 | + if (!empty($number) && !is_numeric($number) && $number == wpinv_format_invoice_number($number)) { |
|
| 814 | + $number = wpinv_clean_invoice_number($number); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - if ( empty( $number ) ) { |
|
| 818 | - if ( !( $last_number === 0 || $last_number === '0' ) ) { |
|
| 819 | - $last_invoice = wpinv_get_invoices( array( 'limit' => 1, 'order' => 'DESC', 'orderby' => 'ID', 'return' => 'posts', 'fields' => 'ids', 'status' => array_keys( wpinv_get_invoice_statuses( true, true ) ) ) ); |
|
| 817 | + if (empty($number)) { |
|
| 818 | + if (!($last_number === 0 || $last_number === '0')) { |
|
| 819 | + $last_invoice = wpinv_get_invoices(array('limit' => 1, 'order' => 'DESC', 'orderby' => 'ID', 'return' => 'posts', 'fields' => 'ids', 'status' => array_keys(wpinv_get_invoice_statuses(true, true)))); |
|
| 820 | 820 | |
| 821 | - if ( !empty( $last_invoice[0] ) && $invoice_number = wpinv_get_invoice_number( $last_invoice[0] ) ) { |
|
| 822 | - if ( is_numeric( $invoice_number ) ) { |
|
| 821 | + if (!empty($last_invoice[0]) && $invoice_number = wpinv_get_invoice_number($last_invoice[0])) { |
|
| 822 | + if (is_numeric($invoice_number)) { |
|
| 823 | 823 | $number = $invoice_number; |
| 824 | 824 | } else { |
| 825 | - $number = wpinv_clean_invoice_number( $invoice_number ); |
|
| 825 | + $number = wpinv_clean_invoice_number($invoice_number); |
|
| 826 | 826 | } |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - if ( empty( $number ) ) { |
|
| 829 | + if (empty($number)) { |
|
| 830 | 830 | $increment_number = false; |
| 831 | 831 | $number = $start; |
| 832 | - $save_number = ( $number - 1 ); |
|
| 832 | + $save_number = ($number - 1); |
|
| 833 | 833 | } else { |
| 834 | 834 | $save_number = $number; |
| 835 | 835 | } |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - if ( $start > $number ) { |
|
| 839 | + if ($start > $number) { |
|
| 840 | 840 | $increment_number = false; |
| 841 | 841 | $number = $start; |
| 842 | - $save_number = ( $number - 1 ); |
|
| 842 | + $save_number = ($number - 1); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if ( $save_number !== false ) { |
|
| 846 | - update_option( 'wpinv_last_invoice_number', $save_number ); |
|
| 845 | + if ($save_number !== false) { |
|
| 846 | + update_option('wpinv_last_invoice_number', $save_number); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - $increment_number = apply_filters( 'wpinv_increment_payment_number', $increment_number, $number ); |
|
| 849 | + $increment_number = apply_filters('wpinv_increment_payment_number', $increment_number, $number); |
|
| 850 | 850 | |
| 851 | - if ( $increment_number ) { |
|
| 851 | + if ($increment_number) { |
|
| 852 | 852 | $number++; |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
| 855 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | -function wpinv_clean_invoice_number( $number, $type = '' ) { |
|
| 859 | - $check = apply_filters( 'wpinv_pre_clean_invoice_number', null, $number, $type ); |
|
| 860 | - if ( null !== $check ) { |
|
| 858 | +function wpinv_clean_invoice_number($number, $type = '') { |
|
| 859 | + $check = apply_filters('wpinv_pre_clean_invoice_number', null, $number, $type); |
|
| 860 | + if (null !== $check) { |
|
| 861 | 861 | return $check; |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - $prefix = wpinv_get_option( 'invoice_number_prefix' ); |
|
| 865 | - $postfix = wpinv_get_option( 'invoice_number_postfix' ); |
|
| 864 | + $prefix = wpinv_get_option('invoice_number_prefix'); |
|
| 865 | + $postfix = wpinv_get_option('invoice_number_postfix'); |
|
| 866 | 866 | |
| 867 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
| 867 | + $number = preg_replace('/' . $prefix . '/', '', $number, 1); |
|
| 868 | 868 | |
| 869 | - $length = strlen( $number ); |
|
| 870 | - $postfix_pos = strrpos( $number, $postfix ); |
|
| 869 | + $length = strlen($number); |
|
| 870 | + $postfix_pos = strrpos($number, $postfix); |
|
| 871 | 871 | |
| 872 | - if ( false !== $postfix_pos ) { |
|
| 873 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
| 872 | + if (false !== $postfix_pos) { |
|
| 873 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - $number = intval( $number ); |
|
| 876 | + $number = intval($number); |
|
| 877 | 877 | |
| 878 | - return apply_filters( 'wpinv_clean_invoice_number', $number, $prefix, $postfix ); |
|
| 878 | + return apply_filters('wpinv_clean_invoice_number', $number, $prefix, $postfix); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | -function wpinv_update_invoice_number( $post_ID, $save_sequential = false, $type = '' ) { |
|
| 881 | +function wpinv_update_invoice_number($post_ID, $save_sequential = false, $type = '') { |
|
| 882 | 882 | global $wpdb; |
| 883 | 883 | |
| 884 | - $check = apply_filters( 'wpinv_pre_update_invoice_number', null, $post_ID, $save_sequential, $type ); |
|
| 885 | - if ( null !== $check ) { |
|
| 884 | + $check = apply_filters('wpinv_pre_update_invoice_number', null, $post_ID, $save_sequential, $type); |
|
| 885 | + if (null !== $check) { |
|
| 886 | 886 | return $check; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - if ( wpinv_sequential_number_active() ) { |
|
| 889 | + if (wpinv_sequential_number_active()) { |
|
| 890 | 890 | $number = wpinv_get_next_invoice_number(); |
| 891 | 891 | |
| 892 | - if ( $save_sequential ) { |
|
| 893 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
| 892 | + if ($save_sequential) { |
|
| 893 | + update_option('wpinv_last_invoice_number', $number); |
|
| 894 | 894 | } |
| 895 | 895 | } else { |
| 896 | 896 | $number = $post_ID; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - $number = wpinv_format_invoice_number( $number ); |
|
| 899 | + $number = wpinv_format_invoice_number($number); |
|
| 900 | 900 | |
| 901 | - update_post_meta( $post_ID, '_wpinv_number', $number ); |
|
| 901 | + update_post_meta($post_ID, '_wpinv_number', $number); |
|
| 902 | 902 | |
| 903 | - $wpdb->update( $wpdb->posts, array( 'post_title' => $number ), array( 'ID' => $post_ID ) ); |
|
| 903 | + $wpdb->update($wpdb->posts, array('post_title' => $number), array('ID' => $post_ID)); |
|
| 904 | 904 | |
| 905 | - clean_post_cache( $post_ID ); |
|
| 905 | + clean_post_cache($post_ID); |
|
| 906 | 906 | |
| 907 | 907 | return $number; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
| 911 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
| 910 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
| 911 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | -function wpinv_generate_post_name( $post_ID ) { |
|
| 915 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
| 916 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
| 914 | +function wpinv_generate_post_name($post_ID) { |
|
| 915 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
| 916 | + $post_name = sanitize_title($prefix . $post_ID); |
|
| 917 | 917 | |
| 918 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
| 918 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -923,8 +923,8 @@ discard block |
||
| 923 | 923 | * |
| 924 | 924 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 925 | 925 | */ |
| 926 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
| 927 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 926 | +function wpinv_is_invoice_viewed($invoice) { |
|
| 927 | + $invoice = new WPInv_Invoice($invoice); |
|
| 928 | 928 | return (bool) $invoice->get_is_viewed(); |
| 929 | 929 | } |
| 930 | 930 | |
@@ -933,51 +933,51 @@ discard block |
||
| 933 | 933 | * |
| 934 | 934 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 935 | 935 | */ |
| 936 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
| 937 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 936 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
| 937 | + $invoice = new WPInv_Invoice($invoice); |
|
| 938 | 938 | |
| 939 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
| 940 | - $invoice->set_is_viewed( true ); |
|
| 939 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
| 940 | + $invoice->set_is_viewed(true); |
|
| 941 | 941 | $invoice->save(); |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | } |
| 945 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 946 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 945 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 946 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 947 | 947 | |
| 948 | 948 | /** |
| 949 | 949 | * Fetch a subscription given an invoice. |
| 950 | 950 | * |
| 951 | 951 | * @return WPInv_Subscription|bool |
| 952 | 952 | */ |
| 953 | -function wpinv_get_subscription( $invoice ) { |
|
| 953 | +function wpinv_get_subscription($invoice) { |
|
| 954 | 954 | |
| 955 | 955 | // Abort if we do not have an invoice. |
| 956 | - if ( empty( $invoice ) ) { |
|
| 956 | + if (empty($invoice)) { |
|
| 957 | 957 | return false; |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | // Retrieve the invoice. |
| 961 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 961 | + $invoice = new WPInv_Invoice($invoice); |
|
| 962 | 962 | |
| 963 | 963 | // Ensure it is a recurring invoice. |
| 964 | - if ( ! $invoice->is_recurring() ) { |
|
| 964 | + if (!$invoice->is_recurring()) { |
|
| 965 | 965 | return false; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | // Fetch the subscription handler. |
| 969 | - $subs_db = new WPInv_Subscriptions_DB(); |
|
| 969 | + $subs_db = new WPInv_Subscriptions_DB(); |
|
| 970 | 970 | |
| 971 | 971 | // Fetch the parent in case it is a renewal. |
| 972 | - if ( $invoice->is_renewal() ) { |
|
| 973 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->get_parent_id(), 'number' => 1 ) ); |
|
| 972 | + if ($invoice->is_renewal()) { |
|
| 973 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->get_parent_id(), 'number' => 1)); |
|
| 974 | 974 | } else { |
| 975 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->get_id(), 'number' => 1 ) ); |
|
| 975 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->get_id(), 'number' => 1)); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | // Return the subscription if it exists. |
| 979 | - if ( ! empty( $subs ) ) { |
|
| 980 | - return reset( $subs ); |
|
| 979 | + if (!empty($subs)) { |
|
| 980 | + return reset($subs); |
|
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | return false; |
@@ -991,27 +991,27 @@ discard block |
||
| 991 | 991 | * @param array $status_transition |
| 992 | 992 | * @todo: descrease customer/store earnings |
| 993 | 993 | */ |
| 994 | -function getpaid_maybe_process_refund( $invoice_id, $invoice, $status_transition ) { |
|
| 994 | +function getpaid_maybe_process_refund($invoice_id, $invoice, $status_transition) { |
|
| 995 | 995 | |
| 996 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
| 996 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
| 997 | 997 | return; |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | $discount_code = $invoice->get_discount_code(); |
| 1001 | - if ( ! empty( $discount_code ) ) { |
|
| 1002 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 1001 | + if (!empty($discount_code)) { |
|
| 1002 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 1003 | 1003 | |
| 1004 | - if ( $discount->exists() ) { |
|
| 1004 | + if ($discount->exists()) { |
|
| 1005 | 1005 | $discount->increase_usage( -1 ); |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice_id ); |
|
| 1011 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice_id ); |
|
| 1012 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice_id ); |
|
| 1010 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice_id); |
|
| 1011 | + do_action('wpinv_refund_invoice', $invoice, $invoice_id); |
|
| 1012 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice_id); |
|
| 1013 | 1013 | } |
| 1014 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3 ); |
|
| 1014 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3); |
|
| 1015 | 1015 | |
| 1016 | 1016 | |
| 1017 | 1017 | /** |
@@ -1019,48 +1019,48 @@ discard block |
||
| 1019 | 1019 | * |
| 1020 | 1020 | * @param int $invoice_id |
| 1021 | 1021 | */ |
| 1022 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
| 1022 | +function getpaid_process_invoice_payment($invoice_id) { |
|
| 1023 | 1023 | |
| 1024 | 1024 | // Fetch the invoice. |
| 1025 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1025 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1026 | 1026 | |
| 1027 | 1027 | // We only want to do this once. |
| 1028 | - if ( 1 == get_post_meta( $invoice_id, 'wpinv_processed_payment', true ) ) { |
|
| 1028 | + if (1 == get_post_meta($invoice_id, 'wpinv_processed_payment', true)) { |
|
| 1029 | 1029 | return; |
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | - update_post_meta( $invoice_id, 'wpinv_processed_payment', 1 ); |
|
| 1032 | + update_post_meta($invoice_id, 'wpinv_processed_payment', 1); |
|
| 1033 | 1033 | |
| 1034 | 1034 | // Fires when processing a payment. |
| 1035 | - do_action( 'getpaid_process_payment', $invoice ); |
|
| 1035 | + do_action('getpaid_process_payment', $invoice); |
|
| 1036 | 1036 | |
| 1037 | 1037 | // Fire an action for each invoice item. |
| 1038 | - foreach( $invoice->get_items() as $item ) { |
|
| 1039 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
| 1038 | + foreach ($invoice->get_items() as $item) { |
|
| 1039 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | // Increase discount usage. |
| 1043 | 1043 | $discount_code = $invoice->get_discount_code(); |
| 1044 | - if ( ! empty( $discount_code ) ) { |
|
| 1045 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 1044 | + if (!empty($discount_code)) { |
|
| 1045 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 1046 | 1046 | |
| 1047 | - if ( $discount->exists() ) { |
|
| 1047 | + if ($discount->exists()) { |
|
| 1048 | 1048 | $discount->increase_usage(); |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | // Record reverse vat. |
| 1054 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
| 1054 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
| 1055 | 1055 | |
| 1056 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
| 1057 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
| 1056 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
| 1057 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | } |
| 1063 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
| 1063 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
| 1064 | 1064 | |
| 1065 | 1065 | /** |
| 1066 | 1066 | * Returns an array of invoice item columns |
@@ -1068,13 +1068,13 @@ discard block |
||
| 1068 | 1068 | * @param int|WPInv_Invoice $invoice |
| 1069 | 1069 | * @return array |
| 1070 | 1070 | */ |
| 1071 | -function getpaid_invoice_item_columns( $invoice ) { |
|
| 1071 | +function getpaid_invoice_item_columns($invoice) { |
|
| 1072 | 1072 | |
| 1073 | 1073 | // Prepare the invoice. |
| 1074 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 1074 | + $invoice = new WPInv_Invoice($invoice); |
|
| 1075 | 1075 | |
| 1076 | 1076 | // Abort if there is no invoice. |
| 1077 | - if ( 0 == $invoice->get_id() ) { |
|
| 1077 | + if (0 == $invoice->get_id()) { |
|
| 1078 | 1078 | return array(); |
| 1079 | 1079 | } |
| 1080 | 1080 | |
@@ -1082,47 +1082,47 @@ discard block |
||
| 1082 | 1082 | $columns = apply_filters( |
| 1083 | 1083 | 'getpaid_invoice_item_columns', |
| 1084 | 1084 | array( |
| 1085 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 1086 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 1087 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 1088 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 1085 | + 'name' => __('Item', 'invoicing'), |
|
| 1086 | + 'price' => __('Price', 'invoicing'), |
|
| 1087 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 1088 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 1089 | 1089 | ), |
| 1090 | 1090 | $invoice |
| 1091 | 1091 | ); |
| 1092 | 1092 | |
| 1093 | 1093 | // Quantities. |
| 1094 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
| 1094 | + if (isset($columns['quantity'])) { |
|
| 1095 | 1095 | |
| 1096 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 1097 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
| 1096 | + if ('hours' == $invoice->get_template()) { |
|
| 1097 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
| 1101 | - unset( $columns[ 'quantity' ] ); |
|
| 1100 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
| 1101 | + unset($columns['quantity']); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | |
| 1107 | 1107 | // Price. |
| 1108 | - if ( isset( $columns[ 'price' ] ) ) { |
|
| 1108 | + if (isset($columns['price'])) { |
|
| 1109 | 1109 | |
| 1110 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 1111 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
| 1110 | + if ('amount' == $invoice->get_template()) { |
|
| 1111 | + $columns['price'] = __('Amount', 'invoicing'); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 1115 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
| 1114 | + if ('hours' == $invoice->get_template()) { |
|
| 1115 | + $columns['price'] = __('Rate', 'invoicing'); |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | |
| 1121 | 1121 | // Sub total. |
| 1122 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
| 1122 | + if (isset($columns['subtotal'])) { |
|
| 1123 | 1123 | |
| 1124 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 1125 | - unset( $columns[ 'subtotal' ] ); |
|
| 1124 | + if ('amount' == $invoice->get_template()) { |
|
| 1125 | + unset($columns['subtotal']); |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | } |
@@ -1136,29 +1136,29 @@ discard block |
||
| 1136 | 1136 | * @param int|WPInv_Invoice $invoice |
| 1137 | 1137 | * @return array |
| 1138 | 1138 | */ |
| 1139 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
| 1139 | +function getpaid_invoice_totals_rows($invoice) { |
|
| 1140 | 1140 | |
| 1141 | 1141 | // Prepare the invoice. |
| 1142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 1142 | + $invoice = new WPInv_Invoice($invoice); |
|
| 1143 | 1143 | |
| 1144 | 1144 | // Abort if there is no invoice. |
| 1145 | - if ( 0 == $invoice->get_id() ) { |
|
| 1145 | + if (0 == $invoice->get_id()) { |
|
| 1146 | 1146 | return array(); |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | $totals = apply_filters( |
| 1150 | 1150 | 'getpaid_invoice_totals_rows', |
| 1151 | 1151 | array( |
| 1152 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 1153 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 1154 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 1155 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 1152 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 1153 | + 'tax' => __('Tax', 'invoicing'), |
|
| 1154 | + 'discount' => __('Discount', 'invoicing'), |
|
| 1155 | + 'total' => __('Total', 'invoicing'), |
|
| 1156 | 1156 | ), |
| 1157 | 1157 | $invoice |
| 1158 | 1158 | ); |
| 1159 | 1159 | |
| 1160 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
| 1161 | - unset( $totals['tax'] ); |
|
| 1160 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
| 1161 | + unset($totals['tax']); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | return $totals; |
@@ -1170,22 +1170,22 @@ discard block |
||
| 1170 | 1170 | * @param int $invoice_id |
| 1171 | 1171 | * @param WPInv_Invoice $invoice |
| 1172 | 1172 | */ |
| 1173 | -function getpaid_new_invoice( $invoice_id, $invoice ) { |
|
| 1173 | +function getpaid_new_invoice($invoice_id, $invoice) { |
|
| 1174 | 1174 | |
| 1175 | - if ( ! $invoice->get_status() ) { |
|
| 1175 | + if (!$invoice->get_status()) { |
|
| 1176 | 1176 | return; |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | // Add an invoice created note. |
| 1180 | 1180 | $invoice->add_note( |
| 1181 | 1181 | wp_sprintf( |
| 1182 | - __( 'Invoice created with the status "%s".', 'invoicing' ), |
|
| 1183 | - wpinv_status_nicename( $invoice->get_status() ) |
|
| 1182 | + __('Invoice created with the status "%s".', 'invoicing'), |
|
| 1183 | + wpinv_status_nicename($invoice->get_status()) |
|
| 1184 | 1184 | ) |
| 1185 | 1185 | ); |
| 1186 | 1186 | |
| 1187 | 1187 | } |
| 1188 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice', 10, 2 ); |
|
| 1188 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice', 10, 2); |
|
| 1189 | 1189 | |
| 1190 | 1190 | /** |
| 1191 | 1191 | * This function updates invoice caches. |
@@ -1193,21 +1193,21 @@ discard block |
||
| 1193 | 1193 | * @param int $invoice_id |
| 1194 | 1194 | * @param WPInv_Invoice $invoice |
| 1195 | 1195 | */ |
| 1196 | -function getpaid_update_invoice_caches( $invoice_id, $invoice ) { |
|
| 1196 | +function getpaid_update_invoice_caches($invoice_id, $invoice) { |
|
| 1197 | 1197 | |
| 1198 | 1198 | // Cache invoice number. |
| 1199 | - wp_cache_set( $invoice->get_number(), $invoice_id, "getpaid_invoice_numbers_to_invoice_ids" ); |
|
| 1199 | + wp_cache_set($invoice->get_number(), $invoice_id, "getpaid_invoice_numbers_to_invoice_ids"); |
|
| 1200 | 1200 | |
| 1201 | 1201 | // Cache invoice key. |
| 1202 | - wp_cache_set( $invoice->get_key(), $invoice_id, "getpaid_invoice_keys_to_invoice_ids" ); |
|
| 1202 | + wp_cache_set($invoice->get_key(), $invoice_id, "getpaid_invoice_keys_to_invoice_ids"); |
|
| 1203 | 1203 | |
| 1204 | 1204 | // (Maybe) cache transaction id. |
| 1205 | 1205 | $transaction_id = $invoice->get_transaction_id(); |
| 1206 | 1206 | |
| 1207 | - if ( ! empty( $transaction_id ) ) { |
|
| 1208 | - wp_cache_set( $transaction_id, $invoice_id, "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
| 1207 | + if (!empty($transaction_id)) { |
|
| 1208 | + wp_cache_set($transaction_id, $invoice_id, "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | } |
| 1212 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5, 2 ); |
|
| 1213 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5, 2 ); |
|
| 1212 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5, 2); |
|
| 1213 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5, 2); |
|
@@ -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, |
@@ -79,20 +79,20 @@ discard block |
||
| 79 | 79 | 'transaction_id' => '', |
| 80 | 80 | 'currency' => '', |
| 81 | 81 | 'disable_taxes' => false, |
| 82 | - 'subscription_id' => null, |
|
| 83 | - 'is_viewed' => false, |
|
| 84 | - 'email_cc' => '', |
|
| 85 | - 'template' => 'quantity', // hours, amount only |
|
| 82 | + 'subscription_id' => null, |
|
| 83 | + 'is_viewed' => false, |
|
| 84 | + 'email_cc' => '', |
|
| 85 | + 'template' => 'quantity', // hours, amount only |
|
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Stores meta in cache for future reads. |
|
| 90 | - * |
|
| 91 | - * A group must be set to to enable caching. |
|
| 92 | - * |
|
| 93 | - * @var string |
|
| 94 | - */ |
|
| 95 | - protected $cache_group = 'getpaid_invoices'; |
|
| 89 | + * Stores meta in cache for future reads. |
|
| 90 | + * |
|
| 91 | + * A group must be set to to enable caching. |
|
| 92 | + * |
|
| 93 | + * @var string |
|
| 94 | + */ |
|
| 95 | + protected $cache_group = 'getpaid_invoices'; |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Stores a reference to the original WP_Post object |
@@ -106,104 +106,104 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @var int |
| 108 | 108 | */ |
| 109 | - protected $recurring_item = null; |
|
| 109 | + protected $recurring_item = null; |
|
| 110 | 110 | |
| 111 | - /** |
|
| 111 | + /** |
|
| 112 | 112 | * Stores an array of item totals. |
| 113 | - * |
|
| 114 | - * e.g $totals['discount'] = array( |
|
| 115 | - * 'initial' => 10, |
|
| 116 | - * 'recurring' => 10, |
|
| 117 | - * ) |
|
| 113 | + * |
|
| 114 | + * e.g $totals['discount'] = array( |
|
| 115 | + * 'initial' => 10, |
|
| 116 | + * 'recurring' => 10, |
|
| 117 | + * ) |
|
| 118 | 118 | * |
| 119 | 119 | * @var array |
| 120 | 120 | */ |
| 121 | - protected $totals = array(); |
|
| 121 | + protected $totals = array(); |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Stores the status transition information. |
|
| 125 | - * |
|
| 126 | - * @since 1.0.19 |
|
| 127 | - * @var bool |
|
| 128 | - */ |
|
| 129 | - protected $status_transition = false; |
|
| 123 | + /** |
|
| 124 | + * Stores the status transition information. |
|
| 125 | + * |
|
| 126 | + * @since 1.0.19 |
|
| 127 | + * @var bool |
|
| 128 | + */ |
|
| 129 | + protected $status_transition = false; |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 133 | - * |
|
| 134 | - * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 135 | - */ |
|
| 132 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 133 | + * |
|
| 134 | + * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 135 | + */ |
|
| 136 | 136 | public function __construct( $invoice = false ) { |
| 137 | 137 | |
| 138 | 138 | parent::__construct( $invoice ); |
| 139 | 139 | |
| 140 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 141 | - $this->set_id( $invoice ); |
|
| 142 | - } elseif ( $invoice instanceof self ) { |
|
| 143 | - $this->set_id( $invoice->get_id() ); |
|
| 144 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 145 | - $this->set_id( $invoice->ID ); |
|
| 146 | - } elseif ( is_array( $invoice ) ) { |
|
| 147 | - $this->set_props( $invoice ); |
|
| 148 | - |
|
| 149 | - if ( isset( $invoice['ID'] ) ) { |
|
| 150 | - $this->set_id( $invoice['ID'] ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 154 | - $this->set_id( $invoice_id ); |
|
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - }else { |
|
| 160 | - $this->set_object_read( true ); |
|
| 161 | - } |
|
| 140 | + if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 141 | + $this->set_id( $invoice ); |
|
| 142 | + } elseif ( $invoice instanceof self ) { |
|
| 143 | + $this->set_id( $invoice->get_id() ); |
|
| 144 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 145 | + $this->set_id( $invoice->ID ); |
|
| 146 | + } elseif ( is_array( $invoice ) ) { |
|
| 147 | + $this->set_props( $invoice ); |
|
| 148 | + |
|
| 149 | + if ( isset( $invoice['ID'] ) ) { |
|
| 150 | + $this->set_id( $invoice['ID'] ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 154 | + $this->set_id( $invoice_id ); |
|
| 155 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 156 | + $this->set_id( $invoice_id ); |
|
| 157 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 158 | + $this->set_id( $invoice_id ); |
|
| 159 | + }else { |
|
| 160 | + $this->set_object_read( true ); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | // Load the datastore. |
| 164 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 164 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 165 | 165 | |
| 166 | - if ( $this->get_id() > 0 ) { |
|
| 166 | + if ( $this->get_id() > 0 ) { |
|
| 167 | 167 | $this->post = get_post( $this->get_id() ); |
| 168 | 168 | $this->ID = $this->get_id(); |
| 169 | - $this->data_store->read( $this ); |
|
| 169 | + $this->data_store->read( $this ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * Given an invoice key/number, it returns its id. |
|
| 176 | - * |
|
| 177 | - * |
|
| 178 | - * @static |
|
| 179 | - * @param string $value The invoice key or number |
|
| 180 | - * @param string $field Either key, transaction_id or number. |
|
| 181 | - * @since 1.0.15 |
|
| 182 | - * @return int |
|
| 183 | - */ |
|
| 184 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 175 | + * Given an invoice key/number, it returns its id. |
|
| 176 | + * |
|
| 177 | + * |
|
| 178 | + * @static |
|
| 179 | + * @param string $value The invoice key or number |
|
| 180 | + * @param string $field Either key, transaction_id or number. |
|
| 181 | + * @since 1.0.15 |
|
| 182 | + * @return int |
|
| 183 | + */ |
|
| 184 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 185 | 185 | global $wpdb; |
| 186 | 186 | |
| 187 | - // Trim the value. |
|
| 188 | - $value = trim( $value ); |
|
| 187 | + // Trim the value. |
|
| 188 | + $value = trim( $value ); |
|
| 189 | 189 | |
| 190 | - if ( empty( $value ) ) { |
|
| 191 | - return 0; |
|
| 192 | - } |
|
| 190 | + if ( empty( $value ) ) { |
|
| 191 | + return 0; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | // Valid fields. |
| 195 | 195 | $fields = array( 'key', 'number', 'transaction_id' ); |
| 196 | 196 | |
| 197 | - // Ensure a field has been passed. |
|
| 198 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 199 | - return 0; |
|
| 200 | - } |
|
| 197 | + // Ensure a field has been passed. |
|
| 198 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 199 | + return 0; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - // Maybe retrieve from the cache. |
|
| 203 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 204 | - if ( ! empty( $invoice_id ) ) { |
|
| 205 | - return $invoice_id; |
|
| 206 | - } |
|
| 202 | + // Maybe retrieve from the cache. |
|
| 203 | + $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 204 | + if ( ! empty( $invoice_id ) ) { |
|
| 205 | + return $invoice_id; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | // Fetch from the db. |
| 209 | 209 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | - if ( empty( $invoice_id ) ) { |
|
| 215 | - return 0; |
|
| 216 | - } |
|
| 214 | + if ( empty( $invoice_id ) ) { |
|
| 215 | + return 0; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - // Update the cache with our data |
|
| 219 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 218 | + // Update the cache with our data |
|
| 219 | + wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 220 | 220 | |
| 221 | - return $invoice_id; |
|
| 221 | + return $invoice_id; |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -244,73 +244,73 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | - * Get parent invoice ID. |
|
| 248 | - * |
|
| 249 | - * @since 1.0.19 |
|
| 250 | - * @param string $context View or edit context. |
|
| 251 | - * @return int |
|
| 252 | - */ |
|
| 253 | - public function get_parent_id( $context = 'view' ) { |
|
| 254 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 247 | + * Get parent invoice ID. |
|
| 248 | + * |
|
| 249 | + * @since 1.0.19 |
|
| 250 | + * @param string $context View or edit context. |
|
| 251 | + * @return int |
|
| 252 | + */ |
|
| 253 | + public function get_parent_id( $context = 'view' ) { |
|
| 254 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * Get parent invoice. |
|
| 259 | - * |
|
| 260 | - * @since 1.0.19 |
|
| 261 | - * @return WPInv_Invoice |
|
| 262 | - */ |
|
| 258 | + * Get parent invoice. |
|
| 259 | + * |
|
| 260 | + * @since 1.0.19 |
|
| 261 | + * @return WPInv_Invoice |
|
| 262 | + */ |
|
| 263 | 263 | public function get_parent_payment() { |
| 264 | 264 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | - * Alias for self::get_parent_payment(). |
|
| 269 | - * |
|
| 270 | - * @since 1.0.19 |
|
| 271 | - * @return WPInv_Invoice |
|
| 272 | - */ |
|
| 268 | + * Alias for self::get_parent_payment(). |
|
| 269 | + * |
|
| 270 | + * @since 1.0.19 |
|
| 271 | + * @return WPInv_Invoice |
|
| 272 | + */ |
|
| 273 | 273 | public function get_parent() { |
| 274 | 274 | return $this->get_parent_payment(); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | - * Get invoice status. |
|
| 279 | - * |
|
| 280 | - * @since 1.0.19 |
|
| 281 | - * @param string $context View or edit context. |
|
| 282 | - * @return string |
|
| 283 | - */ |
|
| 284 | - public function get_status( $context = 'view' ) { |
|
| 285 | - return $this->get_prop( 'status', $context ); |
|
| 286 | - } |
|
| 278 | + * Get invoice status. |
|
| 279 | + * |
|
| 280 | + * @since 1.0.19 |
|
| 281 | + * @param string $context View or edit context. |
|
| 282 | + * @return string |
|
| 283 | + */ |
|
| 284 | + public function get_status( $context = 'view' ) { |
|
| 285 | + return $this->get_prop( 'status', $context ); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - /** |
|
| 289 | - * Retrieves an array of possible invoice statuses. |
|
| 290 | - * |
|
| 291 | - * @since 1.0.19 |
|
| 292 | - * @return array |
|
| 293 | - */ |
|
| 294 | - public function get_all_statuses() { |
|
| 288 | + /** |
|
| 289 | + * Retrieves an array of possible invoice statuses. |
|
| 290 | + * |
|
| 291 | + * @since 1.0.19 |
|
| 292 | + * @return array |
|
| 293 | + */ |
|
| 294 | + public function get_all_statuses() { |
|
| 295 | 295 | |
| 296 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 296 | + $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 297 | 297 | |
| 298 | - // For backwards compatibility. |
|
| 299 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 298 | + // For backwards compatibility. |
|
| 299 | + if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 300 | 300 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
| 301 | - } |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - return $statuses; |
|
| 303 | + return $statuses; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | - * Get invoice status nice name. |
|
| 308 | - * |
|
| 309 | - * @since 1.0.19 |
|
| 310 | - * @return string |
|
| 311 | - */ |
|
| 307 | + * Get invoice status nice name. |
|
| 308 | + * |
|
| 309 | + * @since 1.0.19 |
|
| 310 | + * @return string |
|
| 311 | + */ |
|
| 312 | 312 | public function get_status_nicename() { |
| 313 | - $statuses = $this->get_all_statuses(); |
|
| 313 | + $statuses = $this->get_all_statuses(); |
|
| 314 | 314 | |
| 315 | 315 | $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
| 316 | 316 | |
@@ -318,20 +318,20 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | - * Get plugin version when the invoice was created. |
|
| 322 | - * |
|
| 323 | - * @since 1.0.19 |
|
| 324 | - * @param string $context View or edit context. |
|
| 325 | - * @return string |
|
| 326 | - */ |
|
| 327 | - public function get_version( $context = 'view' ) { |
|
| 328 | - return $this->get_prop( 'version', $context ); |
|
| 329 | - } |
|
| 321 | + * Get plugin version when the invoice was created. |
|
| 322 | + * |
|
| 323 | + * @since 1.0.19 |
|
| 324 | + * @param string $context View or edit context. |
|
| 325 | + * @return string |
|
| 326 | + */ |
|
| 327 | + public function get_version( $context = 'view' ) { |
|
| 328 | + return $this->get_prop( 'version', $context ); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * @deprecated |
|
| 333 | - */ |
|
| 334 | - public function get_invoice_date( $formatted = true ) { |
|
| 331 | + /** |
|
| 332 | + * @deprecated |
|
| 333 | + */ |
|
| 334 | + public function get_invoice_date( $formatted = true ) { |
|
| 335 | 335 | $date_completed = $this->get_date_completed(); |
| 336 | 336 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 337 | 337 | |
@@ -348,187 +348,187 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
| 351 | - * Get date when the invoice was created. |
|
| 352 | - * |
|
| 353 | - * @since 1.0.19 |
|
| 354 | - * @param string $context View or edit context. |
|
| 355 | - * @return string |
|
| 356 | - */ |
|
| 357 | - public function get_date_created( $context = 'view' ) { |
|
| 358 | - return $this->get_prop( 'date_created', $context ); |
|
| 359 | - } |
|
| 351 | + * Get date when the invoice was created. |
|
| 352 | + * |
|
| 353 | + * @since 1.0.19 |
|
| 354 | + * @param string $context View or edit context. |
|
| 355 | + * @return string |
|
| 356 | + */ |
|
| 357 | + public function get_date_created( $context = 'view' ) { |
|
| 358 | + return $this->get_prop( 'date_created', $context ); |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Alias for self::get_date_created(). |
|
| 363 | - * |
|
| 364 | - * @since 1.0.19 |
|
| 365 | - * @param string $context View or edit context. |
|
| 366 | - * @return string |
|
| 367 | - */ |
|
| 368 | - public function get_created_date( $context = 'view' ) { |
|
| 369 | - return $this->get_date_created( $context ); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Get GMT date when the invoice was created. |
|
| 374 | - * |
|
| 375 | - * @since 1.0.19 |
|
| 376 | - * @param string $context View or edit context. |
|
| 377 | - * @return string |
|
| 378 | - */ |
|
| 379 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 361 | + /** |
|
| 362 | + * Alias for self::get_date_created(). |
|
| 363 | + * |
|
| 364 | + * @since 1.0.19 |
|
| 365 | + * @param string $context View or edit context. |
|
| 366 | + * @return string |
|
| 367 | + */ |
|
| 368 | + public function get_created_date( $context = 'view' ) { |
|
| 369 | + return $this->get_date_created( $context ); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Get GMT date when the invoice was created. |
|
| 374 | + * |
|
| 375 | + * @since 1.0.19 |
|
| 376 | + * @param string $context View or edit context. |
|
| 377 | + * @return string |
|
| 378 | + */ |
|
| 379 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 380 | 380 | $date = $this->get_date_created( $context ); |
| 381 | 381 | |
| 382 | 382 | if ( $date ) { |
| 383 | 383 | $date = get_gmt_from_date( $date ); |
| 384 | 384 | } |
| 385 | - return $date; |
|
| 385 | + return $date; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | - * Get date when the invoice was last modified. |
|
| 390 | - * |
|
| 391 | - * @since 1.0.19 |
|
| 392 | - * @param string $context View or edit context. |
|
| 393 | - * @return string |
|
| 394 | - */ |
|
| 395 | - public function get_date_modified( $context = 'view' ) { |
|
| 396 | - return $this->get_prop( 'date_modified', $context ); |
|
| 397 | - } |
|
| 389 | + * Get date when the invoice was last modified. |
|
| 390 | + * |
|
| 391 | + * @since 1.0.19 |
|
| 392 | + * @param string $context View or edit context. |
|
| 393 | + * @return string |
|
| 394 | + */ |
|
| 395 | + public function get_date_modified( $context = 'view' ) { |
|
| 396 | + return $this->get_prop( 'date_modified', $context ); |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Alias for self::get_date_modified(). |
|
| 401 | - * |
|
| 402 | - * @since 1.0.19 |
|
| 403 | - * @param string $context View or edit context. |
|
| 404 | - * @return string |
|
| 405 | - */ |
|
| 406 | - public function get_modified_date( $context = 'view' ) { |
|
| 407 | - return $this->get_date_modified( $context ); |
|
| 399 | + /** |
|
| 400 | + * Alias for self::get_date_modified(). |
|
| 401 | + * |
|
| 402 | + * @since 1.0.19 |
|
| 403 | + * @param string $context View or edit context. |
|
| 404 | + * @return string |
|
| 405 | + */ |
|
| 406 | + public function get_modified_date( $context = 'view' ) { |
|
| 407 | + return $this->get_date_modified( $context ); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | - * Get GMT date when the invoice was last modified. |
|
| 412 | - * |
|
| 413 | - * @since 1.0.19 |
|
| 414 | - * @param string $context View or edit context. |
|
| 415 | - * @return string |
|
| 416 | - */ |
|
| 417 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 411 | + * Get GMT date when the invoice was last modified. |
|
| 412 | + * |
|
| 413 | + * @since 1.0.19 |
|
| 414 | + * @param string $context View or edit context. |
|
| 415 | + * @return string |
|
| 416 | + */ |
|
| 417 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 418 | 418 | $date = $this->get_date_modified( $context ); |
| 419 | 419 | |
| 420 | 420 | if ( $date ) { |
| 421 | 421 | $date = get_gmt_from_date( $date ); |
| 422 | 422 | } |
| 423 | - return $date; |
|
| 423 | + return $date; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | - * Get the invoice due date. |
|
| 428 | - * |
|
| 429 | - * @since 1.0.19 |
|
| 430 | - * @param string $context View or edit context. |
|
| 431 | - * @return string |
|
| 432 | - */ |
|
| 433 | - public function get_due_date( $context = 'view' ) { |
|
| 434 | - return $this->get_prop( 'due_date', $context ); |
|
| 427 | + * Get the invoice due date. |
|
| 428 | + * |
|
| 429 | + * @since 1.0.19 |
|
| 430 | + * @param string $context View or edit context. |
|
| 431 | + * @return string |
|
| 432 | + */ |
|
| 433 | + public function get_due_date( $context = 'view' ) { |
|
| 434 | + return $this->get_prop( 'due_date', $context ); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
| 438 | - * Alias for self::get_due_date(). |
|
| 439 | - * |
|
| 440 | - * @since 1.0.19 |
|
| 441 | - * @param string $context View or edit context. |
|
| 442 | - * @return string |
|
| 443 | - */ |
|
| 444 | - public function get_date_due( $context = 'view' ) { |
|
| 445 | - return $this->get_due_date( $context ); |
|
| 438 | + * Alias for self::get_due_date(). |
|
| 439 | + * |
|
| 440 | + * @since 1.0.19 |
|
| 441 | + * @param string $context View or edit context. |
|
| 442 | + * @return string |
|
| 443 | + */ |
|
| 444 | + public function get_date_due( $context = 'view' ) { |
|
| 445 | + return $this->get_due_date( $context ); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | - * Get the invoice GMT due date. |
|
| 450 | - * |
|
| 451 | - * @since 1.0.19 |
|
| 452 | - * @param string $context View or edit context. |
|
| 453 | - * @return string |
|
| 454 | - */ |
|
| 455 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 449 | + * Get the invoice GMT due date. |
|
| 450 | + * |
|
| 451 | + * @since 1.0.19 |
|
| 452 | + * @param string $context View or edit context. |
|
| 453 | + * @return string |
|
| 454 | + */ |
|
| 455 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 456 | 456 | $date = $this->get_due_date( $context ); |
| 457 | 457 | |
| 458 | 458 | if ( $date ) { |
| 459 | 459 | $date = get_gmt_from_date( $date ); |
| 460 | 460 | } |
| 461 | - return $date; |
|
| 461 | + return $date; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
| 465 | - * Alias for self::get_due_date_gmt(). |
|
| 466 | - * |
|
| 467 | - * @since 1.0.19 |
|
| 468 | - * @param string $context View or edit context. |
|
| 469 | - * @return string |
|
| 470 | - */ |
|
| 471 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 472 | - return $this->get_due_date_gmt( $context ); |
|
| 465 | + * Alias for self::get_due_date_gmt(). |
|
| 466 | + * |
|
| 467 | + * @since 1.0.19 |
|
| 468 | + * @param string $context View or edit context. |
|
| 469 | + * @return string |
|
| 470 | + */ |
|
| 471 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 472 | + return $this->get_due_date_gmt( $context ); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | - * Get date when the invoice was completed. |
|
| 477 | - * |
|
| 478 | - * @since 1.0.19 |
|
| 479 | - * @param string $context View or edit context. |
|
| 480 | - * @return string |
|
| 481 | - */ |
|
| 482 | - public function get_completed_date( $context = 'view' ) { |
|
| 483 | - return $this->get_prop( 'completed_date', $context ); |
|
| 476 | + * Get date when the invoice was completed. |
|
| 477 | + * |
|
| 478 | + * @since 1.0.19 |
|
| 479 | + * @param string $context View or edit context. |
|
| 480 | + * @return string |
|
| 481 | + */ |
|
| 482 | + public function get_completed_date( $context = 'view' ) { |
|
| 483 | + return $this->get_prop( 'completed_date', $context ); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
| 487 | - * Alias for self::get_completed_date(). |
|
| 488 | - * |
|
| 489 | - * @since 1.0.19 |
|
| 490 | - * @param string $context View or edit context. |
|
| 491 | - * @return string |
|
| 492 | - */ |
|
| 493 | - public function get_date_completed( $context = 'view' ) { |
|
| 494 | - return $this->get_completed_date( $context ); |
|
| 487 | + * Alias for self::get_completed_date(). |
|
| 488 | + * |
|
| 489 | + * @since 1.0.19 |
|
| 490 | + * @param string $context View or edit context. |
|
| 491 | + * @return string |
|
| 492 | + */ |
|
| 493 | + public function get_date_completed( $context = 'view' ) { |
|
| 494 | + return $this->get_completed_date( $context ); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
| 498 | - * Get GMT date when the invoice was was completed. |
|
| 499 | - * |
|
| 500 | - * @since 1.0.19 |
|
| 501 | - * @param string $context View or edit context. |
|
| 502 | - * @return string |
|
| 503 | - */ |
|
| 504 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 498 | + * Get GMT date when the invoice was was completed. |
|
| 499 | + * |
|
| 500 | + * @since 1.0.19 |
|
| 501 | + * @param string $context View or edit context. |
|
| 502 | + * @return string |
|
| 503 | + */ |
|
| 504 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 505 | 505 | $date = $this->get_completed_date( $context ); |
| 506 | 506 | |
| 507 | 507 | if ( $date ) { |
| 508 | 508 | $date = get_gmt_from_date( $date ); |
| 509 | 509 | } |
| 510 | - return $date; |
|
| 510 | + return $date; |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
| 514 | - * Alias for self::get_completed_date_gmt(). |
|
| 515 | - * |
|
| 516 | - * @since 1.0.19 |
|
| 517 | - * @param string $context View or edit context. |
|
| 518 | - * @return string |
|
| 519 | - */ |
|
| 520 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 521 | - return $this->get_completed_date_gmt( $context ); |
|
| 514 | + * Alias for self::get_completed_date_gmt(). |
|
| 515 | + * |
|
| 516 | + * @since 1.0.19 |
|
| 517 | + * @param string $context View or edit context. |
|
| 518 | + * @return string |
|
| 519 | + */ |
|
| 520 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 521 | + return $this->get_completed_date_gmt( $context ); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
| 525 | - * Get the invoice number. |
|
| 526 | - * |
|
| 527 | - * @since 1.0.19 |
|
| 528 | - * @param string $context View or edit context. |
|
| 529 | - * @return string |
|
| 530 | - */ |
|
| 531 | - public function get_number( $context = 'view' ) { |
|
| 525 | + * Get the invoice number. |
|
| 526 | + * |
|
| 527 | + * @since 1.0.19 |
|
| 528 | + * @param string $context View or edit context. |
|
| 529 | + * @return string |
|
| 530 | + */ |
|
| 531 | + public function get_number( $context = 'view' ) { |
|
| 532 | 532 | $number = $this->get_prop( 'number', $context ); |
| 533 | 533 | |
| 534 | 534 | if ( empty( $number ) ) { |
@@ -536,17 +536,17 @@ discard block |
||
| 536 | 536 | $this->set_number( $number ); |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - return $number; |
|
| 539 | + return $number; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
| 543 | - * Get the invoice key. |
|
| 544 | - * |
|
| 545 | - * @since 1.0.19 |
|
| 546 | - * @param string $context View or edit context. |
|
| 547 | - * @return string |
|
| 548 | - */ |
|
| 549 | - public function get_key( $context = 'view' ) { |
|
| 543 | + * Get the invoice key. |
|
| 544 | + * |
|
| 545 | + * @since 1.0.19 |
|
| 546 | + * @param string $context View or edit context. |
|
| 547 | + * @return string |
|
| 548 | + */ |
|
| 549 | + public function get_key( $context = 'view' ) { |
|
| 550 | 550 | $key = $this->get_prop( 'key', $context ); |
| 551 | 551 | |
| 552 | 552 | if ( empty( $key ) ) { |
@@ -554,24 +554,24 @@ discard block |
||
| 554 | 554 | $this->set_key( $key ); |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - return $key; |
|
| 557 | + return $key; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
| 561 | - * Get the invoice type. |
|
| 562 | - * |
|
| 563 | - * @since 1.0.19 |
|
| 564 | - * @param string $context View or edit context. |
|
| 565 | - * @return string |
|
| 566 | - */ |
|
| 567 | - public function get_type( $context = 'view' ) { |
|
| 561 | + * Get the invoice type. |
|
| 562 | + * |
|
| 563 | + * @since 1.0.19 |
|
| 564 | + * @param string $context View or edit context. |
|
| 565 | + * @return string |
|
| 566 | + */ |
|
| 567 | + public function get_type( $context = 'view' ) { |
|
| 568 | 568 | return $this->get_prop( 'type', $context ); |
| 569 | - } |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | - /** |
|
| 572 | - * @deprecated |
|
| 573 | - */ |
|
| 574 | - public function get_invoice_quote_type( $post_id ) { |
|
| 571 | + /** |
|
| 572 | + * @deprecated |
|
| 573 | + */ |
|
| 574 | + public function get_invoice_quote_type( $post_id ) { |
|
| 575 | 575 | if ( empty( $post_id ) ) { |
| 576 | 576 | return ''; |
| 577 | 577 | } |
@@ -588,35 +588,35 @@ discard block |
||
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
| 591 | - * Get the invoice post type. |
|
| 592 | - * |
|
| 593 | - * @since 1.0.19 |
|
| 594 | - * @param string $context View or edit context. |
|
| 595 | - * @return string |
|
| 596 | - */ |
|
| 597 | - public function get_post_type( $context = 'view' ) { |
|
| 591 | + * Get the invoice post type. |
|
| 592 | + * |
|
| 593 | + * @since 1.0.19 |
|
| 594 | + * @param string $context View or edit context. |
|
| 595 | + * @return string |
|
| 596 | + */ |
|
| 597 | + public function get_post_type( $context = 'view' ) { |
|
| 598 | 598 | return $this->get_prop( 'post_type', $context ); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
| 602 | - * Get the invoice mode. |
|
| 603 | - * |
|
| 604 | - * @since 1.0.19 |
|
| 605 | - * @param string $context View or edit context. |
|
| 606 | - * @return string |
|
| 607 | - */ |
|
| 608 | - public function get_mode( $context = 'view' ) { |
|
| 602 | + * Get the invoice mode. |
|
| 603 | + * |
|
| 604 | + * @since 1.0.19 |
|
| 605 | + * @param string $context View or edit context. |
|
| 606 | + * @return string |
|
| 607 | + */ |
|
| 608 | + public function get_mode( $context = 'view' ) { |
|
| 609 | 609 | return $this->get_prop( 'mode', $context ); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
| 613 | - * Get the invoice path. |
|
| 614 | - * |
|
| 615 | - * @since 1.0.19 |
|
| 616 | - * @param string $context View or edit context. |
|
| 617 | - * @return string |
|
| 618 | - */ |
|
| 619 | - public function get_path( $context = 'view' ) { |
|
| 613 | + * Get the invoice path. |
|
| 614 | + * |
|
| 615 | + * @since 1.0.19 |
|
| 616 | + * @param string $context View or edit context. |
|
| 617 | + * @return string |
|
| 618 | + */ |
|
| 619 | + public function get_path( $context = 'view' ) { |
|
| 620 | 620 | $path = $this->get_prop( 'path', $context ); |
| 621 | 621 | |
| 622 | 622 | if ( empty( $path ) ) { |
@@ -624,73 +624,73 @@ discard block |
||
| 624 | 624 | $path = sanitize_title( $prefix . $this->get_id() ); |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - return $path; |
|
| 627 | + return $path; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
| 631 | - * Get the invoice name/title. |
|
| 632 | - * |
|
| 633 | - * @since 1.0.19 |
|
| 634 | - * @param string $context View or edit context. |
|
| 635 | - * @return string |
|
| 636 | - */ |
|
| 637 | - public function get_name( $context = 'view' ) { |
|
| 631 | + * Get the invoice name/title. |
|
| 632 | + * |
|
| 633 | + * @since 1.0.19 |
|
| 634 | + * @param string $context View or edit context. |
|
| 635 | + * @return string |
|
| 636 | + */ |
|
| 637 | + public function get_name( $context = 'view' ) { |
|
| 638 | 638 | $name = $this->get_prop( 'title', $context ); |
| 639 | 639 | |
| 640 | - return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 640 | + return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | - * Alias of self::get_name(). |
|
| 645 | - * |
|
| 646 | - * @since 1.0.19 |
|
| 647 | - * @param string $context View or edit context. |
|
| 648 | - * @return string |
|
| 649 | - */ |
|
| 650 | - public function get_title( $context = 'view' ) { |
|
| 651 | - return $this->get_name( $context ); |
|
| 644 | + * Alias of self::get_name(). |
|
| 645 | + * |
|
| 646 | + * @since 1.0.19 |
|
| 647 | + * @param string $context View or edit context. |
|
| 648 | + * @return string |
|
| 649 | + */ |
|
| 650 | + public function get_title( $context = 'view' ) { |
|
| 651 | + return $this->get_name( $context ); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
| 655 | - * Get the invoice description. |
|
| 656 | - * |
|
| 657 | - * @since 1.0.19 |
|
| 658 | - * @param string $context View or edit context. |
|
| 659 | - * @return string |
|
| 660 | - */ |
|
| 661 | - public function get_description( $context = 'view' ) { |
|
| 662 | - return $this->get_prop( 'description', $context ); |
|
| 655 | + * Get the invoice description. |
|
| 656 | + * |
|
| 657 | + * @since 1.0.19 |
|
| 658 | + * @param string $context View or edit context. |
|
| 659 | + * @return string |
|
| 660 | + */ |
|
| 661 | + public function get_description( $context = 'view' ) { |
|
| 662 | + return $this->get_prop( 'description', $context ); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** |
| 666 | - * Alias of self::get_description(). |
|
| 667 | - * |
|
| 668 | - * @since 1.0.19 |
|
| 669 | - * @param string $context View or edit context. |
|
| 670 | - * @return string |
|
| 671 | - */ |
|
| 672 | - public function get_excerpt( $context = 'view' ) { |
|
| 673 | - return $this->get_description( $context ); |
|
| 666 | + * Alias of self::get_description(). |
|
| 667 | + * |
|
| 668 | + * @since 1.0.19 |
|
| 669 | + * @param string $context View or edit context. |
|
| 670 | + * @return string |
|
| 671 | + */ |
|
| 672 | + public function get_excerpt( $context = 'view' ) { |
|
| 673 | + return $this->get_description( $context ); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * Alias of self::get_description(). |
|
| 678 | - * |
|
| 679 | - * @since 1.0.19 |
|
| 680 | - * @param string $context View or edit context. |
|
| 681 | - * @return string |
|
| 682 | - */ |
|
| 683 | - public function get_summary( $context = 'view' ) { |
|
| 684 | - return $this->get_description( $context ); |
|
| 677 | + * Alias of self::get_description(). |
|
| 678 | + * |
|
| 679 | + * @since 1.0.19 |
|
| 680 | + * @param string $context View or edit context. |
|
| 681 | + * @return string |
|
| 682 | + */ |
|
| 683 | + public function get_summary( $context = 'view' ) { |
|
| 684 | + return $this->get_description( $context ); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
| 688 | - * Returns the user info. |
|
| 689 | - * |
|
| 690 | - * @since 1.0.19 |
|
| 688 | + * Returns the user info. |
|
| 689 | + * |
|
| 690 | + * @since 1.0.19 |
|
| 691 | 691 | * @param string $context View or edit context. |
| 692 | - * @return array |
|
| 693 | - */ |
|
| 692 | + * @return array |
|
| 693 | + */ |
|
| 694 | 694 | public function get_user_info( $context = 'view' ) { |
| 695 | 695 | |
| 696 | 696 | $user_info = array( |
@@ -707,605 +707,605 @@ discard block |
||
| 707 | 707 | 'company' => $this->get_company( $context ), |
| 708 | 708 | 'vat_number' => $this->get_vat_number( $context ), |
| 709 | 709 | 'discount' => $this->get_discount_code( $context ), |
| 710 | - ); |
|
| 710 | + ); |
|
| 711 | 711 | |
| 712 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 712 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 713 | 713 | |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | - * Get the customer id. |
|
| 718 | - * |
|
| 719 | - * @since 1.0.19 |
|
| 720 | - * @param string $context View or edit context. |
|
| 721 | - * @return int |
|
| 722 | - */ |
|
| 723 | - public function get_author( $context = 'view' ) { |
|
| 724 | - return (int) $this->get_prop( 'author', $context ); |
|
| 717 | + * Get the customer id. |
|
| 718 | + * |
|
| 719 | + * @since 1.0.19 |
|
| 720 | + * @param string $context View or edit context. |
|
| 721 | + * @return int |
|
| 722 | + */ |
|
| 723 | + public function get_author( $context = 'view' ) { |
|
| 724 | + return (int) $this->get_prop( 'author', $context ); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | - * Alias of self::get_author(). |
|
| 729 | - * |
|
| 730 | - * @since 1.0.19 |
|
| 731 | - * @param string $context View or edit context. |
|
| 732 | - * @return int |
|
| 733 | - */ |
|
| 734 | - public function get_user_id( $context = 'view' ) { |
|
| 735 | - return $this->get_author( $context ); |
|
| 728 | + * Alias of self::get_author(). |
|
| 729 | + * |
|
| 730 | + * @since 1.0.19 |
|
| 731 | + * @param string $context View or edit context. |
|
| 732 | + * @return int |
|
| 733 | + */ |
|
| 734 | + public function get_user_id( $context = 'view' ) { |
|
| 735 | + return $this->get_author( $context ); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - /** |
|
| 739 | - * Alias of self::get_author(). |
|
| 740 | - * |
|
| 741 | - * @since 1.0.19 |
|
| 742 | - * @param string $context View or edit context. |
|
| 743 | - * @return int |
|
| 744 | - */ |
|
| 745 | - public function get_customer_id( $context = 'view' ) { |
|
| 746 | - return $this->get_author( $context ); |
|
| 738 | + /** |
|
| 739 | + * Alias of self::get_author(). |
|
| 740 | + * |
|
| 741 | + * @since 1.0.19 |
|
| 742 | + * @param string $context View or edit context. |
|
| 743 | + * @return int |
|
| 744 | + */ |
|
| 745 | + public function get_customer_id( $context = 'view' ) { |
|
| 746 | + return $this->get_author( $context ); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
| 750 | - * Get the customer's ip. |
|
| 751 | - * |
|
| 752 | - * @since 1.0.19 |
|
| 753 | - * @param string $context View or edit context. |
|
| 754 | - * @return string |
|
| 755 | - */ |
|
| 756 | - public function get_ip( $context = 'view' ) { |
|
| 757 | - return $this->get_prop( 'user_ip', $context ); |
|
| 750 | + * Get the customer's ip. |
|
| 751 | + * |
|
| 752 | + * @since 1.0.19 |
|
| 753 | + * @param string $context View or edit context. |
|
| 754 | + * @return string |
|
| 755 | + */ |
|
| 756 | + public function get_ip( $context = 'view' ) { |
|
| 757 | + return $this->get_prop( 'user_ip', $context ); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | - * Alias of self::get_ip(). |
|
| 762 | - * |
|
| 763 | - * @since 1.0.19 |
|
| 764 | - * @param string $context View or edit context. |
|
| 765 | - * @return string |
|
| 766 | - */ |
|
| 767 | - public function get_user_ip( $context = 'view' ) { |
|
| 768 | - return $this->get_ip( $context ); |
|
| 761 | + * Alias of self::get_ip(). |
|
| 762 | + * |
|
| 763 | + * @since 1.0.19 |
|
| 764 | + * @param string $context View or edit context. |
|
| 765 | + * @return string |
|
| 766 | + */ |
|
| 767 | + public function get_user_ip( $context = 'view' ) { |
|
| 768 | + return $this->get_ip( $context ); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - /** |
|
| 772 | - * Alias of self::get_ip(). |
|
| 773 | - * |
|
| 774 | - * @since 1.0.19 |
|
| 775 | - * @param string $context View or edit context. |
|
| 776 | - * @return string |
|
| 777 | - */ |
|
| 778 | - public function get_customer_ip( $context = 'view' ) { |
|
| 779 | - return $this->get_ip( $context ); |
|
| 771 | + /** |
|
| 772 | + * Alias of self::get_ip(). |
|
| 773 | + * |
|
| 774 | + * @since 1.0.19 |
|
| 775 | + * @param string $context View or edit context. |
|
| 776 | + * @return string |
|
| 777 | + */ |
|
| 778 | + public function get_customer_ip( $context = 'view' ) { |
|
| 779 | + return $this->get_ip( $context ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | - * Get the customer's first name. |
|
| 784 | - * |
|
| 785 | - * @since 1.0.19 |
|
| 786 | - * @param string $context View or edit context. |
|
| 787 | - * @return string |
|
| 788 | - */ |
|
| 789 | - public function get_first_name( $context = 'view' ) { |
|
| 790 | - return $this->get_prop( 'first_name', $context ); |
|
| 783 | + * Get the customer's first name. |
|
| 784 | + * |
|
| 785 | + * @since 1.0.19 |
|
| 786 | + * @param string $context View or edit context. |
|
| 787 | + * @return string |
|
| 788 | + */ |
|
| 789 | + public function get_first_name( $context = 'view' ) { |
|
| 790 | + return $this->get_prop( 'first_name', $context ); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
| 794 | - * Alias of self::get_first_name(). |
|
| 795 | - * |
|
| 796 | - * @since 1.0.19 |
|
| 797 | - * @param string $context View or edit context. |
|
| 798 | - * @return int |
|
| 799 | - */ |
|
| 800 | - public function get_user_first_name( $context = 'view' ) { |
|
| 801 | - return $this->get_first_name( $context ); |
|
| 794 | + * Alias of self::get_first_name(). |
|
| 795 | + * |
|
| 796 | + * @since 1.0.19 |
|
| 797 | + * @param string $context View or edit context. |
|
| 798 | + * @return int |
|
| 799 | + */ |
|
| 800 | + public function get_user_first_name( $context = 'view' ) { |
|
| 801 | + return $this->get_first_name( $context ); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - /** |
|
| 805 | - * Alias of self::get_first_name(). |
|
| 806 | - * |
|
| 807 | - * @since 1.0.19 |
|
| 808 | - * @param string $context View or edit context. |
|
| 809 | - * @return int |
|
| 810 | - */ |
|
| 811 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 812 | - return $this->get_first_name( $context ); |
|
| 804 | + /** |
|
| 805 | + * Alias of self::get_first_name(). |
|
| 806 | + * |
|
| 807 | + * @since 1.0.19 |
|
| 808 | + * @param string $context View or edit context. |
|
| 809 | + * @return int |
|
| 810 | + */ |
|
| 811 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 812 | + return $this->get_first_name( $context ); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * Get the customer's last name. |
|
| 817 | - * |
|
| 818 | - * @since 1.0.19 |
|
| 819 | - * @param string $context View or edit context. |
|
| 820 | - * @return string |
|
| 821 | - */ |
|
| 822 | - public function get_last_name( $context = 'view' ) { |
|
| 823 | - return $this->get_prop( 'last_name', $context ); |
|
| 816 | + * Get the customer's last name. |
|
| 817 | + * |
|
| 818 | + * @since 1.0.19 |
|
| 819 | + * @param string $context View or edit context. |
|
| 820 | + * @return string |
|
| 821 | + */ |
|
| 822 | + public function get_last_name( $context = 'view' ) { |
|
| 823 | + return $this->get_prop( 'last_name', $context ); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |
| 827 | - * Alias of self::get_last_name(). |
|
| 828 | - * |
|
| 829 | - * @since 1.0.19 |
|
| 830 | - * @param string $context View or edit context. |
|
| 831 | - * @return int |
|
| 832 | - */ |
|
| 833 | - public function get_user_last_name( $context = 'view' ) { |
|
| 834 | - return $this->get_last_name( $context ); |
|
| 827 | + * Alias of self::get_last_name(). |
|
| 828 | + * |
|
| 829 | + * @since 1.0.19 |
|
| 830 | + * @param string $context View or edit context. |
|
| 831 | + * @return int |
|
| 832 | + */ |
|
| 833 | + public function get_user_last_name( $context = 'view' ) { |
|
| 834 | + return $this->get_last_name( $context ); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
| 838 | - * Alias of self::get_last_name(). |
|
| 839 | - * |
|
| 840 | - * @since 1.0.19 |
|
| 841 | - * @param string $context View or edit context. |
|
| 842 | - * @return int |
|
| 843 | - */ |
|
| 844 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 845 | - return $this->get_last_name( $context ); |
|
| 838 | + * Alias of self::get_last_name(). |
|
| 839 | + * |
|
| 840 | + * @since 1.0.19 |
|
| 841 | + * @param string $context View or edit context. |
|
| 842 | + * @return int |
|
| 843 | + */ |
|
| 844 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 845 | + return $this->get_last_name( $context ); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | /** |
| 849 | - * Get the customer's full name. |
|
| 850 | - * |
|
| 851 | - * @since 1.0.19 |
|
| 852 | - * @param string $context View or edit context. |
|
| 853 | - * @return string |
|
| 854 | - */ |
|
| 855 | - public function get_full_name( $context = 'view' ) { |
|
| 856 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 849 | + * Get the customer's full name. |
|
| 850 | + * |
|
| 851 | + * @since 1.0.19 |
|
| 852 | + * @param string $context View or edit context. |
|
| 853 | + * @return string |
|
| 854 | + */ |
|
| 855 | + public function get_full_name( $context = 'view' ) { |
|
| 856 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
| 860 | - * Alias of self::get_full_name(). |
|
| 861 | - * |
|
| 862 | - * @since 1.0.19 |
|
| 863 | - * @param string $context View or edit context. |
|
| 864 | - * @return int |
|
| 865 | - */ |
|
| 866 | - public function get_user_full_name( $context = 'view' ) { |
|
| 867 | - return $this->get_full_name( $context ); |
|
| 860 | + * Alias of self::get_full_name(). |
|
| 861 | + * |
|
| 862 | + * @since 1.0.19 |
|
| 863 | + * @param string $context View or edit context. |
|
| 864 | + * @return int |
|
| 865 | + */ |
|
| 866 | + public function get_user_full_name( $context = 'view' ) { |
|
| 867 | + return $this->get_full_name( $context ); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
| 871 | - * Alias of self::get_full_name(). |
|
| 872 | - * |
|
| 873 | - * @since 1.0.19 |
|
| 874 | - * @param string $context View or edit context. |
|
| 875 | - * @return int |
|
| 876 | - */ |
|
| 877 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 878 | - return $this->get_full_name( $context ); |
|
| 871 | + * Alias of self::get_full_name(). |
|
| 872 | + * |
|
| 873 | + * @since 1.0.19 |
|
| 874 | + * @param string $context View or edit context. |
|
| 875 | + * @return int |
|
| 876 | + */ |
|
| 877 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 878 | + return $this->get_full_name( $context ); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
| 882 | - * Get the customer's phone number. |
|
| 883 | - * |
|
| 884 | - * @since 1.0.19 |
|
| 885 | - * @param string $context View or edit context. |
|
| 886 | - * @return string |
|
| 887 | - */ |
|
| 888 | - public function get_phone( $context = 'view' ) { |
|
| 889 | - return $this->get_prop( 'phone', $context ); |
|
| 882 | + * Get the customer's phone number. |
|
| 883 | + * |
|
| 884 | + * @since 1.0.19 |
|
| 885 | + * @param string $context View or edit context. |
|
| 886 | + * @return string |
|
| 887 | + */ |
|
| 888 | + public function get_phone( $context = 'view' ) { |
|
| 889 | + return $this->get_prop( 'phone', $context ); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | /** |
| 893 | - * Alias of self::get_phone(). |
|
| 894 | - * |
|
| 895 | - * @since 1.0.19 |
|
| 896 | - * @param string $context View or edit context. |
|
| 897 | - * @return int |
|
| 898 | - */ |
|
| 899 | - public function get_phone_number( $context = 'view' ) { |
|
| 900 | - return $this->get_phone( $context ); |
|
| 893 | + * Alias of self::get_phone(). |
|
| 894 | + * |
|
| 895 | + * @since 1.0.19 |
|
| 896 | + * @param string $context View or edit context. |
|
| 897 | + * @return int |
|
| 898 | + */ |
|
| 899 | + public function get_phone_number( $context = 'view' ) { |
|
| 900 | + return $this->get_phone( $context ); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
| 904 | - * Alias of self::get_phone(). |
|
| 905 | - * |
|
| 906 | - * @since 1.0.19 |
|
| 907 | - * @param string $context View or edit context. |
|
| 908 | - * @return int |
|
| 909 | - */ |
|
| 910 | - public function get_user_phone( $context = 'view' ) { |
|
| 911 | - return $this->get_phone( $context ); |
|
| 904 | + * Alias of self::get_phone(). |
|
| 905 | + * |
|
| 906 | + * @since 1.0.19 |
|
| 907 | + * @param string $context View or edit context. |
|
| 908 | + * @return int |
|
| 909 | + */ |
|
| 910 | + public function get_user_phone( $context = 'view' ) { |
|
| 911 | + return $this->get_phone( $context ); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
| 915 | - * Alias of self::get_phone(). |
|
| 916 | - * |
|
| 917 | - * @since 1.0.19 |
|
| 918 | - * @param string $context View or edit context. |
|
| 919 | - * @return int |
|
| 920 | - */ |
|
| 921 | - public function get_customer_phone( $context = 'view' ) { |
|
| 922 | - return $this->get_phone( $context ); |
|
| 915 | + * Alias of self::get_phone(). |
|
| 916 | + * |
|
| 917 | + * @since 1.0.19 |
|
| 918 | + * @param string $context View or edit context. |
|
| 919 | + * @return int |
|
| 920 | + */ |
|
| 921 | + public function get_customer_phone( $context = 'view' ) { |
|
| 922 | + return $this->get_phone( $context ); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
| 926 | - * Get the customer's email address. |
|
| 927 | - * |
|
| 928 | - * @since 1.0.19 |
|
| 929 | - * @param string $context View or edit context. |
|
| 930 | - * @return string |
|
| 931 | - */ |
|
| 932 | - public function get_email( $context = 'view' ) { |
|
| 933 | - return $this->get_prop( 'email', $context ); |
|
| 926 | + * Get the customer's email address. |
|
| 927 | + * |
|
| 928 | + * @since 1.0.19 |
|
| 929 | + * @param string $context View or edit context. |
|
| 930 | + * @return string |
|
| 931 | + */ |
|
| 932 | + public function get_email( $context = 'view' ) { |
|
| 933 | + return $this->get_prop( 'email', $context ); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
| 937 | - * Alias of self::get_email(). |
|
| 938 | - * |
|
| 939 | - * @since 1.0.19 |
|
| 940 | - * @param string $context View or edit context. |
|
| 941 | - * @return string |
|
| 942 | - */ |
|
| 943 | - public function get_email_address( $context = 'view' ) { |
|
| 944 | - return $this->get_email( $context ); |
|
| 937 | + * Alias of self::get_email(). |
|
| 938 | + * |
|
| 939 | + * @since 1.0.19 |
|
| 940 | + * @param string $context View or edit context. |
|
| 941 | + * @return string |
|
| 942 | + */ |
|
| 943 | + public function get_email_address( $context = 'view' ) { |
|
| 944 | + return $this->get_email( $context ); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | /** |
| 948 | - * Alias of self::get_email(). |
|
| 949 | - * |
|
| 950 | - * @since 1.0.19 |
|
| 951 | - * @param string $context View or edit context. |
|
| 952 | - * @return int |
|
| 953 | - */ |
|
| 954 | - public function get_user_email( $context = 'view' ) { |
|
| 955 | - return $this->get_email( $context ); |
|
| 948 | + * Alias of self::get_email(). |
|
| 949 | + * |
|
| 950 | + * @since 1.0.19 |
|
| 951 | + * @param string $context View or edit context. |
|
| 952 | + * @return int |
|
| 953 | + */ |
|
| 954 | + public function get_user_email( $context = 'view' ) { |
|
| 955 | + return $this->get_email( $context ); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | /** |
| 959 | - * Alias of self::get_email(). |
|
| 960 | - * |
|
| 961 | - * @since 1.0.19 |
|
| 962 | - * @param string $context View or edit context. |
|
| 963 | - * @return int |
|
| 964 | - */ |
|
| 965 | - public function get_customer_email( $context = 'view' ) { |
|
| 966 | - return $this->get_email( $context ); |
|
| 959 | + * Alias of self::get_email(). |
|
| 960 | + * |
|
| 961 | + * @since 1.0.19 |
|
| 962 | + * @param string $context View or edit context. |
|
| 963 | + * @return int |
|
| 964 | + */ |
|
| 965 | + public function get_customer_email( $context = 'view' ) { |
|
| 966 | + return $this->get_email( $context ); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
| 970 | - * Get the customer's country. |
|
| 971 | - * |
|
| 972 | - * @since 1.0.19 |
|
| 973 | - * @param string $context View or edit context. |
|
| 974 | - * @return string |
|
| 975 | - */ |
|
| 976 | - public function get_country( $context = 'view' ) { |
|
| 977 | - $country = $this->get_prop( 'country', $context ); |
|
| 978 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 970 | + * Get the customer's country. |
|
| 971 | + * |
|
| 972 | + * @since 1.0.19 |
|
| 973 | + * @param string $context View or edit context. |
|
| 974 | + * @return string |
|
| 975 | + */ |
|
| 976 | + public function get_country( $context = 'view' ) { |
|
| 977 | + $country = $this->get_prop( 'country', $context ); |
|
| 978 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | /** |
| 982 | - * Alias of self::get_country(). |
|
| 983 | - * |
|
| 984 | - * @since 1.0.19 |
|
| 985 | - * @param string $context View or edit context. |
|
| 986 | - * @return int |
|
| 987 | - */ |
|
| 988 | - public function get_user_country( $context = 'view' ) { |
|
| 989 | - return $this->get_country( $context ); |
|
| 982 | + * Alias of self::get_country(). |
|
| 983 | + * |
|
| 984 | + * @since 1.0.19 |
|
| 985 | + * @param string $context View or edit context. |
|
| 986 | + * @return int |
|
| 987 | + */ |
|
| 988 | + public function get_user_country( $context = 'view' ) { |
|
| 989 | + return $this->get_country( $context ); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | /** |
| 993 | - * Alias of self::get_country(). |
|
| 994 | - * |
|
| 995 | - * @since 1.0.19 |
|
| 996 | - * @param string $context View or edit context. |
|
| 997 | - * @return int |
|
| 998 | - */ |
|
| 999 | - public function get_customer_country( $context = 'view' ) { |
|
| 1000 | - return $this->get_country( $context ); |
|
| 993 | + * Alias of self::get_country(). |
|
| 994 | + * |
|
| 995 | + * @since 1.0.19 |
|
| 996 | + * @param string $context View or edit context. |
|
| 997 | + * @return int |
|
| 998 | + */ |
|
| 999 | + public function get_customer_country( $context = 'view' ) { |
|
| 1000 | + return $this->get_country( $context ); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | /** |
| 1004 | - * Get the customer's state. |
|
| 1005 | - * |
|
| 1006 | - * @since 1.0.19 |
|
| 1007 | - * @param string $context View or edit context. |
|
| 1008 | - * @return string |
|
| 1009 | - */ |
|
| 1010 | - public function get_state( $context = 'view' ) { |
|
| 1011 | - $state = $this->get_prop( 'state', $context ); |
|
| 1012 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1004 | + * Get the customer's state. |
|
| 1005 | + * |
|
| 1006 | + * @since 1.0.19 |
|
| 1007 | + * @param string $context View or edit context. |
|
| 1008 | + * @return string |
|
| 1009 | + */ |
|
| 1010 | + public function get_state( $context = 'view' ) { |
|
| 1011 | + $state = $this->get_prop( 'state', $context ); |
|
| 1012 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | /** |
| 1016 | - * Alias of self::get_state(). |
|
| 1017 | - * |
|
| 1018 | - * @since 1.0.19 |
|
| 1019 | - * @param string $context View or edit context. |
|
| 1020 | - * @return int |
|
| 1021 | - */ |
|
| 1022 | - public function get_user_state( $context = 'view' ) { |
|
| 1023 | - return $this->get_state( $context ); |
|
| 1016 | + * Alias of self::get_state(). |
|
| 1017 | + * |
|
| 1018 | + * @since 1.0.19 |
|
| 1019 | + * @param string $context View or edit context. |
|
| 1020 | + * @return int |
|
| 1021 | + */ |
|
| 1022 | + public function get_user_state( $context = 'view' ) { |
|
| 1023 | + return $this->get_state( $context ); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
| 1027 | - * Alias of self::get_state(). |
|
| 1028 | - * |
|
| 1029 | - * @since 1.0.19 |
|
| 1030 | - * @param string $context View or edit context. |
|
| 1031 | - * @return int |
|
| 1032 | - */ |
|
| 1033 | - public function get_customer_state( $context = 'view' ) { |
|
| 1034 | - return $this->get_state( $context ); |
|
| 1027 | + * Alias of self::get_state(). |
|
| 1028 | + * |
|
| 1029 | + * @since 1.0.19 |
|
| 1030 | + * @param string $context View or edit context. |
|
| 1031 | + * @return int |
|
| 1032 | + */ |
|
| 1033 | + public function get_customer_state( $context = 'view' ) { |
|
| 1034 | + return $this->get_state( $context ); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | /** |
| 1038 | - * Get the customer's city. |
|
| 1039 | - * |
|
| 1040 | - * @since 1.0.19 |
|
| 1041 | - * @param string $context View or edit context. |
|
| 1042 | - * @return string |
|
| 1043 | - */ |
|
| 1044 | - public function get_city( $context = 'view' ) { |
|
| 1045 | - return $this->get_prop( 'city', $context ); |
|
| 1038 | + * Get the customer's city. |
|
| 1039 | + * |
|
| 1040 | + * @since 1.0.19 |
|
| 1041 | + * @param string $context View or edit context. |
|
| 1042 | + * @return string |
|
| 1043 | + */ |
|
| 1044 | + public function get_city( $context = 'view' ) { |
|
| 1045 | + return $this->get_prop( 'city', $context ); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | /** |
| 1049 | - * Alias of self::get_city(). |
|
| 1050 | - * |
|
| 1051 | - * @since 1.0.19 |
|
| 1052 | - * @param string $context View or edit context. |
|
| 1053 | - * @return string |
|
| 1054 | - */ |
|
| 1055 | - public function get_user_city( $context = 'view' ) { |
|
| 1056 | - return $this->get_city( $context ); |
|
| 1049 | + * Alias of self::get_city(). |
|
| 1050 | + * |
|
| 1051 | + * @since 1.0.19 |
|
| 1052 | + * @param string $context View or edit context. |
|
| 1053 | + * @return string |
|
| 1054 | + */ |
|
| 1055 | + public function get_user_city( $context = 'view' ) { |
|
| 1056 | + return $this->get_city( $context ); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
| 1060 | - * Alias of self::get_city(). |
|
| 1061 | - * |
|
| 1062 | - * @since 1.0.19 |
|
| 1063 | - * @param string $context View or edit context. |
|
| 1064 | - * @return string |
|
| 1065 | - */ |
|
| 1066 | - public function get_customer_city( $context = 'view' ) { |
|
| 1067 | - return $this->get_city( $context ); |
|
| 1060 | + * Alias of self::get_city(). |
|
| 1061 | + * |
|
| 1062 | + * @since 1.0.19 |
|
| 1063 | + * @param string $context View or edit context. |
|
| 1064 | + * @return string |
|
| 1065 | + */ |
|
| 1066 | + public function get_customer_city( $context = 'view' ) { |
|
| 1067 | + return $this->get_city( $context ); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | /** |
| 1071 | - * Get the customer's zip. |
|
| 1072 | - * |
|
| 1073 | - * @since 1.0.19 |
|
| 1074 | - * @param string $context View or edit context. |
|
| 1075 | - * @return string |
|
| 1076 | - */ |
|
| 1077 | - public function get_zip( $context = 'view' ) { |
|
| 1078 | - return $this->get_prop( 'zip', $context ); |
|
| 1071 | + * Get the customer's zip. |
|
| 1072 | + * |
|
| 1073 | + * @since 1.0.19 |
|
| 1074 | + * @param string $context View or edit context. |
|
| 1075 | + * @return string |
|
| 1076 | + */ |
|
| 1077 | + public function get_zip( $context = 'view' ) { |
|
| 1078 | + return $this->get_prop( 'zip', $context ); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
| 1082 | - * Alias of self::get_zip(). |
|
| 1083 | - * |
|
| 1084 | - * @since 1.0.19 |
|
| 1085 | - * @param string $context View or edit context. |
|
| 1086 | - * @return string |
|
| 1087 | - */ |
|
| 1088 | - public function get_user_zip( $context = 'view' ) { |
|
| 1089 | - return $this->get_zip( $context ); |
|
| 1082 | + * Alias of self::get_zip(). |
|
| 1083 | + * |
|
| 1084 | + * @since 1.0.19 |
|
| 1085 | + * @param string $context View or edit context. |
|
| 1086 | + * @return string |
|
| 1087 | + */ |
|
| 1088 | + public function get_user_zip( $context = 'view' ) { |
|
| 1089 | + return $this->get_zip( $context ); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | /** |
| 1093 | - * Alias of self::get_zip(). |
|
| 1094 | - * |
|
| 1095 | - * @since 1.0.19 |
|
| 1096 | - * @param string $context View or edit context. |
|
| 1097 | - * @return string |
|
| 1098 | - */ |
|
| 1099 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1100 | - return $this->get_zip( $context ); |
|
| 1093 | + * Alias of self::get_zip(). |
|
| 1094 | + * |
|
| 1095 | + * @since 1.0.19 |
|
| 1096 | + * @param string $context View or edit context. |
|
| 1097 | + * @return string |
|
| 1098 | + */ |
|
| 1099 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1100 | + return $this->get_zip( $context ); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
| 1104 | - * Get the customer's company. |
|
| 1105 | - * |
|
| 1106 | - * @since 1.0.19 |
|
| 1107 | - * @param string $context View or edit context. |
|
| 1108 | - * @return string |
|
| 1109 | - */ |
|
| 1110 | - public function get_company( $context = 'view' ) { |
|
| 1111 | - return $this->get_prop( 'company', $context ); |
|
| 1104 | + * Get the customer's company. |
|
| 1105 | + * |
|
| 1106 | + * @since 1.0.19 |
|
| 1107 | + * @param string $context View or edit context. |
|
| 1108 | + * @return string |
|
| 1109 | + */ |
|
| 1110 | + public function get_company( $context = 'view' ) { |
|
| 1111 | + return $this->get_prop( 'company', $context ); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
| 1115 | - * Alias of self::get_company(). |
|
| 1116 | - * |
|
| 1117 | - * @since 1.0.19 |
|
| 1118 | - * @param string $context View or edit context. |
|
| 1119 | - * @return string |
|
| 1120 | - */ |
|
| 1121 | - public function get_user_company( $context = 'view' ) { |
|
| 1122 | - return $this->get_company( $context ); |
|
| 1115 | + * Alias of self::get_company(). |
|
| 1116 | + * |
|
| 1117 | + * @since 1.0.19 |
|
| 1118 | + * @param string $context View or edit context. |
|
| 1119 | + * @return string |
|
| 1120 | + */ |
|
| 1121 | + public function get_user_company( $context = 'view' ) { |
|
| 1122 | + return $this->get_company( $context ); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /** |
| 1126 | - * Alias of self::get_company(). |
|
| 1127 | - * |
|
| 1128 | - * @since 1.0.19 |
|
| 1129 | - * @param string $context View or edit context. |
|
| 1130 | - * @return string |
|
| 1131 | - */ |
|
| 1132 | - public function get_customer_company( $context = 'view' ) { |
|
| 1133 | - return $this->get_company( $context ); |
|
| 1126 | + * Alias of self::get_company(). |
|
| 1127 | + * |
|
| 1128 | + * @since 1.0.19 |
|
| 1129 | + * @param string $context View or edit context. |
|
| 1130 | + * @return string |
|
| 1131 | + */ |
|
| 1132 | + public function get_customer_company( $context = 'view' ) { |
|
| 1133 | + return $this->get_company( $context ); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | /** |
| 1137 | - * Get the customer's vat number. |
|
| 1138 | - * |
|
| 1139 | - * @since 1.0.19 |
|
| 1140 | - * @param string $context View or edit context. |
|
| 1141 | - * @return string |
|
| 1142 | - */ |
|
| 1143 | - public function get_vat_number( $context = 'view' ) { |
|
| 1144 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1137 | + * Get the customer's vat number. |
|
| 1138 | + * |
|
| 1139 | + * @since 1.0.19 |
|
| 1140 | + * @param string $context View or edit context. |
|
| 1141 | + * @return string |
|
| 1142 | + */ |
|
| 1143 | + public function get_vat_number( $context = 'view' ) { |
|
| 1144 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
| 1148 | - * Alias of self::get_vat_number(). |
|
| 1149 | - * |
|
| 1150 | - * @since 1.0.19 |
|
| 1151 | - * @param string $context View or edit context. |
|
| 1152 | - * @return string |
|
| 1153 | - */ |
|
| 1154 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1155 | - return $this->get_vat_number( $context ); |
|
| 1148 | + * Alias of self::get_vat_number(). |
|
| 1149 | + * |
|
| 1150 | + * @since 1.0.19 |
|
| 1151 | + * @param string $context View or edit context. |
|
| 1152 | + * @return string |
|
| 1153 | + */ |
|
| 1154 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1155 | + return $this->get_vat_number( $context ); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | /** |
| 1159 | - * Alias of self::get_vat_number(). |
|
| 1160 | - * |
|
| 1161 | - * @since 1.0.19 |
|
| 1162 | - * @param string $context View or edit context. |
|
| 1163 | - * @return string |
|
| 1164 | - */ |
|
| 1165 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1166 | - return $this->get_vat_number( $context ); |
|
| 1159 | + * Alias of self::get_vat_number(). |
|
| 1160 | + * |
|
| 1161 | + * @since 1.0.19 |
|
| 1162 | + * @param string $context View or edit context. |
|
| 1163 | + * @return string |
|
| 1164 | + */ |
|
| 1165 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1166 | + return $this->get_vat_number( $context ); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | /** |
| 1170 | - * Get the customer's vat rate. |
|
| 1171 | - * |
|
| 1172 | - * @since 1.0.19 |
|
| 1173 | - * @param string $context View or edit context. |
|
| 1174 | - * @return string |
|
| 1175 | - */ |
|
| 1176 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1177 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1178 | - } |
|
| 1170 | + * Get the customer's vat rate. |
|
| 1171 | + * |
|
| 1172 | + * @since 1.0.19 |
|
| 1173 | + * @param string $context View or edit context. |
|
| 1174 | + * @return string |
|
| 1175 | + */ |
|
| 1176 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1177 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1178 | + } |
|
| 1179 | + |
|
| 1180 | + /** |
|
| 1181 | + * Alias of self::get_vat_rate(). |
|
| 1182 | + * |
|
| 1183 | + * @since 1.0.19 |
|
| 1184 | + * @param string $context View or edit context. |
|
| 1185 | + * @return string |
|
| 1186 | + */ |
|
| 1187 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1188 | + return $this->get_vat_rate( $context ); |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + /** |
|
| 1192 | + * Alias of self::get_vat_rate(). |
|
| 1193 | + * |
|
| 1194 | + * @since 1.0.19 |
|
| 1195 | + * @param string $context View or edit context. |
|
| 1196 | + * @return string |
|
| 1197 | + */ |
|
| 1198 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1199 | + return $this->get_vat_rate( $context ); |
|
| 1200 | + } |
|
| 1201 | + |
|
| 1202 | + /** |
|
| 1203 | + * Get the customer's address. |
|
| 1204 | + * |
|
| 1205 | + * @since 1.0.19 |
|
| 1206 | + * @param string $context View or edit context. |
|
| 1207 | + * @return string |
|
| 1208 | + */ |
|
| 1209 | + public function get_address( $context = 'view' ) { |
|
| 1210 | + return $this->get_prop( 'address', $context ); |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + /** |
|
| 1214 | + * Alias of self::get_address(). |
|
| 1215 | + * |
|
| 1216 | + * @since 1.0.19 |
|
| 1217 | + * @param string $context View or edit context. |
|
| 1218 | + * @return string |
|
| 1219 | + */ |
|
| 1220 | + public function get_user_address( $context = 'view' ) { |
|
| 1221 | + return $this->get_address( $context ); |
|
| 1222 | + } |
|
| 1223 | + |
|
| 1224 | + /** |
|
| 1225 | + * Alias of self::get_address(). |
|
| 1226 | + * |
|
| 1227 | + * @since 1.0.19 |
|
| 1228 | + * @param string $context View or edit context. |
|
| 1229 | + * @return string |
|
| 1230 | + */ |
|
| 1231 | + public function get_customer_address( $context = 'view' ) { |
|
| 1232 | + return $this->get_address( $context ); |
|
| 1233 | + } |
|
| 1179 | 1234 | |
| 1180 | 1235 | /** |
| 1181 | - * Alias of self::get_vat_rate(). |
|
| 1182 | - * |
|
| 1183 | - * @since 1.0.19 |
|
| 1184 | - * @param string $context View or edit context. |
|
| 1185 | - * @return string |
|
| 1186 | - */ |
|
| 1187 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1188 | - return $this->get_vat_rate( $context ); |
|
| 1236 | + * Get whether the customer has viewed the invoice or not. |
|
| 1237 | + * |
|
| 1238 | + * @since 1.0.19 |
|
| 1239 | + * @param string $context View or edit context. |
|
| 1240 | + * @return bool |
|
| 1241 | + */ |
|
| 1242 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1243 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + /** |
|
| 1247 | + * Get other recipients for invoice communications. |
|
| 1248 | + * |
|
| 1249 | + * @since 1.0.19 |
|
| 1250 | + * @param string $context View or edit context. |
|
| 1251 | + * @return bool |
|
| 1252 | + */ |
|
| 1253 | + public function get_email_cc( $context = 'view' ) { |
|
| 1254 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + /** |
|
| 1258 | + * Get invoice template. |
|
| 1259 | + * |
|
| 1260 | + * @since 1.0.19 |
|
| 1261 | + * @param string $context View or edit context. |
|
| 1262 | + * @return bool |
|
| 1263 | + */ |
|
| 1264 | + public function get_template( $context = 'view' ) { |
|
| 1265 | + return $this->get_prop( 'template', $context ); |
|
| 1266 | + } |
|
| 1267 | + |
|
| 1268 | + /** |
|
| 1269 | + * Get whether the customer has confirmed their address. |
|
| 1270 | + * |
|
| 1271 | + * @since 1.0.19 |
|
| 1272 | + * @param string $context View or edit context. |
|
| 1273 | + * @return bool |
|
| 1274 | + */ |
|
| 1275 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1276 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1189 | 1277 | } |
| 1190 | 1278 | |
| 1191 | 1279 | /** |
| 1192 | - * Alias of self::get_vat_rate(). |
|
| 1193 | - * |
|
| 1194 | - * @since 1.0.19 |
|
| 1195 | - * @param string $context View or edit context. |
|
| 1196 | - * @return string |
|
| 1197 | - */ |
|
| 1198 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1199 | - return $this->get_vat_rate( $context ); |
|
| 1280 | + * Alias of self::get_address_confirmed(). |
|
| 1281 | + * |
|
| 1282 | + * @since 1.0.19 |
|
| 1283 | + * @param string $context View or edit context. |
|
| 1284 | + * @return bool |
|
| 1285 | + */ |
|
| 1286 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1287 | + return $this->get_address_confirmed( $context ); |
|
| 1200 | 1288 | } |
| 1201 | 1289 | |
| 1202 | 1290 | /** |
| 1203 | - * Get the customer's address. |
|
| 1204 | - * |
|
| 1205 | - * @since 1.0.19 |
|
| 1206 | - * @param string $context View or edit context. |
|
| 1207 | - * @return string |
|
| 1208 | - */ |
|
| 1209 | - public function get_address( $context = 'view' ) { |
|
| 1210 | - return $this->get_prop( 'address', $context ); |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - /** |
|
| 1214 | - * Alias of self::get_address(). |
|
| 1215 | - * |
|
| 1216 | - * @since 1.0.19 |
|
| 1217 | - * @param string $context View or edit context. |
|
| 1218 | - * @return string |
|
| 1219 | - */ |
|
| 1220 | - public function get_user_address( $context = 'view' ) { |
|
| 1221 | - return $this->get_address( $context ); |
|
| 1222 | - } |
|
| 1223 | - |
|
| 1224 | - /** |
|
| 1225 | - * Alias of self::get_address(). |
|
| 1226 | - * |
|
| 1227 | - * @since 1.0.19 |
|
| 1228 | - * @param string $context View or edit context. |
|
| 1229 | - * @return string |
|
| 1230 | - */ |
|
| 1231 | - public function get_customer_address( $context = 'view' ) { |
|
| 1232 | - return $this->get_address( $context ); |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * Get whether the customer has viewed the invoice or not. |
|
| 1237 | - * |
|
| 1238 | - * @since 1.0.19 |
|
| 1239 | - * @param string $context View or edit context. |
|
| 1240 | - * @return bool |
|
| 1241 | - */ |
|
| 1242 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1243 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - /** |
|
| 1247 | - * Get other recipients for invoice communications. |
|
| 1248 | - * |
|
| 1249 | - * @since 1.0.19 |
|
| 1250 | - * @param string $context View or edit context. |
|
| 1251 | - * @return bool |
|
| 1252 | - */ |
|
| 1253 | - public function get_email_cc( $context = 'view' ) { |
|
| 1254 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - /** |
|
| 1258 | - * Get invoice template. |
|
| 1259 | - * |
|
| 1260 | - * @since 1.0.19 |
|
| 1261 | - * @param string $context View or edit context. |
|
| 1262 | - * @return bool |
|
| 1263 | - */ |
|
| 1264 | - public function get_template( $context = 'view' ) { |
|
| 1265 | - return $this->get_prop( 'template', $context ); |
|
| 1266 | - } |
|
| 1267 | - |
|
| 1268 | - /** |
|
| 1269 | - * Get whether the customer has confirmed their address. |
|
| 1270 | - * |
|
| 1271 | - * @since 1.0.19 |
|
| 1272 | - * @param string $context View or edit context. |
|
| 1273 | - * @return bool |
|
| 1274 | - */ |
|
| 1275 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1276 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1277 | - } |
|
| 1278 | - |
|
| 1279 | - /** |
|
| 1280 | - * Alias of self::get_address_confirmed(). |
|
| 1281 | - * |
|
| 1282 | - * @since 1.0.19 |
|
| 1283 | - * @param string $context View or edit context. |
|
| 1284 | - * @return bool |
|
| 1285 | - */ |
|
| 1286 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1287 | - return $this->get_address_confirmed( $context ); |
|
| 1288 | - } |
|
| 1289 | - |
|
| 1290 | - /** |
|
| 1291 | - * Alias of self::get_address(). |
|
| 1292 | - * |
|
| 1293 | - * @since 1.0.19 |
|
| 1294 | - * @param string $context View or edit context. |
|
| 1295 | - * @return bool |
|
| 1296 | - */ |
|
| 1297 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1298 | - return $this->get_address_confirmed( $context ); |
|
| 1299 | - } |
|
| 1300 | - |
|
| 1301 | - /** |
|
| 1302 | - * Get the invoice subtotal. |
|
| 1303 | - * |
|
| 1304 | - * @since 1.0.19 |
|
| 1305 | - * @param string $context View or edit context. |
|
| 1306 | - * @return float |
|
| 1307 | - */ |
|
| 1308 | - public function get_subtotal( $context = 'view' ) { |
|
| 1291 | + * Alias of self::get_address(). |
|
| 1292 | + * |
|
| 1293 | + * @since 1.0.19 |
|
| 1294 | + * @param string $context View or edit context. |
|
| 1295 | + * @return bool |
|
| 1296 | + */ |
|
| 1297 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1298 | + return $this->get_address_confirmed( $context ); |
|
| 1299 | + } |
|
| 1300 | + |
|
| 1301 | + /** |
|
| 1302 | + * Get the invoice subtotal. |
|
| 1303 | + * |
|
| 1304 | + * @since 1.0.19 |
|
| 1305 | + * @param string $context View or edit context. |
|
| 1306 | + * @return float |
|
| 1307 | + */ |
|
| 1308 | + public function get_subtotal( $context = 'view' ) { |
|
| 1309 | 1309 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1310 | 1310 | |
| 1311 | 1311 | // Backwards compatibility. |
@@ -1317,155 +1317,155 @@ discard block |
||
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | /** |
| 1320 | - * Get the invoice discount total. |
|
| 1321 | - * |
|
| 1322 | - * @since 1.0.19 |
|
| 1323 | - * @param string $context View or edit context. |
|
| 1324 | - * @return float |
|
| 1325 | - */ |
|
| 1326 | - public function get_total_discount( $context = 'view' ) { |
|
| 1327 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1320 | + * Get the invoice discount total. |
|
| 1321 | + * |
|
| 1322 | + * @since 1.0.19 |
|
| 1323 | + * @param string $context View or edit context. |
|
| 1324 | + * @return float |
|
| 1325 | + */ |
|
| 1326 | + public function get_total_discount( $context = 'view' ) { |
|
| 1327 | + return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | /** |
| 1331 | - * Get the invoice tax total. |
|
| 1332 | - * |
|
| 1333 | - * @since 1.0.19 |
|
| 1334 | - * @param string $context View or edit context. |
|
| 1335 | - * @return float |
|
| 1336 | - */ |
|
| 1337 | - public function get_total_tax( $context = 'view' ) { |
|
| 1338 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1339 | - } |
|
| 1331 | + * Get the invoice tax total. |
|
| 1332 | + * |
|
| 1333 | + * @since 1.0.19 |
|
| 1334 | + * @param string $context View or edit context. |
|
| 1335 | + * @return float |
|
| 1336 | + */ |
|
| 1337 | + public function get_total_tax( $context = 'view' ) { |
|
| 1338 | + return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1339 | + } |
|
| 1340 | 1340 | |
| 1341 | - /** |
|
| 1342 | - * @deprecated |
|
| 1343 | - */ |
|
| 1344 | - public function get_final_tax( $currency = false ) { |
|
| 1345 | - $tax = $this->get_total_tax(); |
|
| 1341 | + /** |
|
| 1342 | + * @deprecated |
|
| 1343 | + */ |
|
| 1344 | + public function get_final_tax( $currency = false ) { |
|
| 1345 | + $tax = $this->get_total_tax(); |
|
| 1346 | 1346 | |
| 1347 | 1347 | if ( $currency ) { |
| 1348 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1348 | + return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | return $tax; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | /** |
| 1355 | - * Get the invoice fees total. |
|
| 1356 | - * |
|
| 1357 | - * @since 1.0.19 |
|
| 1358 | - * @param string $context View or edit context. |
|
| 1359 | - * @return float |
|
| 1360 | - */ |
|
| 1361 | - public function get_total_fees( $context = 'view' ) { |
|
| 1362 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1355 | + * Get the invoice fees total. |
|
| 1356 | + * |
|
| 1357 | + * @since 1.0.19 |
|
| 1358 | + * @param string $context View or edit context. |
|
| 1359 | + * @return float |
|
| 1360 | + */ |
|
| 1361 | + public function get_total_fees( $context = 'view' ) { |
|
| 1362 | + return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | /** |
| 1366 | - * Alias for self::get_total_fees(). |
|
| 1367 | - * |
|
| 1368 | - * @since 1.0.19 |
|
| 1369 | - * @param string $context View or edit context. |
|
| 1370 | - * @return float |
|
| 1371 | - */ |
|
| 1372 | - public function get_fees_total( $context = 'view' ) { |
|
| 1373 | - return $this->get_total_fees( $context ); |
|
| 1366 | + * Alias for self::get_total_fees(). |
|
| 1367 | + * |
|
| 1368 | + * @since 1.0.19 |
|
| 1369 | + * @param string $context View or edit context. |
|
| 1370 | + * @return float |
|
| 1371 | + */ |
|
| 1372 | + public function get_fees_total( $context = 'view' ) { |
|
| 1373 | + return $this->get_total_fees( $context ); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | /** |
| 1377 | - * Get the invoice total. |
|
| 1378 | - * |
|
| 1379 | - * @since 1.0.19 |
|
| 1377 | + * Get the invoice total. |
|
| 1378 | + * |
|
| 1379 | + * @since 1.0.19 |
|
| 1380 | 1380 | * @return float |
| 1381 | - */ |
|
| 1382 | - public function get_total() { |
|
| 1383 | - $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1384 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1381 | + */ |
|
| 1382 | + public function get_total() { |
|
| 1383 | + $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1384 | + return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | /** |
| 1388 | - * Get the initial invoice total. |
|
| 1389 | - * |
|
| 1390 | - * @since 1.0.19 |
|
| 1388 | + * Get the initial invoice total. |
|
| 1389 | + * |
|
| 1390 | + * @since 1.0.19 |
|
| 1391 | 1391 | * @param string $context View or edit context. |
| 1392 | 1392 | * @return float |
| 1393 | - */ |
|
| 1393 | + */ |
|
| 1394 | 1394 | public function get_initial_total() { |
| 1395 | 1395 | |
| 1396 | - if ( empty( $this->totals ) ) { |
|
| 1397 | - $this->recalculate_total(); |
|
| 1398 | - } |
|
| 1396 | + if ( empty( $this->totals ) ) { |
|
| 1397 | + $this->recalculate_total(); |
|
| 1398 | + } |
|
| 1399 | 1399 | |
| 1400 | - $tax = $this->totals['tax']['initial']; |
|
| 1401 | - $fee = $this->totals['fee']['initial']; |
|
| 1402 | - $discount = $this->totals['discount']['initial']; |
|
| 1403 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1404 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1400 | + $tax = $this->totals['tax']['initial']; |
|
| 1401 | + $fee = $this->totals['fee']['initial']; |
|
| 1402 | + $discount = $this->totals['discount']['initial']; |
|
| 1403 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1404 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1405 | 1405 | |
| 1406 | - if ( 0 > $total ) { |
|
| 1407 | - $total = 0; |
|
| 1408 | - } |
|
| 1406 | + if ( 0 > $total ) { |
|
| 1407 | + $total = 0; |
|
| 1408 | + } |
|
| 1409 | 1409 | |
| 1410 | 1410 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1411 | - } |
|
| 1411 | + } |
|
| 1412 | 1412 | |
| 1413 | - /** |
|
| 1414 | - * Get the recurring invoice total. |
|
| 1415 | - * |
|
| 1416 | - * @since 1.0.19 |
|
| 1413 | + /** |
|
| 1414 | + * Get the recurring invoice total. |
|
| 1415 | + * |
|
| 1416 | + * @since 1.0.19 |
|
| 1417 | 1417 | * @param string $context View or edit context. |
| 1418 | 1418 | * @return float |
| 1419 | - */ |
|
| 1419 | + */ |
|
| 1420 | 1420 | public function get_recurring_total() { |
| 1421 | 1421 | |
| 1422 | - if ( empty( $this->totals ) ) { |
|
| 1423 | - $this->recalculate_total(); |
|
| 1424 | - } |
|
| 1422 | + if ( empty( $this->totals ) ) { |
|
| 1423 | + $this->recalculate_total(); |
|
| 1424 | + } |
|
| 1425 | 1425 | |
| 1426 | - $tax = $this->totals['tax']['recurring']; |
|
| 1427 | - $fee = $this->totals['fee']['recurring']; |
|
| 1428 | - $discount = $this->totals['discount']['recurring']; |
|
| 1429 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1430 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1426 | + $tax = $this->totals['tax']['recurring']; |
|
| 1427 | + $fee = $this->totals['fee']['recurring']; |
|
| 1428 | + $discount = $this->totals['discount']['recurring']; |
|
| 1429 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1430 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1431 | 1431 | |
| 1432 | - if ( 0 > $total ) { |
|
| 1433 | - $total = 0; |
|
| 1434 | - } |
|
| 1432 | + if ( 0 > $total ) { |
|
| 1433 | + $total = 0; |
|
| 1434 | + } |
|
| 1435 | 1435 | |
| 1436 | 1436 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1437 | - } |
|
| 1437 | + } |
|
| 1438 | 1438 | |
| 1439 | - /** |
|
| 1440 | - * Returns recurring payment details. |
|
| 1441 | - * |
|
| 1442 | - * @since 1.0.19 |
|
| 1439 | + /** |
|
| 1440 | + * Returns recurring payment details. |
|
| 1441 | + * |
|
| 1442 | + * @since 1.0.19 |
|
| 1443 | 1443 | * @param string $field Optionally provide a field to return. |
| 1444 | - * @param string $currency Whether to include the currency. |
|
| 1444 | + * @param string $currency Whether to include the currency. |
|
| 1445 | 1445 | * @return float |
| 1446 | - */ |
|
| 1446 | + */ |
|
| 1447 | 1447 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1448 | 1448 | |
| 1449 | - // Maybe recalculate totals. |
|
| 1450 | - if ( empty( $this->totals ) ) { |
|
| 1451 | - $this->recalculate_total(); |
|
| 1452 | - } |
|
| 1449 | + // Maybe recalculate totals. |
|
| 1450 | + if ( empty( $this->totals ) ) { |
|
| 1451 | + $this->recalculate_total(); |
|
| 1452 | + } |
|
| 1453 | 1453 | |
| 1454 | - // Prepare recurring totals. |
|
| 1454 | + // Prepare recurring totals. |
|
| 1455 | 1455 | $data = apply_filters( |
| 1456 | - 'wpinv_get_invoice_recurring_details', |
|
| 1457 | - array( |
|
| 1458 | - 'cart_details' => $this->get_cart_details(), |
|
| 1459 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1460 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1461 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1462 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1463 | - 'total' => $this->get_recurring_total(), |
|
| 1464 | - ), |
|
| 1465 | - $this, |
|
| 1466 | - $field, |
|
| 1467 | - $currency |
|
| 1468 | - ); |
|
| 1456 | + 'wpinv_get_invoice_recurring_details', |
|
| 1457 | + array( |
|
| 1458 | + 'cart_details' => $this->get_cart_details(), |
|
| 1459 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1460 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1461 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1462 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1463 | + 'total' => $this->get_recurring_total(), |
|
| 1464 | + ), |
|
| 1465 | + $this, |
|
| 1466 | + $field, |
|
| 1467 | + $currency |
|
| 1468 | + ); |
|
| 1469 | 1469 | |
| 1470 | 1470 | if ( isset( $data[$field] ) ) { |
| 1471 | 1471 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1475,145 +1475,145 @@ discard block |
||
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | 1477 | /** |
| 1478 | - * Get the invoice fees. |
|
| 1479 | - * |
|
| 1480 | - * @since 1.0.19 |
|
| 1481 | - * @param string $context View or edit context. |
|
| 1482 | - * @return array |
|
| 1483 | - */ |
|
| 1484 | - public function get_fees( $context = 'view' ) { |
|
| 1485 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1478 | + * Get the invoice fees. |
|
| 1479 | + * |
|
| 1480 | + * @since 1.0.19 |
|
| 1481 | + * @param string $context View or edit context. |
|
| 1482 | + * @return array |
|
| 1483 | + */ |
|
| 1484 | + public function get_fees( $context = 'view' ) { |
|
| 1485 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | /** |
| 1489 | - * Get the invoice discounts. |
|
| 1490 | - * |
|
| 1491 | - * @since 1.0.19 |
|
| 1492 | - * @param string $context View or edit context. |
|
| 1493 | - * @return array |
|
| 1494 | - */ |
|
| 1495 | - public function get_discounts( $context = 'view' ) { |
|
| 1496 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1489 | + * Get the invoice discounts. |
|
| 1490 | + * |
|
| 1491 | + * @since 1.0.19 |
|
| 1492 | + * @param string $context View or edit context. |
|
| 1493 | + * @return array |
|
| 1494 | + */ |
|
| 1495 | + public function get_discounts( $context = 'view' ) { |
|
| 1496 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | /** |
| 1500 | - * Get the invoice taxes. |
|
| 1501 | - * |
|
| 1502 | - * @since 1.0.19 |
|
| 1503 | - * @param string $context View or edit context. |
|
| 1504 | - * @return array |
|
| 1505 | - */ |
|
| 1506 | - public function get_taxes( $context = 'view' ) { |
|
| 1507 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1500 | + * Get the invoice taxes. |
|
| 1501 | + * |
|
| 1502 | + * @since 1.0.19 |
|
| 1503 | + * @param string $context View or edit context. |
|
| 1504 | + * @return array |
|
| 1505 | + */ |
|
| 1506 | + public function get_taxes( $context = 'view' ) { |
|
| 1507 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | /** |
| 1511 | - * Get the invoice items. |
|
| 1512 | - * |
|
| 1513 | - * @since 1.0.19 |
|
| 1514 | - * @param string $context View or edit context. |
|
| 1515 | - * @return GetPaid_Form_Item[] |
|
| 1516 | - */ |
|
| 1517 | - public function get_items( $context = 'view' ) { |
|
| 1511 | + * Get the invoice items. |
|
| 1512 | + * |
|
| 1513 | + * @since 1.0.19 |
|
| 1514 | + * @param string $context View or edit context. |
|
| 1515 | + * @return GetPaid_Form_Item[] |
|
| 1516 | + */ |
|
| 1517 | + public function get_items( $context = 'view' ) { |
|
| 1518 | 1518 | return $this->get_prop( 'items', $context ); |
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | /** |
| 1522 | - * Get the invoice's payment form. |
|
| 1523 | - * |
|
| 1524 | - * @since 1.0.19 |
|
| 1525 | - * @param string $context View or edit context. |
|
| 1526 | - * @return int |
|
| 1527 | - */ |
|
| 1528 | - public function get_payment_form( $context = 'view' ) { |
|
| 1529 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1522 | + * Get the invoice's payment form. |
|
| 1523 | + * |
|
| 1524 | + * @since 1.0.19 |
|
| 1525 | + * @param string $context View or edit context. |
|
| 1526 | + * @return int |
|
| 1527 | + */ |
|
| 1528 | + public function get_payment_form( $context = 'view' ) { |
|
| 1529 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | /** |
| 1533 | - * Get the invoice's submission id. |
|
| 1534 | - * |
|
| 1535 | - * @since 1.0.19 |
|
| 1536 | - * @param string $context View or edit context. |
|
| 1537 | - * @return string |
|
| 1538 | - */ |
|
| 1539 | - public function get_submission_id( $context = 'view' ) { |
|
| 1540 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1533 | + * Get the invoice's submission id. |
|
| 1534 | + * |
|
| 1535 | + * @since 1.0.19 |
|
| 1536 | + * @param string $context View or edit context. |
|
| 1537 | + * @return string |
|
| 1538 | + */ |
|
| 1539 | + public function get_submission_id( $context = 'view' ) { |
|
| 1540 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | /** |
| 1544 | - * Get the invoice's discount code. |
|
| 1545 | - * |
|
| 1546 | - * @since 1.0.19 |
|
| 1547 | - * @param string $context View or edit context. |
|
| 1548 | - * @return string |
|
| 1549 | - */ |
|
| 1550 | - public function get_discount_code( $context = 'view' ) { |
|
| 1551 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1544 | + * Get the invoice's discount code. |
|
| 1545 | + * |
|
| 1546 | + * @since 1.0.19 |
|
| 1547 | + * @param string $context View or edit context. |
|
| 1548 | + * @return string |
|
| 1549 | + */ |
|
| 1550 | + public function get_discount_code( $context = 'view' ) { |
|
| 1551 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | 1554 | /** |
| 1555 | - * Get the invoice's gateway. |
|
| 1556 | - * |
|
| 1557 | - * @since 1.0.19 |
|
| 1558 | - * @param string $context View or edit context. |
|
| 1559 | - * @return string |
|
| 1560 | - */ |
|
| 1561 | - public function get_gateway( $context = 'view' ) { |
|
| 1562 | - return $this->get_prop( 'gateway', $context ); |
|
| 1555 | + * Get the invoice's gateway. |
|
| 1556 | + * |
|
| 1557 | + * @since 1.0.19 |
|
| 1558 | + * @param string $context View or edit context. |
|
| 1559 | + * @return string |
|
| 1560 | + */ |
|
| 1561 | + public function get_gateway( $context = 'view' ) { |
|
| 1562 | + return $this->get_prop( 'gateway', $context ); |
|
| 1563 | 1563 | } |
| 1564 | 1564 | |
| 1565 | 1565 | /** |
| 1566 | - * Get the invoice's gateway display title. |
|
| 1567 | - * |
|
| 1568 | - * @since 1.0.19 |
|
| 1569 | - * @return string |
|
| 1570 | - */ |
|
| 1566 | + * Get the invoice's gateway display title. |
|
| 1567 | + * |
|
| 1568 | + * @since 1.0.19 |
|
| 1569 | + * @return string |
|
| 1570 | + */ |
|
| 1571 | 1571 | public function get_gateway_title() { |
| 1572 | 1572 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1573 | 1573 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | /** |
| 1577 | - * Get the invoice's transaction id. |
|
| 1578 | - * |
|
| 1579 | - * @since 1.0.19 |
|
| 1580 | - * @param string $context View or edit context. |
|
| 1581 | - * @return string |
|
| 1582 | - */ |
|
| 1583 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1584 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1577 | + * Get the invoice's transaction id. |
|
| 1578 | + * |
|
| 1579 | + * @since 1.0.19 |
|
| 1580 | + * @param string $context View or edit context. |
|
| 1581 | + * @return string |
|
| 1582 | + */ |
|
| 1583 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1584 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | /** |
| 1588 | - * Get the invoice's currency. |
|
| 1589 | - * |
|
| 1590 | - * @since 1.0.19 |
|
| 1591 | - * @param string $context View or edit context. |
|
| 1592 | - * @return string |
|
| 1593 | - */ |
|
| 1594 | - public function get_currency( $context = 'view' ) { |
|
| 1588 | + * Get the invoice's currency. |
|
| 1589 | + * |
|
| 1590 | + * @since 1.0.19 |
|
| 1591 | + * @param string $context View or edit context. |
|
| 1592 | + * @return string |
|
| 1593 | + */ |
|
| 1594 | + public function get_currency( $context = 'view' ) { |
|
| 1595 | 1595 | $currency = $this->get_prop( 'currency', $context ); |
| 1596 | 1596 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | 1599 | /** |
| 1600 | - * Checks if we are charging taxes for this invoice. |
|
| 1601 | - * |
|
| 1602 | - * @since 1.0.19 |
|
| 1603 | - * @param string $context View or edit context. |
|
| 1604 | - * @return bool |
|
| 1605 | - */ |
|
| 1606 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1600 | + * Checks if we are charging taxes for this invoice. |
|
| 1601 | + * |
|
| 1602 | + * @since 1.0.19 |
|
| 1603 | + * @param string $context View or edit context. |
|
| 1604 | + * @return bool |
|
| 1605 | + */ |
|
| 1606 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1607 | 1607 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | /** |
| 1611 | - * Retrieves the remote subscription id for an invoice. |
|
| 1612 | - * |
|
| 1613 | - * @since 1.0.19 |
|
| 1614 | - * @param string $context View or edit context. |
|
| 1615 | - * @return int |
|
| 1616 | - */ |
|
| 1611 | + * Retrieves the remote subscription id for an invoice. |
|
| 1612 | + * |
|
| 1613 | + * @since 1.0.19 |
|
| 1614 | + * @param string $context View or edit context. |
|
| 1615 | + * @return int |
|
| 1616 | + */ |
|
| 1617 | 1617 | public function get_subscription_id( $context = 'view' ) { |
| 1618 | 1618 | $subscription_id = $this->get_prop( 'subscription_id', $context ); |
| 1619 | 1619 | |
@@ -1626,12 +1626,12 @@ discard block |
||
| 1626 | 1626 | } |
| 1627 | 1627 | |
| 1628 | 1628 | /** |
| 1629 | - * Retrieves the payment meta for an invoice. |
|
| 1630 | - * |
|
| 1631 | - * @since 1.0.19 |
|
| 1632 | - * @param string $context View or edit context. |
|
| 1633 | - * @return array |
|
| 1634 | - */ |
|
| 1629 | + * Retrieves the payment meta for an invoice. |
|
| 1630 | + * |
|
| 1631 | + * @since 1.0.19 |
|
| 1632 | + * @param string $context View or edit context. |
|
| 1633 | + * @return array |
|
| 1634 | + */ |
|
| 1635 | 1635 | public function get_payment_meta( $context = 'view' ) { |
| 1636 | 1636 | |
| 1637 | 1637 | return array( |
@@ -1651,11 +1651,11 @@ discard block |
||
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | /** |
| 1654 | - * Retrieves the cart details for an invoice. |
|
| 1655 | - * |
|
| 1656 | - * @since 1.0.19 |
|
| 1657 | - * @return array |
|
| 1658 | - */ |
|
| 1654 | + * Retrieves the cart details for an invoice. |
|
| 1655 | + * |
|
| 1656 | + * @since 1.0.19 |
|
| 1657 | + * @return array |
|
| 1658 | + */ |
|
| 1659 | 1659 | public function get_cart_details() { |
| 1660 | 1660 | $items = $this->get_items(); |
| 1661 | 1661 | $cart_details = array(); |
@@ -1665,16 +1665,16 @@ discard block |
||
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | return $cart_details; |
| 1668 | - } |
|
| 1668 | + } |
|
| 1669 | 1669 | |
| 1670 | - /** |
|
| 1671 | - * Retrieves the recurring item. |
|
| 1672 | - * |
|
| 1673 | - * @return null|GetPaid_Form_Item|int |
|
| 1674 | - */ |
|
| 1675 | - public function get_recurring( $object = false ) { |
|
| 1670 | + /** |
|
| 1671 | + * Retrieves the recurring item. |
|
| 1672 | + * |
|
| 1673 | + * @return null|GetPaid_Form_Item|int |
|
| 1674 | + */ |
|
| 1675 | + public function get_recurring( $object = false ) { |
|
| 1676 | 1676 | |
| 1677 | - // Are we returning an object? |
|
| 1677 | + // Are we returning an object? |
|
| 1678 | 1678 | if ( $object ) { |
| 1679 | 1679 | return $this->get_item( $this->recurring_item ); |
| 1680 | 1680 | } |
@@ -1682,100 +1682,100 @@ discard block |
||
| 1682 | 1682 | return $this->recurring_item; |
| 1683 | 1683 | } |
| 1684 | 1684 | |
| 1685 | - /** |
|
| 1686 | - * Retrieves the subscription name. |
|
| 1687 | - * |
|
| 1688 | - * @since 1.0.19 |
|
| 1689 | - * @return string |
|
| 1690 | - */ |
|
| 1691 | - public function get_subscription_name() { |
|
| 1685 | + /** |
|
| 1686 | + * Retrieves the subscription name. |
|
| 1687 | + * |
|
| 1688 | + * @since 1.0.19 |
|
| 1689 | + * @return string |
|
| 1690 | + */ |
|
| 1691 | + public function get_subscription_name() { |
|
| 1692 | 1692 | |
| 1693 | - // Retrieve the recurring name |
|
| 1693 | + // Retrieve the recurring name |
|
| 1694 | 1694 | $item = $this->get_recurring( true ); |
| 1695 | 1695 | |
| 1696 | - // Abort if it does not exist. |
|
| 1696 | + // Abort if it does not exist. |
|
| 1697 | 1697 | if ( empty( $item ) ) { |
| 1698 | 1698 | return ''; |
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | - // Return the item name. |
|
| 1701 | + // Return the item name. |
|
| 1702 | 1702 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1703 | - } |
|
| 1704 | - |
|
| 1705 | - /** |
|
| 1706 | - * Retrieves the view url. |
|
| 1707 | - * |
|
| 1708 | - * @since 1.0.19 |
|
| 1709 | - * @return string |
|
| 1710 | - */ |
|
| 1711 | - public function get_view_url() { |
|
| 1703 | + } |
|
| 1704 | + |
|
| 1705 | + /** |
|
| 1706 | + * Retrieves the view url. |
|
| 1707 | + * |
|
| 1708 | + * @since 1.0.19 |
|
| 1709 | + * @return string |
|
| 1710 | + */ |
|
| 1711 | + public function get_view_url() { |
|
| 1712 | 1712 | $invoice_url = get_permalink( $this->get_id() ); |
| 1713 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1713 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1714 | 1714 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1715 | - } |
|
| 1715 | + } |
|
| 1716 | 1716 | |
| 1717 | - /** |
|
| 1718 | - * Retrieves the payment url. |
|
| 1719 | - * |
|
| 1720 | - * @since 1.0.19 |
|
| 1721 | - * @return string |
|
| 1722 | - */ |
|
| 1723 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1717 | + /** |
|
| 1718 | + * Retrieves the payment url. |
|
| 1719 | + * |
|
| 1720 | + * @since 1.0.19 |
|
| 1721 | + * @return string |
|
| 1722 | + */ |
|
| 1723 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1724 | 1724 | |
| 1725 | - // Retrieve the checkout url. |
|
| 1725 | + // Retrieve the checkout url. |
|
| 1726 | 1726 | $pay_url = wpinv_get_checkout_uri(); |
| 1727 | 1727 | |
| 1728 | - // Maybe force ssl. |
|
| 1728 | + // Maybe force ssl. |
|
| 1729 | 1729 | if ( is_ssl() ) { |
| 1730 | 1730 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | - // Add the invoice key. |
|
| 1734 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1733 | + // Add the invoice key. |
|
| 1734 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1735 | 1735 | |
| 1736 | - // (Maybe?) add a secret |
|
| 1736 | + // (Maybe?) add a secret |
|
| 1737 | 1737 | if ( $secret ) { |
| 1738 | 1738 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
| 1742 | - } |
|
| 1742 | + } |
|
| 1743 | 1743 | |
| 1744 | - /** |
|
| 1745 | - * Retrieves the receipt url. |
|
| 1746 | - * |
|
| 1747 | - * @since 1.0.19 |
|
| 1748 | - * @return string |
|
| 1749 | - */ |
|
| 1750 | - public function get_receipt_url() { |
|
| 1751 | - |
|
| 1752 | - // Retrieve the checkout url. |
|
| 1744 | + /** |
|
| 1745 | + * Retrieves the receipt url. |
|
| 1746 | + * |
|
| 1747 | + * @since 1.0.19 |
|
| 1748 | + * @return string |
|
| 1749 | + */ |
|
| 1750 | + public function get_receipt_url() { |
|
| 1751 | + |
|
| 1752 | + // Retrieve the checkout url. |
|
| 1753 | 1753 | $receipt_url = wpinv_get_success_page_uri(); |
| 1754 | 1754 | |
| 1755 | - // Maybe force ssl. |
|
| 1755 | + // Maybe force ssl. |
|
| 1756 | 1756 | if ( is_ssl() ) { |
| 1757 | 1757 | $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
| 1758 | 1758 | } |
| 1759 | 1759 | |
| 1760 | - // Add the invoice key. |
|
| 1761 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1760 | + // Add the invoice key. |
|
| 1761 | + $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1762 | 1762 | |
| 1763 | 1763 | return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | 1766 | /** |
| 1767 | - * Magic method for accessing invoice properties. |
|
| 1768 | - * |
|
| 1769 | - * @since 1.0.15 |
|
| 1770 | - * @access public |
|
| 1771 | - * |
|
| 1772 | - * @param string $key Discount data to retrieve |
|
| 1773 | - * @param string $context View or edit context. |
|
| 1774 | - * @return mixed Value of the given invoice property (if set). |
|
| 1775 | - */ |
|
| 1776 | - public function get( $key, $context = 'view' ) { |
|
| 1767 | + * Magic method for accessing invoice properties. |
|
| 1768 | + * |
|
| 1769 | + * @since 1.0.15 |
|
| 1770 | + * @access public |
|
| 1771 | + * |
|
| 1772 | + * @param string $key Discount data to retrieve |
|
| 1773 | + * @param string $context View or edit context. |
|
| 1774 | + * @return mixed Value of the given invoice property (if set). |
|
| 1775 | + */ |
|
| 1776 | + public function get( $key, $context = 'view' ) { |
|
| 1777 | 1777 | return $this->get_prop( $key, $context ); |
| 1778 | - } |
|
| 1778 | + } |
|
| 1779 | 1779 | |
| 1780 | 1780 | /* |
| 1781 | 1781 | |-------------------------------------------------------------------------- |
@@ -1788,131 +1788,131 @@ discard block |
||
| 1788 | 1788 | */ |
| 1789 | 1789 | |
| 1790 | 1790 | /** |
| 1791 | - * Magic method for setting invoice properties. |
|
| 1792 | - * |
|
| 1793 | - * @since 1.0.19 |
|
| 1794 | - * @access public |
|
| 1795 | - * |
|
| 1796 | - * @param string $key Discount data to retrieve |
|
| 1797 | - * @param mixed $value new value. |
|
| 1798 | - * @return mixed Value of the given invoice property (if set). |
|
| 1799 | - */ |
|
| 1800 | - public function set( $key, $value ) { |
|
| 1791 | + * Magic method for setting invoice properties. |
|
| 1792 | + * |
|
| 1793 | + * @since 1.0.19 |
|
| 1794 | + * @access public |
|
| 1795 | + * |
|
| 1796 | + * @param string $key Discount data to retrieve |
|
| 1797 | + * @param mixed $value new value. |
|
| 1798 | + * @return mixed Value of the given invoice property (if set). |
|
| 1799 | + */ |
|
| 1800 | + public function set( $key, $value ) { |
|
| 1801 | 1801 | |
| 1802 | 1802 | $setter = "set_$key"; |
| 1803 | 1803 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1804 | 1804 | $this->{$setter}( $value ); |
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | - } |
|
| 1807 | + } |
|
| 1808 | 1808 | |
| 1809 | - /** |
|
| 1810 | - * Sets item status. |
|
| 1811 | - * |
|
| 1812 | - * @since 1.0.19 |
|
| 1813 | - * @param string $new_status New status. |
|
| 1814 | - * @param string $note Optional note to add. |
|
| 1815 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1816 | - * @return array details of change. |
|
| 1817 | - */ |
|
| 1818 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1819 | - $old_status = $this->get_status(); |
|
| 1809 | + /** |
|
| 1810 | + * Sets item status. |
|
| 1811 | + * |
|
| 1812 | + * @since 1.0.19 |
|
| 1813 | + * @param string $new_status New status. |
|
| 1814 | + * @param string $note Optional note to add. |
|
| 1815 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1816 | + * @return array details of change. |
|
| 1817 | + */ |
|
| 1818 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1819 | + $old_status = $this->get_status(); |
|
| 1820 | 1820 | |
| 1821 | - $statuses = $this->get_all_statuses(); |
|
| 1821 | + $statuses = $this->get_all_statuses(); |
|
| 1822 | 1822 | |
| 1823 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1824 | - unset( $statuses[ 'draft' ] ); |
|
| 1825 | - } |
|
| 1823 | + if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1824 | + unset( $statuses[ 'draft' ] ); |
|
| 1825 | + } |
|
| 1826 | 1826 | |
| 1827 | 1827 | |
| 1828 | - $this->set_prop( 'status', $new_status ); |
|
| 1828 | + $this->set_prop( 'status', $new_status ); |
|
| 1829 | 1829 | |
| 1830 | - // If setting the status, ensure it's set to a valid status. |
|
| 1831 | - if ( true === $this->object_read ) { |
|
| 1830 | + // If setting the status, ensure it's set to a valid status. |
|
| 1831 | + if ( true === $this->object_read ) { |
|
| 1832 | 1832 | |
| 1833 | - // Only allow valid new status. |
|
| 1834 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1835 | - $new_status = 'wpi-pending'; |
|
| 1836 | - } |
|
| 1833 | + // Only allow valid new status. |
|
| 1834 | + if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1835 | + $new_status = 'wpi-pending'; |
|
| 1836 | + } |
|
| 1837 | 1837 | |
| 1838 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1839 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1840 | - $old_status = 'wpi-pending'; |
|
| 1841 | - } |
|
| 1838 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1839 | + if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1840 | + $old_status = 'wpi-pending'; |
|
| 1841 | + } |
|
| 1842 | 1842 | |
| 1843 | - // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1844 | - if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) { |
|
| 1845 | - $old_status = 'wpi-pending'; |
|
| 1846 | - } |
|
| 1843 | + // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1844 | + if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) { |
|
| 1845 | + $old_status = 'wpi-pending'; |
|
| 1846 | + } |
|
| 1847 | 1847 | |
| 1848 | - } |
|
| 1848 | + } |
|
| 1849 | 1849 | |
| 1850 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1851 | - $this->status_transition = array( |
|
| 1852 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1853 | - 'to' => $new_status, |
|
| 1854 | - 'note' => $note, |
|
| 1855 | - 'manual' => (bool) $manual_update, |
|
| 1856 | - ); |
|
| 1850 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1851 | + $this->status_transition = array( |
|
| 1852 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1853 | + 'to' => $new_status, |
|
| 1854 | + 'note' => $note, |
|
| 1855 | + 'manual' => (bool) $manual_update, |
|
| 1856 | + ); |
|
| 1857 | 1857 | |
| 1858 | - if ( $manual_update ) { |
|
| 1859 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1860 | - } |
|
| 1858 | + if ( $manual_update ) { |
|
| 1859 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1860 | + } |
|
| 1861 | 1861 | |
| 1862 | - $this->maybe_set_date_paid(); |
|
| 1862 | + $this->maybe_set_date_paid(); |
|
| 1863 | 1863 | |
| 1864 | - } |
|
| 1864 | + } |
|
| 1865 | 1865 | |
| 1866 | - return array( |
|
| 1867 | - 'from' => $old_status, |
|
| 1868 | - 'to' => $new_status, |
|
| 1869 | - ); |
|
| 1870 | - } |
|
| 1866 | + return array( |
|
| 1867 | + 'from' => $old_status, |
|
| 1868 | + 'to' => $new_status, |
|
| 1869 | + ); |
|
| 1870 | + } |
|
| 1871 | 1871 | |
| 1872 | - /** |
|
| 1873 | - * Maybe set date paid. |
|
| 1874 | - * |
|
| 1875 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 1876 | - * order status. |
|
| 1877 | - * |
|
| 1878 | - * @since 1.0.19 |
|
| 1879 | - */ |
|
| 1880 | - public function maybe_set_date_paid() { |
|
| 1872 | + /** |
|
| 1873 | + * Maybe set date paid. |
|
| 1874 | + * |
|
| 1875 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 1876 | + * order status. |
|
| 1877 | + * |
|
| 1878 | + * @since 1.0.19 |
|
| 1879 | + */ |
|
| 1880 | + public function maybe_set_date_paid() { |
|
| 1881 | 1881 | |
| 1882 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1883 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1884 | - } |
|
| 1885 | - } |
|
| 1882 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1883 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1884 | + } |
|
| 1885 | + } |
|
| 1886 | 1886 | |
| 1887 | 1887 | /** |
| 1888 | - * Set parent invoice ID. |
|
| 1889 | - * |
|
| 1890 | - * @since 1.0.19 |
|
| 1891 | - */ |
|
| 1892 | - public function set_parent_id( $value ) { |
|
| 1893 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1894 | - return; |
|
| 1895 | - } |
|
| 1896 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1888 | + * Set parent invoice ID. |
|
| 1889 | + * |
|
| 1890 | + * @since 1.0.19 |
|
| 1891 | + */ |
|
| 1892 | + public function set_parent_id( $value ) { |
|
| 1893 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1894 | + return; |
|
| 1895 | + } |
|
| 1896 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | 1899 | /** |
| 1900 | - * Set plugin version when the invoice was created. |
|
| 1901 | - * |
|
| 1902 | - * @since 1.0.19 |
|
| 1903 | - */ |
|
| 1904 | - public function set_version( $value ) { |
|
| 1905 | - $this->set_prop( 'version', $value ); |
|
| 1900 | + * Set plugin version when the invoice was created. |
|
| 1901 | + * |
|
| 1902 | + * @since 1.0.19 |
|
| 1903 | + */ |
|
| 1904 | + public function set_version( $value ) { |
|
| 1905 | + $this->set_prop( 'version', $value ); |
|
| 1906 | 1906 | } |
| 1907 | - |
|
| 1908 | - /** |
|
| 1909 | - * Set date when the invoice was created. |
|
| 1910 | - * |
|
| 1911 | - * @since 1.0.19 |
|
| 1912 | - * @param string $value Value to set. |
|
| 1907 | + |
|
| 1908 | + /** |
|
| 1909 | + * Set date when the invoice was created. |
|
| 1910 | + * |
|
| 1911 | + * @since 1.0.19 |
|
| 1912 | + * @param string $value Value to set. |
|
| 1913 | 1913 | * @return bool Whether or not the date was set. |
| 1914 | - */ |
|
| 1915 | - public function set_date_created( $value ) { |
|
| 1914 | + */ |
|
| 1915 | + public function set_date_created( $value ) { |
|
| 1916 | 1916 | $date = strtotime( $value ); |
| 1917 | 1917 | |
| 1918 | 1918 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1925,13 +1925,13 @@ discard block |
||
| 1925 | 1925 | } |
| 1926 | 1926 | |
| 1927 | 1927 | /** |
| 1928 | - * Set date invoice due date. |
|
| 1929 | - * |
|
| 1930 | - * @since 1.0.19 |
|
| 1931 | - * @param string $value Value to set. |
|
| 1928 | + * Set date invoice due date. |
|
| 1929 | + * |
|
| 1930 | + * @since 1.0.19 |
|
| 1931 | + * @param string $value Value to set. |
|
| 1932 | 1932 | * @return bool Whether or not the date was set. |
| 1933 | - */ |
|
| 1934 | - public function set_due_date( $value ) { |
|
| 1933 | + */ |
|
| 1934 | + public function set_due_date( $value ) { |
|
| 1935 | 1935 | $date = strtotime( $value ); |
| 1936 | 1936 | |
| 1937 | 1937 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1939,29 +1939,29 @@ discard block |
||
| 1939 | 1939 | return true; |
| 1940 | 1940 | } |
| 1941 | 1941 | |
| 1942 | - $this->set_prop( 'due_date', '' ); |
|
| 1942 | + $this->set_prop( 'due_date', '' ); |
|
| 1943 | 1943 | return false; |
| 1944 | 1944 | |
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | /** |
| 1948 | - * Alias of self::set_due_date(). |
|
| 1949 | - * |
|
| 1950 | - * @since 1.0.19 |
|
| 1951 | - * @param string $value New name. |
|
| 1952 | - */ |
|
| 1953 | - public function set_date_due( $value ) { |
|
| 1954 | - $this->set_due_date( $value ); |
|
| 1948 | + * Alias of self::set_due_date(). |
|
| 1949 | + * |
|
| 1950 | + * @since 1.0.19 |
|
| 1951 | + * @param string $value New name. |
|
| 1952 | + */ |
|
| 1953 | + public function set_date_due( $value ) { |
|
| 1954 | + $this->set_due_date( $value ); |
|
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | 1957 | /** |
| 1958 | - * Set date invoice was completed. |
|
| 1959 | - * |
|
| 1960 | - * @since 1.0.19 |
|
| 1961 | - * @param string $value Value to set. |
|
| 1958 | + * Set date invoice was completed. |
|
| 1959 | + * |
|
| 1960 | + * @since 1.0.19 |
|
| 1961 | + * @param string $value Value to set. |
|
| 1962 | 1962 | * @return bool Whether or not the date was set. |
| 1963 | - */ |
|
| 1964 | - public function set_completed_date( $value ) { |
|
| 1963 | + */ |
|
| 1964 | + public function set_completed_date( $value ) { |
|
| 1965 | 1965 | $date = strtotime( $value ); |
| 1966 | 1966 | |
| 1967 | 1967 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1969,29 +1969,29 @@ discard block |
||
| 1969 | 1969 | return true; |
| 1970 | 1970 | } |
| 1971 | 1971 | |
| 1972 | - $this->set_prop( 'completed_date', '' ); |
|
| 1972 | + $this->set_prop( 'completed_date', '' ); |
|
| 1973 | 1973 | return false; |
| 1974 | 1974 | |
| 1975 | 1975 | } |
| 1976 | 1976 | |
| 1977 | 1977 | /** |
| 1978 | - * Alias of self::set_completed_date(). |
|
| 1979 | - * |
|
| 1980 | - * @since 1.0.19 |
|
| 1981 | - * @param string $value New name. |
|
| 1982 | - */ |
|
| 1983 | - public function set_date_completed( $value ) { |
|
| 1984 | - $this->set_completed_date( $value ); |
|
| 1978 | + * Alias of self::set_completed_date(). |
|
| 1979 | + * |
|
| 1980 | + * @since 1.0.19 |
|
| 1981 | + * @param string $value New name. |
|
| 1982 | + */ |
|
| 1983 | + public function set_date_completed( $value ) { |
|
| 1984 | + $this->set_completed_date( $value ); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | /** |
| 1988 | - * Set date when the invoice was last modified. |
|
| 1989 | - * |
|
| 1990 | - * @since 1.0.19 |
|
| 1991 | - * @param string $value Value to set. |
|
| 1988 | + * Set date when the invoice was last modified. |
|
| 1989 | + * |
|
| 1990 | + * @since 1.0.19 |
|
| 1991 | + * @param string $value Value to set. |
|
| 1992 | 1992 | * @return bool Whether or not the date was set. |
| 1993 | - */ |
|
| 1994 | - public function set_date_modified( $value ) { |
|
| 1993 | + */ |
|
| 1994 | + public function set_date_modified( $value ) { |
|
| 1995 | 1995 | $date = strtotime( $value ); |
| 1996 | 1996 | |
| 1997 | 1997 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1999,706 +1999,706 @@ discard block |
||
| 1999 | 1999 | return true; |
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | - $this->set_prop( 'date_modified', '' ); |
|
| 2002 | + $this->set_prop( 'date_modified', '' ); |
|
| 2003 | 2003 | return false; |
| 2004 | 2004 | |
| 2005 | 2005 | } |
| 2006 | 2006 | |
| 2007 | 2007 | /** |
| 2008 | - * Set the invoice number. |
|
| 2009 | - * |
|
| 2010 | - * @since 1.0.19 |
|
| 2011 | - * @param string $value New number. |
|
| 2012 | - */ |
|
| 2013 | - public function set_number( $value ) { |
|
| 2008 | + * Set the invoice number. |
|
| 2009 | + * |
|
| 2010 | + * @since 1.0.19 |
|
| 2011 | + * @param string $value New number. |
|
| 2012 | + */ |
|
| 2013 | + public function set_number( $value ) { |
|
| 2014 | 2014 | $number = sanitize_text_field( $value ); |
| 2015 | - $this->set_prop( 'number', $number ); |
|
| 2015 | + $this->set_prop( 'number', $number ); |
|
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | 2018 | /** |
| 2019 | - * Set the invoice type. |
|
| 2020 | - * |
|
| 2021 | - * @since 1.0.19 |
|
| 2022 | - * @param string $value Type. |
|
| 2023 | - */ |
|
| 2024 | - public function set_type( $value ) { |
|
| 2019 | + * Set the invoice type. |
|
| 2020 | + * |
|
| 2021 | + * @since 1.0.19 |
|
| 2022 | + * @param string $value Type. |
|
| 2023 | + */ |
|
| 2024 | + public function set_type( $value ) { |
|
| 2025 | 2025 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 2026 | - $this->set_prop( 'type', $type ); |
|
| 2027 | - } |
|
| 2026 | + $this->set_prop( 'type', $type ); |
|
| 2027 | + } |
|
| 2028 | 2028 | |
| 2029 | 2029 | /** |
| 2030 | - * Set the invoice post type. |
|
| 2031 | - * |
|
| 2032 | - * @since 1.0.19 |
|
| 2033 | - * @param string $value Post type. |
|
| 2034 | - */ |
|
| 2035 | - public function set_post_type( $value ) { |
|
| 2030 | + * Set the invoice post type. |
|
| 2031 | + * |
|
| 2032 | + * @since 1.0.19 |
|
| 2033 | + * @param string $value Post type. |
|
| 2034 | + */ |
|
| 2035 | + public function set_post_type( $value ) { |
|
| 2036 | 2036 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 2037 | - $this->set_type( $value ); |
|
| 2037 | + $this->set_type( $value ); |
|
| 2038 | 2038 | $this->set_prop( 'post_type', $value ); |
| 2039 | 2039 | } |
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | 2042 | /** |
| 2043 | - * Set the invoice key. |
|
| 2044 | - * |
|
| 2045 | - * @since 1.0.19 |
|
| 2046 | - * @param string $value New key. |
|
| 2047 | - */ |
|
| 2048 | - public function set_key( $value ) { |
|
| 2043 | + * Set the invoice key. |
|
| 2044 | + * |
|
| 2045 | + * @since 1.0.19 |
|
| 2046 | + * @param string $value New key. |
|
| 2047 | + */ |
|
| 2048 | + public function set_key( $value ) { |
|
| 2049 | 2049 | $key = sanitize_text_field( $value ); |
| 2050 | - $this->set_prop( 'key', $key ); |
|
| 2050 | + $this->set_prop( 'key', $key ); |
|
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | 2053 | /** |
| 2054 | - * Set the invoice mode. |
|
| 2055 | - * |
|
| 2056 | - * @since 1.0.19 |
|
| 2057 | - * @param string $value mode. |
|
| 2058 | - */ |
|
| 2059 | - public function set_mode( $value ) { |
|
| 2054 | + * Set the invoice mode. |
|
| 2055 | + * |
|
| 2056 | + * @since 1.0.19 |
|
| 2057 | + * @param string $value mode. |
|
| 2058 | + */ |
|
| 2059 | + public function set_mode( $value ) { |
|
| 2060 | 2060 | if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
| 2061 | 2061 | $this->set_prop( 'value', $value ); |
| 2062 | 2062 | } |
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | 2065 | /** |
| 2066 | - * Set the invoice path. |
|
| 2067 | - * |
|
| 2068 | - * @since 1.0.19 |
|
| 2069 | - * @param string $value path. |
|
| 2070 | - */ |
|
| 2071 | - public function set_path( $value ) { |
|
| 2066 | + * Set the invoice path. |
|
| 2067 | + * |
|
| 2068 | + * @since 1.0.19 |
|
| 2069 | + * @param string $value path. |
|
| 2070 | + */ |
|
| 2071 | + public function set_path( $value ) { |
|
| 2072 | 2072 | $this->set_prop( 'path', $value ); |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | 2075 | /** |
| 2076 | - * Set the invoice name. |
|
| 2077 | - * |
|
| 2078 | - * @since 1.0.19 |
|
| 2079 | - * @param string $value New name. |
|
| 2080 | - */ |
|
| 2081 | - public function set_name( $value ) { |
|
| 2076 | + * Set the invoice name. |
|
| 2077 | + * |
|
| 2078 | + * @since 1.0.19 |
|
| 2079 | + * @param string $value New name. |
|
| 2080 | + */ |
|
| 2081 | + public function set_name( $value ) { |
|
| 2082 | 2082 | $name = sanitize_text_field( $value ); |
| 2083 | - $this->set_prop( 'name', $name ); |
|
| 2083 | + $this->set_prop( 'name', $name ); |
|
| 2084 | 2084 | } |
| 2085 | 2085 | |
| 2086 | 2086 | /** |
| 2087 | - * Alias of self::set_name(). |
|
| 2088 | - * |
|
| 2089 | - * @since 1.0.19 |
|
| 2090 | - * @param string $value New name. |
|
| 2091 | - */ |
|
| 2092 | - public function set_title( $value ) { |
|
| 2093 | - $this->set_name( $value ); |
|
| 2087 | + * Alias of self::set_name(). |
|
| 2088 | + * |
|
| 2089 | + * @since 1.0.19 |
|
| 2090 | + * @param string $value New name. |
|
| 2091 | + */ |
|
| 2092 | + public function set_title( $value ) { |
|
| 2093 | + $this->set_name( $value ); |
|
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | 2096 | /** |
| 2097 | - * Set the invoice description. |
|
| 2098 | - * |
|
| 2099 | - * @since 1.0.19 |
|
| 2100 | - * @param string $value New description. |
|
| 2101 | - */ |
|
| 2102 | - public function set_description( $value ) { |
|
| 2097 | + * Set the invoice description. |
|
| 2098 | + * |
|
| 2099 | + * @since 1.0.19 |
|
| 2100 | + * @param string $value New description. |
|
| 2101 | + */ |
|
| 2102 | + public function set_description( $value ) { |
|
| 2103 | 2103 | $description = wp_kses_post( $value ); |
| 2104 | - return $this->set_prop( 'description', $description ); |
|
| 2104 | + return $this->set_prop( 'description', $description ); |
|
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | 2107 | /** |
| 2108 | - * Alias of self::set_description(). |
|
| 2109 | - * |
|
| 2110 | - * @since 1.0.19 |
|
| 2111 | - * @param string $value New description. |
|
| 2112 | - */ |
|
| 2113 | - public function set_excerpt( $value ) { |
|
| 2114 | - $this->set_description( $value ); |
|
| 2108 | + * Alias of self::set_description(). |
|
| 2109 | + * |
|
| 2110 | + * @since 1.0.19 |
|
| 2111 | + * @param string $value New description. |
|
| 2112 | + */ |
|
| 2113 | + public function set_excerpt( $value ) { |
|
| 2114 | + $this->set_description( $value ); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | 2117 | /** |
| 2118 | - * Alias of self::set_description(). |
|
| 2119 | - * |
|
| 2120 | - * @since 1.0.19 |
|
| 2121 | - * @param string $value New description. |
|
| 2122 | - */ |
|
| 2123 | - public function set_summary( $value ) { |
|
| 2124 | - $this->set_description( $value ); |
|
| 2118 | + * Alias of self::set_description(). |
|
| 2119 | + * |
|
| 2120 | + * @since 1.0.19 |
|
| 2121 | + * @param string $value New description. |
|
| 2122 | + */ |
|
| 2123 | + public function set_summary( $value ) { |
|
| 2124 | + $this->set_description( $value ); |
|
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | 2127 | /** |
| 2128 | - * Set the receiver of the invoice. |
|
| 2129 | - * |
|
| 2130 | - * @since 1.0.19 |
|
| 2131 | - * @param int $value New author. |
|
| 2132 | - */ |
|
| 2133 | - public function set_author( $value ) { |
|
| 2134 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2128 | + * Set the receiver of the invoice. |
|
| 2129 | + * |
|
| 2130 | + * @since 1.0.19 |
|
| 2131 | + * @param int $value New author. |
|
| 2132 | + */ |
|
| 2133 | + public function set_author( $value ) { |
|
| 2134 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2135 | 2135 | |
| 2136 | - if ( $user && $user->ID ) { |
|
| 2137 | - $this->set_prop( 'author', $user->ID ); |
|
| 2138 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2139 | - } |
|
| 2136 | + if ( $user && $user->ID ) { |
|
| 2137 | + $this->set_prop( 'author', $user->ID ); |
|
| 2138 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2139 | + } |
|
| 2140 | 2140 | |
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | /** |
| 2144 | - * Alias of self::set_author(). |
|
| 2145 | - * |
|
| 2146 | - * @since 1.0.19 |
|
| 2147 | - * @param int $value New user id. |
|
| 2148 | - */ |
|
| 2149 | - public function set_user_id( $value ) { |
|
| 2150 | - $this->set_author( $value ); |
|
| 2144 | + * Alias of self::set_author(). |
|
| 2145 | + * |
|
| 2146 | + * @since 1.0.19 |
|
| 2147 | + * @param int $value New user id. |
|
| 2148 | + */ |
|
| 2149 | + public function set_user_id( $value ) { |
|
| 2150 | + $this->set_author( $value ); |
|
| 2151 | 2151 | } |
| 2152 | 2152 | |
| 2153 | 2153 | /** |
| 2154 | - * Alias of self::set_author(). |
|
| 2155 | - * |
|
| 2156 | - * @since 1.0.19 |
|
| 2157 | - * @param int $value New user id. |
|
| 2158 | - */ |
|
| 2159 | - public function set_customer_id( $value ) { |
|
| 2160 | - $this->set_author( $value ); |
|
| 2154 | + * Alias of self::set_author(). |
|
| 2155 | + * |
|
| 2156 | + * @since 1.0.19 |
|
| 2157 | + * @param int $value New user id. |
|
| 2158 | + */ |
|
| 2159 | + public function set_customer_id( $value ) { |
|
| 2160 | + $this->set_author( $value ); |
|
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | /** |
| 2164 | - * Set the customer's ip. |
|
| 2165 | - * |
|
| 2166 | - * @since 1.0.19 |
|
| 2167 | - * @param string $value ip address. |
|
| 2168 | - */ |
|
| 2169 | - public function set_ip( $value ) { |
|
| 2170 | - $this->set_prop( 'ip', $value ); |
|
| 2164 | + * Set the customer's ip. |
|
| 2165 | + * |
|
| 2166 | + * @since 1.0.19 |
|
| 2167 | + * @param string $value ip address. |
|
| 2168 | + */ |
|
| 2169 | + public function set_ip( $value ) { |
|
| 2170 | + $this->set_prop( 'ip', $value ); |
|
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | 2173 | /** |
| 2174 | - * Alias of self::set_ip(). |
|
| 2175 | - * |
|
| 2176 | - * @since 1.0.19 |
|
| 2177 | - * @param string $value ip address. |
|
| 2178 | - */ |
|
| 2179 | - public function set_user_ip( $value ) { |
|
| 2180 | - $this->set_ip( $value ); |
|
| 2174 | + * Alias of self::set_ip(). |
|
| 2175 | + * |
|
| 2176 | + * @since 1.0.19 |
|
| 2177 | + * @param string $value ip address. |
|
| 2178 | + */ |
|
| 2179 | + public function set_user_ip( $value ) { |
|
| 2180 | + $this->set_ip( $value ); |
|
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | /** |
| 2184 | - * Set the customer's first name. |
|
| 2185 | - * |
|
| 2186 | - * @since 1.0.19 |
|
| 2187 | - * @param string $value first name. |
|
| 2188 | - */ |
|
| 2189 | - public function set_first_name( $value ) { |
|
| 2190 | - $this->set_prop( 'first_name', $value ); |
|
| 2184 | + * Set the customer's first name. |
|
| 2185 | + * |
|
| 2186 | + * @since 1.0.19 |
|
| 2187 | + * @param string $value first name. |
|
| 2188 | + */ |
|
| 2189 | + public function set_first_name( $value ) { |
|
| 2190 | + $this->set_prop( 'first_name', $value ); |
|
| 2191 | + } |
|
| 2192 | + |
|
| 2193 | + /** |
|
| 2194 | + * Alias of self::set_first_name(). |
|
| 2195 | + * |
|
| 2196 | + * @since 1.0.19 |
|
| 2197 | + * @param string $value first name. |
|
| 2198 | + */ |
|
| 2199 | + public function set_user_first_name( $value ) { |
|
| 2200 | + $this->set_first_name( $value ); |
|
| 2201 | + } |
|
| 2202 | + |
|
| 2203 | + /** |
|
| 2204 | + * Alias of self::set_first_name(). |
|
| 2205 | + * |
|
| 2206 | + * @since 1.0.19 |
|
| 2207 | + * @param string $value first name. |
|
| 2208 | + */ |
|
| 2209 | + public function set_customer_first_name( $value ) { |
|
| 2210 | + $this->set_first_name( $value ); |
|
| 2211 | + } |
|
| 2212 | + |
|
| 2213 | + /** |
|
| 2214 | + * Set the customer's last name. |
|
| 2215 | + * |
|
| 2216 | + * @since 1.0.19 |
|
| 2217 | + * @param string $value last name. |
|
| 2218 | + */ |
|
| 2219 | + public function set_last_name( $value ) { |
|
| 2220 | + $this->set_prop( 'last_name', $value ); |
|
| 2191 | 2221 | } |
| 2192 | 2222 | |
| 2193 | 2223 | /** |
| 2194 | - * Alias of self::set_first_name(). |
|
| 2195 | - * |
|
| 2196 | - * @since 1.0.19 |
|
| 2197 | - * @param string $value first name. |
|
| 2198 | - */ |
|
| 2199 | - public function set_user_first_name( $value ) { |
|
| 2200 | - $this->set_first_name( $value ); |
|
| 2224 | + * Alias of self::set_last_name(). |
|
| 2225 | + * |
|
| 2226 | + * @since 1.0.19 |
|
| 2227 | + * @param string $value last name. |
|
| 2228 | + */ |
|
| 2229 | + public function set_user_last_name( $value ) { |
|
| 2230 | + $this->set_last_name( $value ); |
|
| 2201 | 2231 | } |
| 2202 | 2232 | |
| 2203 | 2233 | /** |
| 2204 | - * Alias of self::set_first_name(). |
|
| 2205 | - * |
|
| 2206 | - * @since 1.0.19 |
|
| 2207 | - * @param string $value first name. |
|
| 2208 | - */ |
|
| 2209 | - public function set_customer_first_name( $value ) { |
|
| 2210 | - $this->set_first_name( $value ); |
|
| 2234 | + * Alias of self::set_last_name(). |
|
| 2235 | + * |
|
| 2236 | + * @since 1.0.19 |
|
| 2237 | + * @param string $value last name. |
|
| 2238 | + */ |
|
| 2239 | + public function set_customer_last_name( $value ) { |
|
| 2240 | + $this->set_last_name( $value ); |
|
| 2211 | 2241 | } |
| 2212 | 2242 | |
| 2213 | 2243 | /** |
| 2214 | - * Set the customer's last name. |
|
| 2215 | - * |
|
| 2216 | - * @since 1.0.19 |
|
| 2217 | - * @param string $value last name. |
|
| 2218 | - */ |
|
| 2219 | - public function set_last_name( $value ) { |
|
| 2220 | - $this->set_prop( 'last_name', $value ); |
|
| 2244 | + * Set the customer's phone number. |
|
| 2245 | + * |
|
| 2246 | + * @since 1.0.19 |
|
| 2247 | + * @param string $value phone. |
|
| 2248 | + */ |
|
| 2249 | + public function set_phone( $value ) { |
|
| 2250 | + $this->set_prop( 'phone', $value ); |
|
| 2221 | 2251 | } |
| 2222 | 2252 | |
| 2223 | 2253 | /** |
| 2224 | - * Alias of self::set_last_name(). |
|
| 2225 | - * |
|
| 2226 | - * @since 1.0.19 |
|
| 2227 | - * @param string $value last name. |
|
| 2228 | - */ |
|
| 2229 | - public function set_user_last_name( $value ) { |
|
| 2230 | - $this->set_last_name( $value ); |
|
| 2254 | + * Alias of self::set_phone(). |
|
| 2255 | + * |
|
| 2256 | + * @since 1.0.19 |
|
| 2257 | + * @param string $value phone. |
|
| 2258 | + */ |
|
| 2259 | + public function set_user_phone( $value ) { |
|
| 2260 | + $this->set_phone( $value ); |
|
| 2231 | 2261 | } |
| 2232 | 2262 | |
| 2233 | 2263 | /** |
| 2234 | - * Alias of self::set_last_name(). |
|
| 2235 | - * |
|
| 2236 | - * @since 1.0.19 |
|
| 2237 | - * @param string $value last name. |
|
| 2238 | - */ |
|
| 2239 | - public function set_customer_last_name( $value ) { |
|
| 2240 | - $this->set_last_name( $value ); |
|
| 2264 | + * Alias of self::set_phone(). |
|
| 2265 | + * |
|
| 2266 | + * @since 1.0.19 |
|
| 2267 | + * @param string $value phone. |
|
| 2268 | + */ |
|
| 2269 | + public function set_customer_phone( $value ) { |
|
| 2270 | + $this->set_phone( $value ); |
|
| 2241 | 2271 | } |
| 2242 | 2272 | |
| 2243 | 2273 | /** |
| 2244 | - * Set the customer's phone number. |
|
| 2245 | - * |
|
| 2246 | - * @since 1.0.19 |
|
| 2247 | - * @param string $value phone. |
|
| 2248 | - */ |
|
| 2249 | - public function set_phone( $value ) { |
|
| 2250 | - $this->set_prop( 'phone', $value ); |
|
| 2274 | + * Alias of self::set_phone(). |
|
| 2275 | + * |
|
| 2276 | + * @since 1.0.19 |
|
| 2277 | + * @param string $value phone. |
|
| 2278 | + */ |
|
| 2279 | + public function set_phone_number( $value ) { |
|
| 2280 | + $this->set_phone( $value ); |
|
| 2251 | 2281 | } |
| 2252 | 2282 | |
| 2253 | 2283 | /** |
| 2254 | - * Alias of self::set_phone(). |
|
| 2255 | - * |
|
| 2256 | - * @since 1.0.19 |
|
| 2257 | - * @param string $value phone. |
|
| 2258 | - */ |
|
| 2259 | - public function set_user_phone( $value ) { |
|
| 2260 | - $this->set_phone( $value ); |
|
| 2284 | + * Set the customer's email address. |
|
| 2285 | + * |
|
| 2286 | + * @since 1.0.19 |
|
| 2287 | + * @param string $value email address. |
|
| 2288 | + */ |
|
| 2289 | + public function set_email( $value ) { |
|
| 2290 | + $this->set_prop( 'email', $value ); |
|
| 2261 | 2291 | } |
| 2262 | 2292 | |
| 2263 | 2293 | /** |
| 2264 | - * Alias of self::set_phone(). |
|
| 2265 | - * |
|
| 2266 | - * @since 1.0.19 |
|
| 2267 | - * @param string $value phone. |
|
| 2268 | - */ |
|
| 2269 | - public function set_customer_phone( $value ) { |
|
| 2270 | - $this->set_phone( $value ); |
|
| 2294 | + * Alias of self::set_email(). |
|
| 2295 | + * |
|
| 2296 | + * @since 1.0.19 |
|
| 2297 | + * @param string $value email address. |
|
| 2298 | + */ |
|
| 2299 | + public function set_user_email( $value ) { |
|
| 2300 | + $this->set_email( $value ); |
|
| 2271 | 2301 | } |
| 2272 | 2302 | |
| 2273 | 2303 | /** |
| 2274 | - * Alias of self::set_phone(). |
|
| 2275 | - * |
|
| 2276 | - * @since 1.0.19 |
|
| 2277 | - * @param string $value phone. |
|
| 2278 | - */ |
|
| 2279 | - public function set_phone_number( $value ) { |
|
| 2280 | - $this->set_phone( $value ); |
|
| 2304 | + * Alias of self::set_email(). |
|
| 2305 | + * |
|
| 2306 | + * @since 1.0.19 |
|
| 2307 | + * @param string $value email address. |
|
| 2308 | + */ |
|
| 2309 | + public function set_email_address( $value ) { |
|
| 2310 | + $this->set_email( $value ); |
|
| 2281 | 2311 | } |
| 2282 | 2312 | |
| 2283 | 2313 | /** |
| 2284 | - * Set the customer's email address. |
|
| 2285 | - * |
|
| 2286 | - * @since 1.0.19 |
|
| 2287 | - * @param string $value email address. |
|
| 2288 | - */ |
|
| 2289 | - public function set_email( $value ) { |
|
| 2290 | - $this->set_prop( 'email', $value ); |
|
| 2314 | + * Alias of self::set_email(). |
|
| 2315 | + * |
|
| 2316 | + * @since 1.0.19 |
|
| 2317 | + * @param string $value email address. |
|
| 2318 | + */ |
|
| 2319 | + public function set_customer_email( $value ) { |
|
| 2320 | + $this->set_email( $value ); |
|
| 2291 | 2321 | } |
| 2292 | 2322 | |
| 2293 | 2323 | /** |
| 2294 | - * Alias of self::set_email(). |
|
| 2295 | - * |
|
| 2296 | - * @since 1.0.19 |
|
| 2297 | - * @param string $value email address. |
|
| 2298 | - */ |
|
| 2299 | - public function set_user_email( $value ) { |
|
| 2300 | - $this->set_email( $value ); |
|
| 2324 | + * Set the customer's country. |
|
| 2325 | + * |
|
| 2326 | + * @since 1.0.19 |
|
| 2327 | + * @param string $value country. |
|
| 2328 | + */ |
|
| 2329 | + public function set_country( $value ) { |
|
| 2330 | + $this->set_prop( 'country', $value ); |
|
| 2301 | 2331 | } |
| 2302 | 2332 | |
| 2303 | 2333 | /** |
| 2304 | - * Alias of self::set_email(). |
|
| 2305 | - * |
|
| 2306 | - * @since 1.0.19 |
|
| 2307 | - * @param string $value email address. |
|
| 2308 | - */ |
|
| 2309 | - public function set_email_address( $value ) { |
|
| 2310 | - $this->set_email( $value ); |
|
| 2334 | + * Alias of self::set_country(). |
|
| 2335 | + * |
|
| 2336 | + * @since 1.0.19 |
|
| 2337 | + * @param string $value country. |
|
| 2338 | + */ |
|
| 2339 | + public function set_user_country( $value ) { |
|
| 2340 | + $this->set_country( $value ); |
|
| 2311 | 2341 | } |
| 2312 | 2342 | |
| 2313 | 2343 | /** |
| 2314 | - * Alias of self::set_email(). |
|
| 2315 | - * |
|
| 2316 | - * @since 1.0.19 |
|
| 2317 | - * @param string $value email address. |
|
| 2318 | - */ |
|
| 2319 | - public function set_customer_email( $value ) { |
|
| 2320 | - $this->set_email( $value ); |
|
| 2344 | + * Alias of self::set_country(). |
|
| 2345 | + * |
|
| 2346 | + * @since 1.0.19 |
|
| 2347 | + * @param string $value country. |
|
| 2348 | + */ |
|
| 2349 | + public function set_customer_country( $value ) { |
|
| 2350 | + $this->set_country( $value ); |
|
| 2321 | 2351 | } |
| 2322 | 2352 | |
| 2323 | 2353 | /** |
| 2324 | - * Set the customer's country. |
|
| 2325 | - * |
|
| 2326 | - * @since 1.0.19 |
|
| 2327 | - * @param string $value country. |
|
| 2328 | - */ |
|
| 2329 | - public function set_country( $value ) { |
|
| 2330 | - $this->set_prop( 'country', $value ); |
|
| 2354 | + * Set the customer's state. |
|
| 2355 | + * |
|
| 2356 | + * @since 1.0.19 |
|
| 2357 | + * @param string $value state. |
|
| 2358 | + */ |
|
| 2359 | + public function set_state( $value ) { |
|
| 2360 | + $this->set_prop( 'state', $value ); |
|
| 2331 | 2361 | } |
| 2332 | 2362 | |
| 2333 | 2363 | /** |
| 2334 | - * Alias of self::set_country(). |
|
| 2335 | - * |
|
| 2336 | - * @since 1.0.19 |
|
| 2337 | - * @param string $value country. |
|
| 2338 | - */ |
|
| 2339 | - public function set_user_country( $value ) { |
|
| 2340 | - $this->set_country( $value ); |
|
| 2364 | + * Alias of self::set_state(). |
|
| 2365 | + * |
|
| 2366 | + * @since 1.0.19 |
|
| 2367 | + * @param string $value state. |
|
| 2368 | + */ |
|
| 2369 | + public function set_user_state( $value ) { |
|
| 2370 | + $this->set_state( $value ); |
|
| 2341 | 2371 | } |
| 2342 | 2372 | |
| 2343 | 2373 | /** |
| 2344 | - * Alias of self::set_country(). |
|
| 2345 | - * |
|
| 2346 | - * @since 1.0.19 |
|
| 2347 | - * @param string $value country. |
|
| 2348 | - */ |
|
| 2349 | - public function set_customer_country( $value ) { |
|
| 2350 | - $this->set_country( $value ); |
|
| 2374 | + * Alias of self::set_state(). |
|
| 2375 | + * |
|
| 2376 | + * @since 1.0.19 |
|
| 2377 | + * @param string $value state. |
|
| 2378 | + */ |
|
| 2379 | + public function set_customer_state( $value ) { |
|
| 2380 | + $this->set_state( $value ); |
|
| 2351 | 2381 | } |
| 2352 | 2382 | |
| 2353 | 2383 | /** |
| 2354 | - * Set the customer's state. |
|
| 2355 | - * |
|
| 2356 | - * @since 1.0.19 |
|
| 2357 | - * @param string $value state. |
|
| 2358 | - */ |
|
| 2359 | - public function set_state( $value ) { |
|
| 2360 | - $this->set_prop( 'state', $value ); |
|
| 2384 | + * Set the customer's city. |
|
| 2385 | + * |
|
| 2386 | + * @since 1.0.19 |
|
| 2387 | + * @param string $value city. |
|
| 2388 | + */ |
|
| 2389 | + public function set_city( $value ) { |
|
| 2390 | + $this->set_prop( 'city', $value ); |
|
| 2361 | 2391 | } |
| 2362 | 2392 | |
| 2363 | 2393 | /** |
| 2364 | - * Alias of self::set_state(). |
|
| 2365 | - * |
|
| 2366 | - * @since 1.0.19 |
|
| 2367 | - * @param string $value state. |
|
| 2368 | - */ |
|
| 2369 | - public function set_user_state( $value ) { |
|
| 2370 | - $this->set_state( $value ); |
|
| 2394 | + * Alias of self::set_city(). |
|
| 2395 | + * |
|
| 2396 | + * @since 1.0.19 |
|
| 2397 | + * @param string $value city. |
|
| 2398 | + */ |
|
| 2399 | + public function set_user_city( $value ) { |
|
| 2400 | + $this->set_city( $value ); |
|
| 2371 | 2401 | } |
| 2372 | 2402 | |
| 2373 | 2403 | /** |
| 2374 | - * Alias of self::set_state(). |
|
| 2375 | - * |
|
| 2376 | - * @since 1.0.19 |
|
| 2377 | - * @param string $value state. |
|
| 2378 | - */ |
|
| 2379 | - public function set_customer_state( $value ) { |
|
| 2380 | - $this->set_state( $value ); |
|
| 2404 | + * Alias of self::set_city(). |
|
| 2405 | + * |
|
| 2406 | + * @since 1.0.19 |
|
| 2407 | + * @param string $value city. |
|
| 2408 | + */ |
|
| 2409 | + public function set_customer_city( $value ) { |
|
| 2410 | + $this->set_city( $value ); |
|
| 2381 | 2411 | } |
| 2382 | 2412 | |
| 2383 | 2413 | /** |
| 2384 | - * Set the customer's city. |
|
| 2385 | - * |
|
| 2386 | - * @since 1.0.19 |
|
| 2387 | - * @param string $value city. |
|
| 2388 | - */ |
|
| 2389 | - public function set_city( $value ) { |
|
| 2390 | - $this->set_prop( 'city', $value ); |
|
| 2414 | + * Set the customer's zip code. |
|
| 2415 | + * |
|
| 2416 | + * @since 1.0.19 |
|
| 2417 | + * @param string $value zip. |
|
| 2418 | + */ |
|
| 2419 | + public function set_zip( $value ) { |
|
| 2420 | + $this->set_prop( 'zip', $value ); |
|
| 2391 | 2421 | } |
| 2392 | 2422 | |
| 2393 | 2423 | /** |
| 2394 | - * Alias of self::set_city(). |
|
| 2395 | - * |
|
| 2396 | - * @since 1.0.19 |
|
| 2397 | - * @param string $value city. |
|
| 2398 | - */ |
|
| 2399 | - public function set_user_city( $value ) { |
|
| 2400 | - $this->set_city( $value ); |
|
| 2424 | + * Alias of self::set_zip(). |
|
| 2425 | + * |
|
| 2426 | + * @since 1.0.19 |
|
| 2427 | + * @param string $value zip. |
|
| 2428 | + */ |
|
| 2429 | + public function set_user_zip( $value ) { |
|
| 2430 | + $this->set_zip( $value ); |
|
| 2401 | 2431 | } |
| 2402 | 2432 | |
| 2403 | 2433 | /** |
| 2404 | - * Alias of self::set_city(). |
|
| 2405 | - * |
|
| 2406 | - * @since 1.0.19 |
|
| 2407 | - * @param string $value city. |
|
| 2408 | - */ |
|
| 2409 | - public function set_customer_city( $value ) { |
|
| 2410 | - $this->set_city( $value ); |
|
| 2434 | + * Alias of self::set_zip(). |
|
| 2435 | + * |
|
| 2436 | + * @since 1.0.19 |
|
| 2437 | + * @param string $value zip. |
|
| 2438 | + */ |
|
| 2439 | + public function set_customer_zip( $value ) { |
|
| 2440 | + $this->set_zip( $value ); |
|
| 2411 | 2441 | } |
| 2412 | 2442 | |
| 2413 | 2443 | /** |
| 2414 | - * Set the customer's zip code. |
|
| 2415 | - * |
|
| 2416 | - * @since 1.0.19 |
|
| 2417 | - * @param string $value zip. |
|
| 2418 | - */ |
|
| 2419 | - public function set_zip( $value ) { |
|
| 2420 | - $this->set_prop( 'zip', $value ); |
|
| 2444 | + * Set the customer's company. |
|
| 2445 | + * |
|
| 2446 | + * @since 1.0.19 |
|
| 2447 | + * @param string $value company. |
|
| 2448 | + */ |
|
| 2449 | + public function set_company( $value ) { |
|
| 2450 | + $this->set_prop( 'company', $value ); |
|
| 2421 | 2451 | } |
| 2422 | 2452 | |
| 2423 | 2453 | /** |
| 2424 | - * Alias of self::set_zip(). |
|
| 2425 | - * |
|
| 2426 | - * @since 1.0.19 |
|
| 2427 | - * @param string $value zip. |
|
| 2428 | - */ |
|
| 2429 | - public function set_user_zip( $value ) { |
|
| 2430 | - $this->set_zip( $value ); |
|
| 2454 | + * Alias of self::set_company(). |
|
| 2455 | + * |
|
| 2456 | + * @since 1.0.19 |
|
| 2457 | + * @param string $value company. |
|
| 2458 | + */ |
|
| 2459 | + public function set_user_company( $value ) { |
|
| 2460 | + $this->set_company( $value ); |
|
| 2431 | 2461 | } |
| 2432 | 2462 | |
| 2433 | 2463 | /** |
| 2434 | - * Alias of self::set_zip(). |
|
| 2435 | - * |
|
| 2436 | - * @since 1.0.19 |
|
| 2437 | - * @param string $value zip. |
|
| 2438 | - */ |
|
| 2439 | - public function set_customer_zip( $value ) { |
|
| 2440 | - $this->set_zip( $value ); |
|
| 2464 | + * Alias of self::set_company(). |
|
| 2465 | + * |
|
| 2466 | + * @since 1.0.19 |
|
| 2467 | + * @param string $value company. |
|
| 2468 | + */ |
|
| 2469 | + public function set_customer_company( $value ) { |
|
| 2470 | + $this->set_company( $value ); |
|
| 2441 | 2471 | } |
| 2442 | 2472 | |
| 2443 | 2473 | /** |
| 2444 | - * Set the customer's company. |
|
| 2445 | - * |
|
| 2446 | - * @since 1.0.19 |
|
| 2447 | - * @param string $value company. |
|
| 2448 | - */ |
|
| 2449 | - public function set_company( $value ) { |
|
| 2450 | - $this->set_prop( 'company', $value ); |
|
| 2474 | + * Set the customer's var number. |
|
| 2475 | + * |
|
| 2476 | + * @since 1.0.19 |
|
| 2477 | + * @param string $value var number. |
|
| 2478 | + */ |
|
| 2479 | + public function set_vat_number( $value ) { |
|
| 2480 | + $this->set_prop( 'vat_number', $value ); |
|
| 2451 | 2481 | } |
| 2452 | 2482 | |
| 2453 | 2483 | /** |
| 2454 | - * Alias of self::set_company(). |
|
| 2455 | - * |
|
| 2456 | - * @since 1.0.19 |
|
| 2457 | - * @param string $value company. |
|
| 2458 | - */ |
|
| 2459 | - public function set_user_company( $value ) { |
|
| 2460 | - $this->set_company( $value ); |
|
| 2484 | + * Alias of self::set_vat_number(). |
|
| 2485 | + * |
|
| 2486 | + * @since 1.0.19 |
|
| 2487 | + * @param string $value var number. |
|
| 2488 | + */ |
|
| 2489 | + public function set_user_vat_number( $value ) { |
|
| 2490 | + $this->set_vat_number( $value ); |
|
| 2461 | 2491 | } |
| 2462 | 2492 | |
| 2463 | 2493 | /** |
| 2464 | - * Alias of self::set_company(). |
|
| 2465 | - * |
|
| 2466 | - * @since 1.0.19 |
|
| 2467 | - * @param string $value company. |
|
| 2468 | - */ |
|
| 2469 | - public function set_customer_company( $value ) { |
|
| 2470 | - $this->set_company( $value ); |
|
| 2494 | + * Alias of self::set_vat_number(). |
|
| 2495 | + * |
|
| 2496 | + * @since 1.0.19 |
|
| 2497 | + * @param string $value var number. |
|
| 2498 | + */ |
|
| 2499 | + public function set_customer_vat_number( $value ) { |
|
| 2500 | + $this->set_vat_number( $value ); |
|
| 2471 | 2501 | } |
| 2472 | 2502 | |
| 2473 | 2503 | /** |
| 2474 | - * Set the customer's var number. |
|
| 2475 | - * |
|
| 2476 | - * @since 1.0.19 |
|
| 2477 | - * @param string $value var number. |
|
| 2478 | - */ |
|
| 2479 | - public function set_vat_number( $value ) { |
|
| 2480 | - $this->set_prop( 'vat_number', $value ); |
|
| 2504 | + * Set the customer's vat rate. |
|
| 2505 | + * |
|
| 2506 | + * @since 1.0.19 |
|
| 2507 | + * @param string $value var rate. |
|
| 2508 | + */ |
|
| 2509 | + public function set_vat_rate( $value ) { |
|
| 2510 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2481 | 2511 | } |
| 2482 | 2512 | |
| 2483 | 2513 | /** |
| 2484 | - * Alias of self::set_vat_number(). |
|
| 2485 | - * |
|
| 2486 | - * @since 1.0.19 |
|
| 2487 | - * @param string $value var number. |
|
| 2488 | - */ |
|
| 2489 | - public function set_user_vat_number( $value ) { |
|
| 2490 | - $this->set_vat_number( $value ); |
|
| 2514 | + * Alias of self::set_vat_rate(). |
|
| 2515 | + * |
|
| 2516 | + * @since 1.0.19 |
|
| 2517 | + * @param string $value var number. |
|
| 2518 | + */ |
|
| 2519 | + public function set_user_vat_rate( $value ) { |
|
| 2520 | + $this->set_vat_rate( $value ); |
|
| 2491 | 2521 | } |
| 2492 | 2522 | |
| 2493 | 2523 | /** |
| 2494 | - * Alias of self::set_vat_number(). |
|
| 2495 | - * |
|
| 2496 | - * @since 1.0.19 |
|
| 2497 | - * @param string $value var number. |
|
| 2498 | - */ |
|
| 2499 | - public function set_customer_vat_number( $value ) { |
|
| 2500 | - $this->set_vat_number( $value ); |
|
| 2524 | + * Alias of self::set_vat_rate(). |
|
| 2525 | + * |
|
| 2526 | + * @since 1.0.19 |
|
| 2527 | + * @param string $value var number. |
|
| 2528 | + */ |
|
| 2529 | + public function set_customer_vat_rate( $value ) { |
|
| 2530 | + $this->set_vat_rate( $value ); |
|
| 2501 | 2531 | } |
| 2502 | 2532 | |
| 2503 | 2533 | /** |
| 2504 | - * Set the customer's vat rate. |
|
| 2505 | - * |
|
| 2506 | - * @since 1.0.19 |
|
| 2507 | - * @param string $value var rate. |
|
| 2508 | - */ |
|
| 2509 | - public function set_vat_rate( $value ) { |
|
| 2510 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2534 | + * Set the customer's address. |
|
| 2535 | + * |
|
| 2536 | + * @since 1.0.19 |
|
| 2537 | + * @param string $value address. |
|
| 2538 | + */ |
|
| 2539 | + public function set_address( $value ) { |
|
| 2540 | + $this->set_prop( 'address', $value ); |
|
| 2511 | 2541 | } |
| 2512 | 2542 | |
| 2513 | 2543 | /** |
| 2514 | - * Alias of self::set_vat_rate(). |
|
| 2515 | - * |
|
| 2516 | - * @since 1.0.19 |
|
| 2517 | - * @param string $value var number. |
|
| 2518 | - */ |
|
| 2519 | - public function set_user_vat_rate( $value ) { |
|
| 2520 | - $this->set_vat_rate( $value ); |
|
| 2544 | + * Alias of self::set_address(). |
|
| 2545 | + * |
|
| 2546 | + * @since 1.0.19 |
|
| 2547 | + * @param string $value address. |
|
| 2548 | + */ |
|
| 2549 | + public function set_user_address( $value ) { |
|
| 2550 | + $this->set_address( $value ); |
|
| 2521 | 2551 | } |
| 2522 | 2552 | |
| 2523 | 2553 | /** |
| 2524 | - * Alias of self::set_vat_rate(). |
|
| 2525 | - * |
|
| 2526 | - * @since 1.0.19 |
|
| 2527 | - * @param string $value var number. |
|
| 2528 | - */ |
|
| 2529 | - public function set_customer_vat_rate( $value ) { |
|
| 2530 | - $this->set_vat_rate( $value ); |
|
| 2554 | + * Alias of self::set_address(). |
|
| 2555 | + * |
|
| 2556 | + * @since 1.0.19 |
|
| 2557 | + * @param string $value address. |
|
| 2558 | + */ |
|
| 2559 | + public function set_customer_address( $value ) { |
|
| 2560 | + $this->set_address( $value ); |
|
| 2531 | 2561 | } |
| 2532 | 2562 | |
| 2533 | 2563 | /** |
| 2534 | - * Set the customer's address. |
|
| 2535 | - * |
|
| 2536 | - * @since 1.0.19 |
|
| 2537 | - * @param string $value address. |
|
| 2538 | - */ |
|
| 2539 | - public function set_address( $value ) { |
|
| 2540 | - $this->set_prop( 'address', $value ); |
|
| 2564 | + * Set whether the customer has viewed the invoice or not. |
|
| 2565 | + * |
|
| 2566 | + * @since 1.0.19 |
|
| 2567 | + * @param int|bool $value confirmed. |
|
| 2568 | + */ |
|
| 2569 | + public function set_is_viewed( $value ) { |
|
| 2570 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2541 | 2571 | } |
| 2542 | 2572 | |
| 2543 | 2573 | /** |
| 2544 | - * Alias of self::set_address(). |
|
| 2545 | - * |
|
| 2546 | - * @since 1.0.19 |
|
| 2547 | - * @param string $value address. |
|
| 2548 | - */ |
|
| 2549 | - public function set_user_address( $value ) { |
|
| 2550 | - $this->set_address( $value ); |
|
| 2574 | + * Set extra email recipients. |
|
| 2575 | + * |
|
| 2576 | + * @since 1.0.19 |
|
| 2577 | + * @param string $value email recipients. |
|
| 2578 | + */ |
|
| 2579 | + public function set_email_cc( $value ) { |
|
| 2580 | + $this->set_prop( 'email_cc', $value ); |
|
| 2551 | 2581 | } |
| 2552 | 2582 | |
| 2553 | 2583 | /** |
| 2554 | - * Alias of self::set_address(). |
|
| 2555 | - * |
|
| 2556 | - * @since 1.0.19 |
|
| 2557 | - * @param string $value address. |
|
| 2558 | - */ |
|
| 2559 | - public function set_customer_address( $value ) { |
|
| 2560 | - $this->set_address( $value ); |
|
| 2584 | + * Set the invoice template. |
|
| 2585 | + * |
|
| 2586 | + * @since 1.0.19 |
|
| 2587 | + * @param string $value email recipients. |
|
| 2588 | + */ |
|
| 2589 | + public function set_template( $value ) { |
|
| 2590 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2591 | + $this->set_prop( 'template', $value ); |
|
| 2592 | + } |
|
| 2561 | 2593 | } |
| 2562 | 2594 | |
| 2563 | 2595 | /** |
| 2564 | - * Set whether the customer has viewed the invoice or not. |
|
| 2565 | - * |
|
| 2566 | - * @since 1.0.19 |
|
| 2567 | - * @param int|bool $value confirmed. |
|
| 2568 | - */ |
|
| 2569 | - public function set_is_viewed( $value ) { |
|
| 2570 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2571 | - } |
|
| 2572 | - |
|
| 2573 | - /** |
|
| 2574 | - * Set extra email recipients. |
|
| 2575 | - * |
|
| 2576 | - * @since 1.0.19 |
|
| 2577 | - * @param string $value email recipients. |
|
| 2578 | - */ |
|
| 2579 | - public function set_email_cc( $value ) { |
|
| 2580 | - $this->set_prop( 'email_cc', $value ); |
|
| 2581 | - } |
|
| 2582 | - |
|
| 2583 | - /** |
|
| 2584 | - * Set the invoice template. |
|
| 2585 | - * |
|
| 2586 | - * @since 1.0.19 |
|
| 2587 | - * @param string $value email recipients. |
|
| 2588 | - */ |
|
| 2589 | - public function set_template( $value ) { |
|
| 2590 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2591 | - $this->set_prop( 'template', $value ); |
|
| 2592 | - } |
|
| 2593 | - } |
|
| 2594 | - |
|
| 2595 | - /** |
|
| 2596 | - * Set the customer's address confirmed status. |
|
| 2597 | - * |
|
| 2598 | - * @since 1.0.19 |
|
| 2599 | - * @param int|bool $value confirmed. |
|
| 2600 | - */ |
|
| 2601 | - public function set_address_confirmed( $value ) { |
|
| 2602 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2596 | + * Set the customer's address confirmed status. |
|
| 2597 | + * |
|
| 2598 | + * @since 1.0.19 |
|
| 2599 | + * @param int|bool $value confirmed. |
|
| 2600 | + */ |
|
| 2601 | + public function set_address_confirmed( $value ) { |
|
| 2602 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2603 | 2603 | } |
| 2604 | 2604 | |
| 2605 | 2605 | /** |
| 2606 | - * Alias of self::set_address_confirmed(). |
|
| 2607 | - * |
|
| 2608 | - * @since 1.0.19 |
|
| 2609 | - * @param int|bool $value confirmed. |
|
| 2610 | - */ |
|
| 2611 | - public function set_user_address_confirmed( $value ) { |
|
| 2612 | - $this->set_address_confirmed( $value ); |
|
| 2606 | + * Alias of self::set_address_confirmed(). |
|
| 2607 | + * |
|
| 2608 | + * @since 1.0.19 |
|
| 2609 | + * @param int|bool $value confirmed. |
|
| 2610 | + */ |
|
| 2611 | + public function set_user_address_confirmed( $value ) { |
|
| 2612 | + $this->set_address_confirmed( $value ); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | |
| 2615 | 2615 | /** |
| 2616 | - * Alias of self::set_address_confirmed(). |
|
| 2617 | - * |
|
| 2618 | - * @since 1.0.19 |
|
| 2619 | - * @param int|bool $value confirmed. |
|
| 2620 | - */ |
|
| 2621 | - public function set_customer_address_confirmed( $value ) { |
|
| 2622 | - $this->set_address_confirmed( $value ); |
|
| 2616 | + * Alias of self::set_address_confirmed(). |
|
| 2617 | + * |
|
| 2618 | + * @since 1.0.19 |
|
| 2619 | + * @param int|bool $value confirmed. |
|
| 2620 | + */ |
|
| 2621 | + public function set_customer_address_confirmed( $value ) { |
|
| 2622 | + $this->set_address_confirmed( $value ); |
|
| 2623 | 2623 | } |
| 2624 | 2624 | |
| 2625 | 2625 | /** |
| 2626 | - * Set the invoice sub total. |
|
| 2627 | - * |
|
| 2628 | - * @since 1.0.19 |
|
| 2629 | - * @param float $value sub total. |
|
| 2630 | - */ |
|
| 2631 | - public function set_subtotal( $value ) { |
|
| 2632 | - $this->set_prop( 'subtotal', $value ); |
|
| 2626 | + * Set the invoice sub total. |
|
| 2627 | + * |
|
| 2628 | + * @since 1.0.19 |
|
| 2629 | + * @param float $value sub total. |
|
| 2630 | + */ |
|
| 2631 | + public function set_subtotal( $value ) { |
|
| 2632 | + $this->set_prop( 'subtotal', $value ); |
|
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | 2635 | /** |
| 2636 | - * Set the invoice discount amount. |
|
| 2637 | - * |
|
| 2638 | - * @since 1.0.19 |
|
| 2639 | - * @param float $value discount total. |
|
| 2640 | - */ |
|
| 2641 | - public function set_total_discount( $value ) { |
|
| 2642 | - $this->set_prop( 'total_discount', $value ); |
|
| 2636 | + * Set the invoice discount amount. |
|
| 2637 | + * |
|
| 2638 | + * @since 1.0.19 |
|
| 2639 | + * @param float $value discount total. |
|
| 2640 | + */ |
|
| 2641 | + public function set_total_discount( $value ) { |
|
| 2642 | + $this->set_prop( 'total_discount', $value ); |
|
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | /** |
| 2646 | - * Alias of self::set_total_discount(). |
|
| 2647 | - * |
|
| 2648 | - * @since 1.0.19 |
|
| 2649 | - * @param float $value discount total. |
|
| 2650 | - */ |
|
| 2651 | - public function set_discount( $value ) { |
|
| 2652 | - $this->set_total_discount( $value ); |
|
| 2646 | + * Alias of self::set_total_discount(). |
|
| 2647 | + * |
|
| 2648 | + * @since 1.0.19 |
|
| 2649 | + * @param float $value discount total. |
|
| 2650 | + */ |
|
| 2651 | + public function set_discount( $value ) { |
|
| 2652 | + $this->set_total_discount( $value ); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | |
| 2655 | 2655 | /** |
| 2656 | - * Set the invoice tax amount. |
|
| 2657 | - * |
|
| 2658 | - * @since 1.0.19 |
|
| 2659 | - * @param float $value tax total. |
|
| 2660 | - */ |
|
| 2661 | - public function set_total_tax( $value ) { |
|
| 2662 | - $this->set_prop( 'total_tax', $value ); |
|
| 2656 | + * Set the invoice tax amount. |
|
| 2657 | + * |
|
| 2658 | + * @since 1.0.19 |
|
| 2659 | + * @param float $value tax total. |
|
| 2660 | + */ |
|
| 2661 | + public function set_total_tax( $value ) { |
|
| 2662 | + $this->set_prop( 'total_tax', $value ); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | /** |
| 2666 | - * Alias of self::set_total_tax(). |
|
| 2667 | - * |
|
| 2668 | - * @since 1.0.19 |
|
| 2669 | - * @param float $value tax total. |
|
| 2670 | - */ |
|
| 2671 | - public function set_tax_total( $value ) { |
|
| 2672 | - $this->set_total_tax( $value ); |
|
| 2666 | + * Alias of self::set_total_tax(). |
|
| 2667 | + * |
|
| 2668 | + * @since 1.0.19 |
|
| 2669 | + * @param float $value tax total. |
|
| 2670 | + */ |
|
| 2671 | + public function set_tax_total( $value ) { |
|
| 2672 | + $this->set_total_tax( $value ); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
| 2676 | - * Set the invoice fees amount. |
|
| 2677 | - * |
|
| 2678 | - * @since 1.0.19 |
|
| 2679 | - * @param float $value fees total. |
|
| 2680 | - */ |
|
| 2681 | - public function set_total_fees( $value ) { |
|
| 2682 | - $this->set_prop( 'total_fees', $value ); |
|
| 2676 | + * Set the invoice fees amount. |
|
| 2677 | + * |
|
| 2678 | + * @since 1.0.19 |
|
| 2679 | + * @param float $value fees total. |
|
| 2680 | + */ |
|
| 2681 | + public function set_total_fees( $value ) { |
|
| 2682 | + $this->set_prop( 'total_fees', $value ); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
| 2686 | - * Alias of self::set_total_fees(). |
|
| 2687 | - * |
|
| 2688 | - * @since 1.0.19 |
|
| 2689 | - * @param float $value fees total. |
|
| 2690 | - */ |
|
| 2691 | - public function set_fees_total( $value ) { |
|
| 2692 | - $this->set_total_fees( $value ); |
|
| 2686 | + * Alias of self::set_total_fees(). |
|
| 2687 | + * |
|
| 2688 | + * @since 1.0.19 |
|
| 2689 | + * @param float $value fees total. |
|
| 2690 | + */ |
|
| 2691 | + public function set_fees_total( $value ) { |
|
| 2692 | + $this->set_total_fees( $value ); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
| 2696 | - * Set the invoice fees. |
|
| 2697 | - * |
|
| 2698 | - * @since 1.0.19 |
|
| 2699 | - * @param array $value fees. |
|
| 2700 | - */ |
|
| 2701 | - public function set_fees( $value ) { |
|
| 2696 | + * Set the invoice fees. |
|
| 2697 | + * |
|
| 2698 | + * @since 1.0.19 |
|
| 2699 | + * @param array $value fees. |
|
| 2700 | + */ |
|
| 2701 | + public function set_fees( $value ) { |
|
| 2702 | 2702 | |
| 2703 | 2703 | $this->set_prop( 'fees', array() ); |
| 2704 | 2704 | |
@@ -2716,23 +2716,23 @@ discard block |
||
| 2716 | 2716 | } |
| 2717 | 2717 | |
| 2718 | 2718 | /** |
| 2719 | - * Set the invoice taxes. |
|
| 2720 | - * |
|
| 2721 | - * @since 1.0.19 |
|
| 2722 | - * @param array $value taxes. |
|
| 2723 | - */ |
|
| 2724 | - public function set_taxes( $value ) { |
|
| 2725 | - $this->set_prop( 'taxes', $value ); |
|
| 2719 | + * Set the invoice taxes. |
|
| 2720 | + * |
|
| 2721 | + * @since 1.0.19 |
|
| 2722 | + * @param array $value taxes. |
|
| 2723 | + */ |
|
| 2724 | + public function set_taxes( $value ) { |
|
| 2725 | + $this->set_prop( 'taxes', $value ); |
|
| 2726 | 2726 | } |
| 2727 | 2727 | |
| 2728 | 2728 | /** |
| 2729 | - * Set the invoice discounts. |
|
| 2730 | - * |
|
| 2731 | - * @since 1.0.19 |
|
| 2732 | - * @param array $value discounts. |
|
| 2733 | - */ |
|
| 2734 | - public function set_discounts( $value ) { |
|
| 2735 | - $this->set_prop( 'discounts', array() ); |
|
| 2729 | + * Set the invoice discounts. |
|
| 2730 | + * |
|
| 2731 | + * @since 1.0.19 |
|
| 2732 | + * @param array $value discounts. |
|
| 2733 | + */ |
|
| 2734 | + public function set_discounts( $value ) { |
|
| 2735 | + $this->set_prop( 'discounts', array() ); |
|
| 2736 | 2736 | |
| 2737 | 2737 | // Ensure that we have an array. |
| 2738 | 2738 | if ( ! is_array( $value ) ) { |
@@ -2747,12 +2747,12 @@ discard block |
||
| 2747 | 2747 | } |
| 2748 | 2748 | |
| 2749 | 2749 | /** |
| 2750 | - * Set the invoice items. |
|
| 2751 | - * |
|
| 2752 | - * @since 1.0.19 |
|
| 2753 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2754 | - */ |
|
| 2755 | - public function set_items( $value ) { |
|
| 2750 | + * Set the invoice items. |
|
| 2751 | + * |
|
| 2752 | + * @since 1.0.19 |
|
| 2753 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2754 | + */ |
|
| 2755 | + public function set_items( $value ) { |
|
| 2756 | 2756 | |
| 2757 | 2757 | // Remove existing items. |
| 2758 | 2758 | $this->set_prop( 'items', array() ); |
@@ -2769,83 +2769,83 @@ discard block |
||
| 2769 | 2769 | } |
| 2770 | 2770 | |
| 2771 | 2771 | /** |
| 2772 | - * Set the payment form. |
|
| 2773 | - * |
|
| 2774 | - * @since 1.0.19 |
|
| 2775 | - * @param int $value payment form. |
|
| 2776 | - */ |
|
| 2777 | - public function set_payment_form( $value ) { |
|
| 2778 | - $this->set_prop( 'payment_form', $value ); |
|
| 2772 | + * Set the payment form. |
|
| 2773 | + * |
|
| 2774 | + * @since 1.0.19 |
|
| 2775 | + * @param int $value payment form. |
|
| 2776 | + */ |
|
| 2777 | + public function set_payment_form( $value ) { |
|
| 2778 | + $this->set_prop( 'payment_form', $value ); |
|
| 2779 | 2779 | } |
| 2780 | 2780 | |
| 2781 | 2781 | /** |
| 2782 | - * Set the submission id. |
|
| 2783 | - * |
|
| 2784 | - * @since 1.0.19 |
|
| 2785 | - * @param string $value submission id. |
|
| 2786 | - */ |
|
| 2787 | - public function set_submission_id( $value ) { |
|
| 2788 | - $this->set_prop( 'submission_id', $value ); |
|
| 2782 | + * Set the submission id. |
|
| 2783 | + * |
|
| 2784 | + * @since 1.0.19 |
|
| 2785 | + * @param string $value submission id. |
|
| 2786 | + */ |
|
| 2787 | + public function set_submission_id( $value ) { |
|
| 2788 | + $this->set_prop( 'submission_id', $value ); |
|
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | 2791 | /** |
| 2792 | - * Set the discount code. |
|
| 2793 | - * |
|
| 2794 | - * @since 1.0.19 |
|
| 2795 | - * @param string $value discount code. |
|
| 2796 | - */ |
|
| 2797 | - public function set_discount_code( $value ) { |
|
| 2798 | - $this->set_prop( 'discount_code', $value ); |
|
| 2792 | + * Set the discount code. |
|
| 2793 | + * |
|
| 2794 | + * @since 1.0.19 |
|
| 2795 | + * @param string $value discount code. |
|
| 2796 | + */ |
|
| 2797 | + public function set_discount_code( $value ) { |
|
| 2798 | + $this->set_prop( 'discount_code', $value ); |
|
| 2799 | 2799 | } |
| 2800 | 2800 | |
| 2801 | 2801 | /** |
| 2802 | - * Set the gateway. |
|
| 2803 | - * |
|
| 2804 | - * @since 1.0.19 |
|
| 2805 | - * @param string $value gateway. |
|
| 2806 | - */ |
|
| 2807 | - public function set_gateway( $value ) { |
|
| 2808 | - $this->set_prop( 'gateway', $value ); |
|
| 2802 | + * Set the gateway. |
|
| 2803 | + * |
|
| 2804 | + * @since 1.0.19 |
|
| 2805 | + * @param string $value gateway. |
|
| 2806 | + */ |
|
| 2807 | + public function set_gateway( $value ) { |
|
| 2808 | + $this->set_prop( 'gateway', $value ); |
|
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | 2811 | /** |
| 2812 | - * Set the transaction id. |
|
| 2813 | - * |
|
| 2814 | - * @since 1.0.19 |
|
| 2815 | - * @param string $value transaction id. |
|
| 2816 | - */ |
|
| 2817 | - public function set_transaction_id( $value ) { |
|
| 2818 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2812 | + * Set the transaction id. |
|
| 2813 | + * |
|
| 2814 | + * @since 1.0.19 |
|
| 2815 | + * @param string $value transaction id. |
|
| 2816 | + */ |
|
| 2817 | + public function set_transaction_id( $value ) { |
|
| 2818 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2819 | 2819 | } |
| 2820 | 2820 | |
| 2821 | 2821 | /** |
| 2822 | - * Set the currency id. |
|
| 2823 | - * |
|
| 2824 | - * @since 1.0.19 |
|
| 2825 | - * @param string $value currency id. |
|
| 2826 | - */ |
|
| 2827 | - public function set_currency( $value ) { |
|
| 2828 | - $this->set_prop( 'currency', $value ); |
|
| 2822 | + * Set the currency id. |
|
| 2823 | + * |
|
| 2824 | + * @since 1.0.19 |
|
| 2825 | + * @param string $value currency id. |
|
| 2826 | + */ |
|
| 2827 | + public function set_currency( $value ) { |
|
| 2828 | + $this->set_prop( 'currency', $value ); |
|
| 2829 | 2829 | } |
| 2830 | 2830 | |
| 2831 | - /** |
|
| 2832 | - * Set whether to disable taxes. |
|
| 2833 | - * |
|
| 2834 | - * @since 1.0.19 |
|
| 2835 | - * @param bool $value value. |
|
| 2836 | - */ |
|
| 2837 | - public function set_disable_taxes( $value ) { |
|
| 2838 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2839 | - } |
|
| 2831 | + /** |
|
| 2832 | + * Set whether to disable taxes. |
|
| 2833 | + * |
|
| 2834 | + * @since 1.0.19 |
|
| 2835 | + * @param bool $value value. |
|
| 2836 | + */ |
|
| 2837 | + public function set_disable_taxes( $value ) { |
|
| 2838 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2839 | + } |
|
| 2840 | 2840 | |
| 2841 | 2841 | /** |
| 2842 | - * Set the subscription id. |
|
| 2843 | - * |
|
| 2844 | - * @since 1.0.19 |
|
| 2845 | - * @param string $value subscription id. |
|
| 2846 | - */ |
|
| 2847 | - public function set_subscription_id( $value ) { |
|
| 2848 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2842 | + * Set the subscription id. |
|
| 2843 | + * |
|
| 2844 | + * @since 1.0.19 |
|
| 2845 | + * @param string $value subscription id. |
|
| 2846 | + */ |
|
| 2847 | + public function set_subscription_id( $value ) { |
|
| 2848 | + $this->set_prop( 'subscription_id', $value ); |
|
| 2849 | 2849 | } |
| 2850 | 2850 | |
| 2851 | 2851 | /* |
@@ -2884,12 +2884,12 @@ discard block |
||
| 2884 | 2884 | */ |
| 2885 | 2885 | public function is_taxable() { |
| 2886 | 2886 | return ! $this->get_disable_taxes(); |
| 2887 | - } |
|
| 2887 | + } |
|
| 2888 | 2888 | |
| 2889 | - /** |
|
| 2890 | - * @deprecated |
|
| 2891 | - */ |
|
| 2892 | - public function has_vat() { |
|
| 2889 | + /** |
|
| 2890 | + * @deprecated |
|
| 2891 | + */ |
|
| 2892 | + public function has_vat() { |
|
| 2893 | 2893 | global $wpinv_euvat, $wpi_country; |
| 2894 | 2894 | |
| 2895 | 2895 | $requires_vat = false; |
@@ -2900,17 +2900,17 @@ discard block |
||
| 2900 | 2900 | } |
| 2901 | 2901 | |
| 2902 | 2902 | return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
| 2903 | - } |
|
| 2903 | + } |
|
| 2904 | 2904 | |
| 2905 | - /** |
|
| 2906 | - * Checks to see if the invoice requires payment. |
|
| 2907 | - */ |
|
| 2908 | - public function is_free() { |
|
| 2905 | + /** |
|
| 2906 | + * Checks to see if the invoice requires payment. |
|
| 2907 | + */ |
|
| 2908 | + public function is_free() { |
|
| 2909 | 2909 | $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
| 2910 | 2910 | |
| 2911 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2912 | - $is_free = false; |
|
| 2913 | - } |
|
| 2911 | + if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2912 | + $is_free = false; |
|
| 2913 | + } |
|
| 2914 | 2914 | |
| 2915 | 2915 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 2916 | 2916 | } |
@@ -2921,38 +2921,38 @@ discard block |
||
| 2921 | 2921 | public function is_paid() { |
| 2922 | 2922 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 2923 | 2923 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 2924 | - } |
|
| 2924 | + } |
|
| 2925 | 2925 | |
| 2926 | - /** |
|
| 2926 | + /** |
|
| 2927 | 2927 | * Checks if the invoice needs payment. |
| 2928 | 2928 | */ |
| 2929 | - public function needs_payment() { |
|
| 2930 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2929 | + public function needs_payment() { |
|
| 2930 | + $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2931 | 2931 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 2932 | 2932 | } |
| 2933 | 2933 | |
| 2934 | - /** |
|
| 2934 | + /** |
|
| 2935 | 2935 | * Checks if the invoice is refunded. |
| 2936 | 2936 | */ |
| 2937 | - public function is_refunded() { |
|
| 2937 | + public function is_refunded() { |
|
| 2938 | 2938 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 2939 | 2939 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 2940 | - } |
|
| 2940 | + } |
|
| 2941 | 2941 | |
| 2942 | - /** |
|
| 2942 | + /** |
|
| 2943 | 2943 | * Checks if the invoice is due. |
| 2944 | 2944 | */ |
| 2945 | - public function is_due() { |
|
| 2946 | - $due_date = $this->get_due_date(); |
|
| 2947 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 2948 | - } |
|
| 2945 | + public function is_due() { |
|
| 2946 | + $due_date = $this->get_due_date(); |
|
| 2947 | + return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 2948 | + } |
|
| 2949 | 2949 | |
| 2950 | - /** |
|
| 2950 | + /** |
|
| 2951 | 2951 | * Checks if the invoice is draft. |
| 2952 | 2952 | */ |
| 2953 | - public function is_draft() { |
|
| 2953 | + public function is_draft() { |
|
| 2954 | 2954 | return $this->has_status( 'draft, auto-draft' ); |
| 2955 | - } |
|
| 2955 | + } |
|
| 2956 | 2956 | |
| 2957 | 2957 | /** |
| 2958 | 2958 | * Checks if the invoice has a given status. |
@@ -2960,9 +2960,9 @@ discard block |
||
| 2960 | 2960 | public function has_status( $status ) { |
| 2961 | 2961 | $status = wpinv_parse_list( $status ); |
| 2962 | 2962 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 2963 | - } |
|
| 2963 | + } |
|
| 2964 | 2964 | |
| 2965 | - /** |
|
| 2965 | + /** |
|
| 2966 | 2966 | * Checks if the invoice is of a given type. |
| 2967 | 2967 | */ |
| 2968 | 2968 | public function is_type( $type ) { |
@@ -2985,25 +2985,25 @@ discard block |
||
| 2985 | 2985 | */ |
| 2986 | 2986 | public function has_free_trial() { |
| 2987 | 2987 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 2988 | - } |
|
| 2988 | + } |
|
| 2989 | 2989 | |
| 2990 | - /** |
|
| 2990 | + /** |
|
| 2991 | 2991 | * @deprecated |
| 2992 | 2992 | */ |
| 2993 | 2993 | public function is_free_trial() { |
| 2994 | 2994 | $this->has_free_trial(); |
| 2995 | 2995 | } |
| 2996 | 2996 | |
| 2997 | - /** |
|
| 2997 | + /** |
|
| 2998 | 2998 | * Check if the initial payment if 0. |
| 2999 | 2999 | * |
| 3000 | 3000 | */ |
| 3001 | - public function is_initial_free() { |
|
| 3001 | + public function is_initial_free() { |
|
| 3002 | 3002 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 3003 | 3003 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 3004 | 3004 | } |
| 3005 | 3005 | |
| 3006 | - /** |
|
| 3006 | + /** |
|
| 3007 | 3007 | * Check if the recurring item has a free trial. |
| 3008 | 3008 | * |
| 3009 | 3009 | */ |
@@ -3016,21 +3016,21 @@ discard block |
||
| 3016 | 3016 | |
| 3017 | 3017 | $item = $this->get_recurring( true ); |
| 3018 | 3018 | return $item->has_free_trial(); |
| 3019 | - } |
|
| 3019 | + } |
|
| 3020 | 3020 | |
| 3021 | - /** |
|
| 3021 | + /** |
|
| 3022 | 3022 | * Check if the free trial is a result of a discount. |
| 3023 | 3023 | */ |
| 3024 | 3024 | public function is_free_trial_from_discount() { |
| 3025 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3026 | - } |
|
| 3025 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3026 | + } |
|
| 3027 | 3027 | |
| 3028 | - /** |
|
| 3028 | + /** |
|
| 3029 | 3029 | * @deprecated |
| 3030 | 3030 | */ |
| 3031 | 3031 | public function discount_first_payment_only() { |
| 3032 | 3032 | |
| 3033 | - $discount_code = $this->get_discount_code(); |
|
| 3033 | + $discount_code = $this->get_discount_code(); |
|
| 3034 | 3034 | if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
| 3035 | 3035 | return true; |
| 3036 | 3036 | } |
@@ -3062,19 +3062,19 @@ discard block |
||
| 3062 | 3062 | public function add_item( $item ) { |
| 3063 | 3063 | |
| 3064 | 3064 | // Make sure that it is available for purchase. |
| 3065 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3066 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3065 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3066 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3067 | 3067 | } |
| 3068 | 3068 | |
| 3069 | 3069 | // Do we have a recurring item? |
| 3070 | - if ( $item->is_recurring() ) { |
|
| 3070 | + if ( $item->is_recurring() ) { |
|
| 3071 | 3071 | |
| 3072 | - // An invoice can only contain one recurring item. |
|
| 3073 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3074 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3075 | - } |
|
| 3072 | + // An invoice can only contain one recurring item. |
|
| 3073 | + if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3074 | + return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3075 | + } |
|
| 3076 | 3076 | |
| 3077 | - $this->recurring_item = $item->get_id(); |
|
| 3077 | + $this->recurring_item = $item->get_id(); |
|
| 3078 | 3078 | } |
| 3079 | 3079 | |
| 3080 | 3080 | // Invoice id. |
@@ -3085,28 +3085,28 @@ discard block |
||
| 3085 | 3085 | $items[ (int) $item->get_id() ] = $item; |
| 3086 | 3086 | |
| 3087 | 3087 | $this->set_prop( 'items', $items ); |
| 3088 | - return true; |
|
| 3088 | + return true; |
|
| 3089 | 3089 | } |
| 3090 | 3090 | |
| 3091 | 3091 | /** |
| 3092 | - * Retrieves a specific item. |
|
| 3093 | - * |
|
| 3094 | - * @since 1.0.19 |
|
| 3095 | - */ |
|
| 3096 | - public function get_item( $item_id ) { |
|
| 3097 | - $items = $this->get_items(); |
|
| 3098 | - $item_id = (int) $item_id; |
|
| 3099 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3092 | + * Retrieves a specific item. |
|
| 3093 | + * |
|
| 3094 | + * @since 1.0.19 |
|
| 3095 | + */ |
|
| 3096 | + public function get_item( $item_id ) { |
|
| 3097 | + $items = $this->get_items(); |
|
| 3098 | + $item_id = (int) $item_id; |
|
| 3099 | + return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3100 | 3100 | } |
| 3101 | 3101 | |
| 3102 | 3102 | /** |
| 3103 | - * Removes a specific item. |
|
| 3104 | - * |
|
| 3105 | - * @since 1.0.19 |
|
| 3106 | - */ |
|
| 3107 | - public function remove_item( $item_id ) { |
|
| 3108 | - $items = $this->get_items(); |
|
| 3109 | - $item_id = (int) $item_id; |
|
| 3103 | + * Removes a specific item. |
|
| 3104 | + * |
|
| 3105 | + * @since 1.0.19 |
|
| 3106 | + */ |
|
| 3107 | + public function remove_item( $item_id ) { |
|
| 3108 | + $items = $this->get_items(); |
|
| 3109 | + $item_id = (int) $item_id; |
|
| 3110 | 3110 | |
| 3111 | 3111 | if ( $item_id == $this->recurring_item ) { |
| 3112 | 3112 | $this->recurring_item = null; |
@@ -3133,38 +3133,38 @@ discard block |
||
| 3133 | 3133 | if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
| 3134 | 3134 | |
| 3135 | 3135 | $amount = $fees[ $fee ]['amount'] += $amount; |
| 3136 | - $fees[ $fee ] = array( |
|
| 3136 | + $fees[ $fee ] = array( |
|
| 3137 | 3137 | 'amount' => $amount, |
| 3138 | 3138 | 'recurring' => (bool) $recurring, |
| 3139 | 3139 | ); |
| 3140 | 3140 | |
| 3141 | - } else { |
|
| 3142 | - $fees[ $fee ] = array( |
|
| 3141 | + } else { |
|
| 3142 | + $fees[ $fee ] = array( |
|
| 3143 | 3143 | 'amount' => $amount, |
| 3144 | 3144 | 'recurring' => (bool) $recurring, |
| 3145 | 3145 | ); |
| 3146 | - } |
|
| 3146 | + } |
|
| 3147 | 3147 | |
| 3148 | 3148 | $this->set_prop( 'fees', $fee ); |
| 3149 | 3149 | |
| 3150 | 3150 | } |
| 3151 | 3151 | |
| 3152 | 3152 | /** |
| 3153 | - * Retrieves a specific fee. |
|
| 3154 | - * |
|
| 3155 | - * @since 1.0.19 |
|
| 3156 | - */ |
|
| 3157 | - public function get_fee( $fee ) { |
|
| 3153 | + * Retrieves a specific fee. |
|
| 3154 | + * |
|
| 3155 | + * @since 1.0.19 |
|
| 3156 | + */ |
|
| 3157 | + public function get_fee( $fee ) { |
|
| 3158 | 3158 | $fees = $this->get_fees(); |
| 3159 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3159 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3160 | 3160 | } |
| 3161 | 3161 | |
| 3162 | 3162 | /** |
| 3163 | - * Removes a specific fee. |
|
| 3164 | - * |
|
| 3165 | - * @since 1.0.19 |
|
| 3166 | - */ |
|
| 3167 | - public function remove_fee( $fee ) { |
|
| 3163 | + * Removes a specific fee. |
|
| 3164 | + * |
|
| 3165 | + * @since 1.0.19 |
|
| 3166 | + */ |
|
| 3167 | + public function remove_fee( $fee ) { |
|
| 3168 | 3168 | $fees = $this->get_fees(); |
| 3169 | 3169 | if ( isset( $fees[ $fee ] ) ) { |
| 3170 | 3170 | unset( $fees[ $fee ] ); |
@@ -3187,44 +3187,44 @@ discard block |
||
| 3187 | 3187 | if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
| 3188 | 3188 | |
| 3189 | 3189 | $amount = $discounts[ $discount ]['amount'] += $amount; |
| 3190 | - $discounts[ $discount ] = array( |
|
| 3190 | + $discounts[ $discount ] = array( |
|
| 3191 | 3191 | 'amount' => $amount, |
| 3192 | 3192 | 'recurring' => (bool) $recurring, |
| 3193 | 3193 | ); |
| 3194 | 3194 | |
| 3195 | - } else { |
|
| 3196 | - $discounts[ $discount ] = array( |
|
| 3195 | + } else { |
|
| 3196 | + $discounts[ $discount ] = array( |
|
| 3197 | 3197 | 'amount' => $amount, |
| 3198 | 3198 | 'recurring' => (bool) $recurring, |
| 3199 | 3199 | ); |
| 3200 | - } |
|
| 3200 | + } |
|
| 3201 | 3201 | |
| 3202 | 3202 | $this->set_prop( 'discounts', $discount ); |
| 3203 | 3203 | |
| 3204 | 3204 | } |
| 3205 | 3205 | |
| 3206 | 3206 | /** |
| 3207 | - * Retrieves a specific discount. |
|
| 3208 | - * |
|
| 3209 | - * @since 1.0.19 |
|
| 3210 | - */ |
|
| 3211 | - public function get_discount( $discount = false ) { |
|
| 3207 | + * Retrieves a specific discount. |
|
| 3208 | + * |
|
| 3209 | + * @since 1.0.19 |
|
| 3210 | + */ |
|
| 3211 | + public function get_discount( $discount = false ) { |
|
| 3212 | 3212 | |
| 3213 | - // Backwards compatibilty. |
|
| 3214 | - if ( empty( $discount ) ) { |
|
| 3215 | - return $this->get_total_discount(); |
|
| 3216 | - } |
|
| 3213 | + // Backwards compatibilty. |
|
| 3214 | + if ( empty( $discount ) ) { |
|
| 3215 | + return $this->get_total_discount(); |
|
| 3216 | + } |
|
| 3217 | 3217 | |
| 3218 | 3218 | $discounts = $this->get_discounts(); |
| 3219 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3219 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3220 | 3220 | } |
| 3221 | 3221 | |
| 3222 | 3222 | /** |
| 3223 | - * Removes a specific discount. |
|
| 3224 | - * |
|
| 3225 | - * @since 1.0.19 |
|
| 3226 | - */ |
|
| 3227 | - public function remove_discount( $discount ) { |
|
| 3223 | + * Removes a specific discount. |
|
| 3224 | + * |
|
| 3225 | + * @since 1.0.19 |
|
| 3226 | + */ |
|
| 3227 | + public function remove_discount( $discount ) { |
|
| 3228 | 3228 | $discounts = $this->get_discounts(); |
| 3229 | 3229 | if ( isset( $discounts[ $discount ] ) ) { |
| 3230 | 3230 | unset( $discounts[ $discount ] ); |
@@ -3250,44 +3250,44 @@ discard block |
||
| 3250 | 3250 | if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
| 3251 | 3251 | |
| 3252 | 3252 | $amount = $taxes[ $tax ]['amount'] += $amount; |
| 3253 | - $taxes[ $tax ] = array( |
|
| 3253 | + $taxes[ $tax ] = array( |
|
| 3254 | 3254 | 'amount' => $amount, |
| 3255 | 3255 | 'recurring' => (bool) $recurring, |
| 3256 | 3256 | ); |
| 3257 | 3257 | |
| 3258 | - } else { |
|
| 3259 | - $taxes[ $tax ] = array( |
|
| 3258 | + } else { |
|
| 3259 | + $taxes[ $tax ] = array( |
|
| 3260 | 3260 | 'amount' => $amount, |
| 3261 | 3261 | 'recurring' => (bool) $recurring, |
| 3262 | 3262 | ); |
| 3263 | - } |
|
| 3263 | + } |
|
| 3264 | 3264 | |
| 3265 | 3265 | $this->set_prop( 'taxes', $tax ); |
| 3266 | 3266 | |
| 3267 | 3267 | } |
| 3268 | 3268 | |
| 3269 | 3269 | /** |
| 3270 | - * Retrieves a specific tax. |
|
| 3271 | - * |
|
| 3272 | - * @since 1.0.19 |
|
| 3273 | - */ |
|
| 3274 | - public function get_tax( $tax = null ) { |
|
| 3270 | + * Retrieves a specific tax. |
|
| 3271 | + * |
|
| 3272 | + * @since 1.0.19 |
|
| 3273 | + */ |
|
| 3274 | + public function get_tax( $tax = null ) { |
|
| 3275 | 3275 | |
| 3276 | - // Backwards compatility. |
|
| 3277 | - if ( empty( $tax ) ) { |
|
| 3278 | - return $this->get_total_tax(); |
|
| 3279 | - } |
|
| 3276 | + // Backwards compatility. |
|
| 3277 | + if ( empty( $tax ) ) { |
|
| 3278 | + return $this->get_total_tax(); |
|
| 3279 | + } |
|
| 3280 | 3280 | |
| 3281 | 3281 | $taxes = $this->get_taxes(); |
| 3282 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3282 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3283 | 3283 | } |
| 3284 | 3284 | |
| 3285 | 3285 | /** |
| 3286 | - * Removes a specific tax. |
|
| 3287 | - * |
|
| 3288 | - * @since 1.0.19 |
|
| 3289 | - */ |
|
| 3290 | - public function remove_tax( $tax ) { |
|
| 3286 | + * Removes a specific tax. |
|
| 3287 | + * |
|
| 3288 | + * @since 1.0.19 |
|
| 3289 | + */ |
|
| 3290 | + public function remove_tax( $tax ) { |
|
| 3291 | 3291 | $taxes = $this->get_discounts(); |
| 3292 | 3292 | if ( isset( $taxes[ $tax ] ) ) { |
| 3293 | 3293 | unset( $taxes[ $tax ] ); |
@@ -3296,160 +3296,160 @@ discard block |
||
| 3296 | 3296 | } |
| 3297 | 3297 | |
| 3298 | 3298 | /** |
| 3299 | - * Recalculates the invoice subtotal. |
|
| 3300 | - * |
|
| 3301 | - * @since 1.0.19 |
|
| 3302 | - * @return float The recalculated subtotal |
|
| 3303 | - */ |
|
| 3304 | - public function recalculate_subtotal() { |
|
| 3299 | + * Recalculates the invoice subtotal. |
|
| 3300 | + * |
|
| 3301 | + * @since 1.0.19 |
|
| 3302 | + * @return float The recalculated subtotal |
|
| 3303 | + */ |
|
| 3304 | + public function recalculate_subtotal() { |
|
| 3305 | 3305 | $items = $this->get_items(); |
| 3306 | - $subtotal = 0; |
|
| 3307 | - $recurring = 0; |
|
| 3306 | + $subtotal = 0; |
|
| 3307 | + $recurring = 0; |
|
| 3308 | 3308 | |
| 3309 | 3309 | foreach ( $items as $item ) { |
| 3310 | - $subtotal += $item->get_sub_total(); |
|
| 3311 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3310 | + $subtotal += $item->get_sub_total(); |
|
| 3311 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3312 | 3312 | } |
| 3313 | 3313 | |
| 3314 | - if ( $this->is_renewal() ) { |
|
| 3315 | - $this->set_subtotal( $recurring ); |
|
| 3316 | - } else { |
|
| 3317 | - $this->set_subtotal( $subtotal ); |
|
| 3318 | - } |
|
| 3314 | + if ( $this->is_renewal() ) { |
|
| 3315 | + $this->set_subtotal( $recurring ); |
|
| 3316 | + } else { |
|
| 3317 | + $this->set_subtotal( $subtotal ); |
|
| 3318 | + } |
|
| 3319 | 3319 | |
| 3320 | - $this->totals['subtotal'] = array( |
|
| 3321 | - 'initial' => $subtotal, |
|
| 3322 | - 'recurring' => $recurring, |
|
| 3323 | - ); |
|
| 3320 | + $this->totals['subtotal'] = array( |
|
| 3321 | + 'initial' => $subtotal, |
|
| 3322 | + 'recurring' => $recurring, |
|
| 3323 | + ); |
|
| 3324 | 3324 | |
| 3325 | 3325 | return $this->is_renewal() ? $recurring : $subtotal; |
| 3326 | 3326 | } |
| 3327 | 3327 | |
| 3328 | 3328 | /** |
| 3329 | - * Recalculates the invoice discount total. |
|
| 3330 | - * |
|
| 3331 | - * @since 1.0.19 |
|
| 3332 | - * @return float The recalculated discount |
|
| 3333 | - */ |
|
| 3334 | - public function recalculate_total_discount() { |
|
| 3329 | + * Recalculates the invoice discount total. |
|
| 3330 | + * |
|
| 3331 | + * @since 1.0.19 |
|
| 3332 | + * @return float The recalculated discount |
|
| 3333 | + */ |
|
| 3334 | + public function recalculate_total_discount() { |
|
| 3335 | 3335 | $discounts = $this->get_discounts(); |
| 3336 | - $discount = 0; |
|
| 3337 | - $recurring = 0; |
|
| 3336 | + $discount = 0; |
|
| 3337 | + $recurring = 0; |
|
| 3338 | 3338 | |
| 3339 | 3339 | foreach ( $discounts as $data ) { |
| 3340 | 3340 | |
| 3341 | - if ( $data['recurring'] ) { |
|
| 3342 | - $recurring += $data['amount']; |
|
| 3343 | - } else { |
|
| 3344 | - $discount += $data['amount']; |
|
| 3345 | - } |
|
| 3341 | + if ( $data['recurring'] ) { |
|
| 3342 | + $recurring += $data['amount']; |
|
| 3343 | + } else { |
|
| 3344 | + $discount += $data['amount']; |
|
| 3345 | + } |
|
| 3346 | 3346 | |
| 3347 | - } |
|
| 3347 | + } |
|
| 3348 | 3348 | |
| 3349 | - if ( $this->is_renewal() ) { |
|
| 3350 | - $this->set_total_discount( $recurring ); |
|
| 3351 | - } else { |
|
| 3352 | - $this->set_total_discount( $discount ); |
|
| 3353 | - } |
|
| 3349 | + if ( $this->is_renewal() ) { |
|
| 3350 | + $this->set_total_discount( $recurring ); |
|
| 3351 | + } else { |
|
| 3352 | + $this->set_total_discount( $discount ); |
|
| 3353 | + } |
|
| 3354 | 3354 | |
| 3355 | - $this->totals['discount'] = array( |
|
| 3356 | - 'initial' => $discount, |
|
| 3357 | - 'recurring' => $recurring, |
|
| 3358 | - ); |
|
| 3355 | + $this->totals['discount'] = array( |
|
| 3356 | + 'initial' => $discount, |
|
| 3357 | + 'recurring' => $recurring, |
|
| 3358 | + ); |
|
| 3359 | 3359 | |
| 3360 | - return $this->is_renewal() ? $recurring : $discount; |
|
| 3360 | + return $this->is_renewal() ? $recurring : $discount; |
|
| 3361 | 3361 | |
| 3362 | 3362 | } |
| 3363 | 3363 | |
| 3364 | 3364 | /** |
| 3365 | - * Recalculates the invoice tax total. |
|
| 3366 | - * |
|
| 3367 | - * @since 1.0.19 |
|
| 3368 | - * @return float The recalculated tax |
|
| 3369 | - */ |
|
| 3370 | - public function recalculate_total_tax() { |
|
| 3365 | + * Recalculates the invoice tax total. |
|
| 3366 | + * |
|
| 3367 | + * @since 1.0.19 |
|
| 3368 | + * @return float The recalculated tax |
|
| 3369 | + */ |
|
| 3370 | + public function recalculate_total_tax() { |
|
| 3371 | 3371 | $taxes = $this->get_taxes(); |
| 3372 | - $tax = 0; |
|
| 3373 | - $recurring = 0; |
|
| 3372 | + $tax = 0; |
|
| 3373 | + $recurring = 0; |
|
| 3374 | 3374 | |
| 3375 | 3375 | foreach ( $taxes as $data ) { |
| 3376 | 3376 | |
| 3377 | - if ( $data['recurring'] ) { |
|
| 3378 | - $recurring += $data['amount']; |
|
| 3379 | - } else { |
|
| 3380 | - $tax += $data['amount']; |
|
| 3381 | - } |
|
| 3377 | + if ( $data['recurring'] ) { |
|
| 3378 | + $recurring += $data['amount']; |
|
| 3379 | + } else { |
|
| 3380 | + $tax += $data['amount']; |
|
| 3381 | + } |
|
| 3382 | 3382 | |
| 3383 | - } |
|
| 3383 | + } |
|
| 3384 | 3384 | |
| 3385 | - if ( $this->is_renewal() ) { |
|
| 3386 | - $this->set_total_tax( $recurring ); |
|
| 3387 | - } else { |
|
| 3388 | - $this->set_total_tax( $tax ); |
|
| 3389 | - } |
|
| 3385 | + if ( $this->is_renewal() ) { |
|
| 3386 | + $this->set_total_tax( $recurring ); |
|
| 3387 | + } else { |
|
| 3388 | + $this->set_total_tax( $tax ); |
|
| 3389 | + } |
|
| 3390 | 3390 | |
| 3391 | - $this->totals['tax'] = array( |
|
| 3392 | - 'initial' => $tax, |
|
| 3393 | - 'recurring' => $recurring, |
|
| 3394 | - ); |
|
| 3391 | + $this->totals['tax'] = array( |
|
| 3392 | + 'initial' => $tax, |
|
| 3393 | + 'recurring' => $recurring, |
|
| 3394 | + ); |
|
| 3395 | 3395 | |
| 3396 | - return $this->is_renewal() ? $recurring : $tax; |
|
| 3396 | + return $this->is_renewal() ? $recurring : $tax; |
|
| 3397 | 3397 | |
| 3398 | 3398 | } |
| 3399 | 3399 | |
| 3400 | 3400 | /** |
| 3401 | - * Recalculates the invoice fees total. |
|
| 3402 | - * |
|
| 3403 | - * @since 1.0.19 |
|
| 3404 | - * @return float The recalculated fee |
|
| 3405 | - */ |
|
| 3406 | - public function recalculate_total_fees() { |
|
| 3407 | - $fees = $this->get_fees(); |
|
| 3408 | - $fee = 0; |
|
| 3409 | - $recurring = 0; |
|
| 3401 | + * Recalculates the invoice fees total. |
|
| 3402 | + * |
|
| 3403 | + * @since 1.0.19 |
|
| 3404 | + * @return float The recalculated fee |
|
| 3405 | + */ |
|
| 3406 | + public function recalculate_total_fees() { |
|
| 3407 | + $fees = $this->get_fees(); |
|
| 3408 | + $fee = 0; |
|
| 3409 | + $recurring = 0; |
|
| 3410 | 3410 | |
| 3411 | 3411 | foreach ( $fees as $data ) { |
| 3412 | 3412 | |
| 3413 | - if ( $data['recurring'] ) { |
|
| 3414 | - $recurring += $data['amount']; |
|
| 3415 | - } else { |
|
| 3416 | - $fee += $data['amount']; |
|
| 3417 | - } |
|
| 3413 | + if ( $data['recurring'] ) { |
|
| 3414 | + $recurring += $data['amount']; |
|
| 3415 | + } else { |
|
| 3416 | + $fee += $data['amount']; |
|
| 3417 | + } |
|
| 3418 | 3418 | |
| 3419 | - } |
|
| 3419 | + } |
|
| 3420 | 3420 | |
| 3421 | 3421 | if ( $this->is_renewal() ) { |
| 3422 | - $this->set_total_fees( $recurring ); |
|
| 3423 | - } else { |
|
| 3424 | - $this->set_total_fees( $fee ); |
|
| 3425 | - } |
|
| 3422 | + $this->set_total_fees( $recurring ); |
|
| 3423 | + } else { |
|
| 3424 | + $this->set_total_fees( $fee ); |
|
| 3425 | + } |
|
| 3426 | 3426 | |
| 3427 | - $this->totals['fee'] = array( |
|
| 3428 | - 'initial' => $fee, |
|
| 3429 | - 'recurring' => $recurring, |
|
| 3430 | - ); |
|
| 3427 | + $this->totals['fee'] = array( |
|
| 3428 | + 'initial' => $fee, |
|
| 3429 | + 'recurring' => $recurring, |
|
| 3430 | + ); |
|
| 3431 | 3431 | |
| 3432 | 3432 | $this->set_total_fees( $fee ); |
| 3433 | 3433 | return $this->is_renewal() ? $recurring : $fee; |
| 3434 | 3434 | } |
| 3435 | 3435 | |
| 3436 | 3436 | /** |
| 3437 | - * Recalculates the invoice total. |
|
| 3438 | - * |
|
| 3439 | - * @since 1.0.19 |
|
| 3437 | + * Recalculates the invoice total. |
|
| 3438 | + * |
|
| 3439 | + * @since 1.0.19 |
|
| 3440 | 3440 | * @return float The invoice total |
| 3441 | - */ |
|
| 3442 | - public function recalculate_total() { |
|
| 3441 | + */ |
|
| 3442 | + public function recalculate_total() { |
|
| 3443 | 3443 | $this->recalculate_subtotal(); |
| 3444 | 3444 | $this->recalculate_total_fees(); |
| 3445 | 3445 | $this->recalculate_total_discount(); |
| 3446 | 3446 | $this->recalculate_total_tax(); |
| 3447 | - return $this->get_total(); |
|
| 3448 | - } |
|
| 3447 | + return $this->get_total(); |
|
| 3448 | + } |
|
| 3449 | 3449 | |
| 3450 | - /** |
|
| 3451 | - * @deprecated |
|
| 3452 | - */ |
|
| 3450 | + /** |
|
| 3451 | + * @deprecated |
|
| 3452 | + */ |
|
| 3453 | 3453 | public function recalculate_totals( $temp = false ) { |
| 3454 | 3454 | $this->update_items( $temp ); |
| 3455 | 3455 | $this->save( true ); |
@@ -3513,9 +3513,9 @@ discard block |
||
| 3513 | 3513 | } |
| 3514 | 3514 | |
| 3515 | 3515 | return $note_id; |
| 3516 | - } |
|
| 3516 | + } |
|
| 3517 | 3517 | |
| 3518 | - /** |
|
| 3518 | + /** |
|
| 3519 | 3519 | * Generates a unique key for the invoice. |
| 3520 | 3520 | */ |
| 3521 | 3521 | public function generate_key( $string = '' ) { |
@@ -3535,106 +3535,106 @@ discard block |
||
| 3535 | 3535 | $number = wpinv_get_next_invoice_number( $this->post_type ); |
| 3536 | 3536 | } |
| 3537 | 3537 | |
| 3538 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3538 | + $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3539 | 3539 | |
| 3540 | - return $number; |
|
| 3541 | - } |
|
| 3540 | + return $number; |
|
| 3541 | + } |
|
| 3542 | 3542 | |
| 3543 | - /** |
|
| 3544 | - * Handle the status transition. |
|
| 3545 | - */ |
|
| 3546 | - protected function status_transition() { |
|
| 3547 | - $status_transition = $this->status_transition; |
|
| 3543 | + /** |
|
| 3544 | + * Handle the status transition. |
|
| 3545 | + */ |
|
| 3546 | + protected function status_transition() { |
|
| 3547 | + $status_transition = $this->status_transition; |
|
| 3548 | 3548 | |
| 3549 | - // Reset status transition variable. |
|
| 3550 | - $this->status_transition = false; |
|
| 3549 | + // Reset status transition variable. |
|
| 3550 | + $this->status_transition = false; |
|
| 3551 | 3551 | |
| 3552 | - if ( $status_transition ) { |
|
| 3553 | - try { |
|
| 3552 | + if ( $status_transition ) { |
|
| 3553 | + try { |
|
| 3554 | 3554 | |
| 3555 | - // Fire a hook for the status change. |
|
| 3556 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3555 | + // Fire a hook for the status change. |
|
| 3556 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3557 | 3557 | |
| 3558 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3559 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3558 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3559 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3560 | 3560 | |
| 3561 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3561 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3562 | 3562 | |
| 3563 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3564 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3563 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3564 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3565 | 3565 | |
| 3566 | - // Fire another hook. |
|
| 3567 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3568 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3566 | + // Fire another hook. |
|
| 3567 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3568 | + do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3569 | 3569 | |
| 3570 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3571 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3570 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3571 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3572 | 3572 | |
| 3573 | - // Note the transition occurred. |
|
| 3574 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3573 | + // Note the transition occurred. |
|
| 3574 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3575 | 3575 | |
| 3576 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3577 | - if ( |
|
| 3578 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
| 3579 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3580 | - ) { |
|
| 3581 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3582 | - } |
|
| 3583 | - } else { |
|
| 3584 | - /* translators: %s: new invoice status */ |
|
| 3585 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3576 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3577 | + if ( |
|
| 3578 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
| 3579 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3580 | + ) { |
|
| 3581 | + do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3582 | + } |
|
| 3583 | + } else { |
|
| 3584 | + /* translators: %s: new invoice status */ |
|
| 3585 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3586 | 3586 | |
| 3587 | - // Note the transition occurred. |
|
| 3588 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3587 | + // Note the transition occurred. |
|
| 3588 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3589 | 3589 | |
| 3590 | - } |
|
| 3591 | - } catch ( Exception $e ) { |
|
| 3592 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3593 | - } |
|
| 3594 | - } |
|
| 3595 | - } |
|
| 3590 | + } |
|
| 3591 | + } catch ( Exception $e ) { |
|
| 3592 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3593 | + } |
|
| 3594 | + } |
|
| 3595 | + } |
|
| 3596 | 3596 | |
| 3597 | - /** |
|
| 3598 | - * Updates an invoice status. |
|
| 3599 | - */ |
|
| 3600 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3597 | + /** |
|
| 3598 | + * Updates an invoice status. |
|
| 3599 | + */ |
|
| 3600 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3601 | 3601 | |
| 3602 | - // Fires before updating a status. |
|
| 3603 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3602 | + // Fires before updating a status. |
|
| 3603 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3604 | 3604 | |
| 3605 | - // Update the status. |
|
| 3606 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3605 | + // Update the status. |
|
| 3606 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3607 | 3607 | |
| 3608 | - // Save the order. |
|
| 3609 | - return $this->save(); |
|
| 3608 | + // Save the order. |
|
| 3609 | + return $this->save(); |
|
| 3610 | 3610 | |
| 3611 | - } |
|
| 3611 | + } |
|
| 3612 | 3612 | |
| 3613 | - /** |
|
| 3614 | - * @deprecated |
|
| 3615 | - */ |
|
| 3616 | - public function refresh_item_ids() { |
|
| 3613 | + /** |
|
| 3614 | + * @deprecated |
|
| 3615 | + */ |
|
| 3616 | + public function refresh_item_ids() { |
|
| 3617 | 3617 | $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
| 3618 | 3618 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3619 | - } |
|
| 3619 | + } |
|
| 3620 | 3620 | |
| 3621 | - /** |
|
| 3622 | - * @deprecated |
|
| 3623 | - */ |
|
| 3624 | - public function update_items( $temp = false ) { |
|
| 3621 | + /** |
|
| 3622 | + * @deprecated |
|
| 3623 | + */ |
|
| 3624 | + public function update_items( $temp = false ) { |
|
| 3625 | 3625 | |
| 3626 | - $this->set_items( $this->get_items() ); |
|
| 3626 | + $this->set_items( $this->get_items() ); |
|
| 3627 | 3627 | |
| 3628 | - if ( ! $temp ) { |
|
| 3629 | - $this->save(); |
|
| 3630 | - } |
|
| 3628 | + if ( ! $temp ) { |
|
| 3629 | + $this->save(); |
|
| 3630 | + } |
|
| 3631 | 3631 | |
| 3632 | 3632 | return $this; |
| 3633 | - } |
|
| 3633 | + } |
|
| 3634 | 3634 | |
| 3635 | - /** |
|
| 3636 | - * @deprecated |
|
| 3637 | - */ |
|
| 3635 | + /** |
|
| 3636 | + * @deprecated |
|
| 3637 | + */ |
|
| 3638 | 3638 | public function validate_discount() { |
| 3639 | 3639 | |
| 3640 | 3640 | $discount_code = $this->get_discount_code(); |
@@ -3650,86 +3650,86 @@ discard block |
||
| 3650 | 3650 | |
| 3651 | 3651 | } |
| 3652 | 3652 | |
| 3653 | - /** |
|
| 3654 | - * Refunds an invoice. |
|
| 3655 | - */ |
|
| 3653 | + /** |
|
| 3654 | + * Refunds an invoice. |
|
| 3655 | + */ |
|
| 3656 | 3656 | public function refund() { |
| 3657 | - $this->set_status( 'wpi-refunded' ); |
|
| 3657 | + $this->set_status( 'wpi-refunded' ); |
|
| 3658 | 3658 | $this->save(); |
| 3659 | - } |
|
| 3659 | + } |
|
| 3660 | 3660 | |
| 3661 | - /** |
|
| 3662 | - * Marks an invoice as paid. |
|
| 3663 | - * |
|
| 3664 | - * @param string $transaction_id |
|
| 3665 | - */ |
|
| 3661 | + /** |
|
| 3662 | + * Marks an invoice as paid. |
|
| 3663 | + * |
|
| 3664 | + * @param string $transaction_id |
|
| 3665 | + */ |
|
| 3666 | 3666 | public function mark_paid( $transaction_id = null, $note = '' ) { |
| 3667 | 3667 | |
| 3668 | - // Set the transaction id. |
|
| 3669 | - if ( empty( $transaction_id ) ) { |
|
| 3670 | - $transaction_id = $this->generate_key('trans_'); |
|
| 3671 | - } |
|
| 3668 | + // Set the transaction id. |
|
| 3669 | + if ( empty( $transaction_id ) ) { |
|
| 3670 | + $transaction_id = $this->generate_key('trans_'); |
|
| 3671 | + } |
|
| 3672 | 3672 | |
| 3673 | - if ( ! $this->get_transaction_id() ) { |
|
| 3674 | - $this->set_transaction_id( $transaction_id ); |
|
| 3675 | - } |
|
| 3673 | + if ( ! $this->get_transaction_id() ) { |
|
| 3674 | + $this->set_transaction_id( $transaction_id ); |
|
| 3675 | + } |
|
| 3676 | 3676 | |
| 3677 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3678 | - return $this->save(); |
|
| 3679 | - } |
|
| 3677 | + if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3678 | + return $this->save(); |
|
| 3679 | + } |
|
| 3680 | 3680 | |
| 3681 | - // Set the completed date. |
|
| 3682 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3681 | + // Set the completed date. |
|
| 3682 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3683 | 3683 | |
| 3684 | - // Set the new status. |
|
| 3685 | - if ( $this->is_renewal() ) { |
|
| 3684 | + // Set the new status. |
|
| 3685 | + if ( $this->is_renewal() ) { |
|
| 3686 | 3686 | |
| 3687 | - $_note = sprintf( |
|
| 3688 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3689 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3690 | - ); |
|
| 3687 | + $_note = sprintf( |
|
| 3688 | + __( 'Renewed via %s', 'invoicing' ), |
|
| 3689 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3690 | + ); |
|
| 3691 | 3691 | |
| 3692 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3693 | - $_note = $note; |
|
| 3694 | - } |
|
| 3692 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3693 | + $_note = $note; |
|
| 3694 | + } |
|
| 3695 | 3695 | |
| 3696 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3696 | + $this->set_status( 'wpi-renewal', $_note ); |
|
| 3697 | 3697 | |
| 3698 | - } else { |
|
| 3698 | + } else { |
|
| 3699 | 3699 | |
| 3700 | - $_note = sprintf( |
|
| 3701 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3702 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3703 | - ); |
|
| 3700 | + $_note = sprintf( |
|
| 3701 | + __( 'Paid via %s', 'invoicing' ), |
|
| 3702 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3703 | + ); |
|
| 3704 | 3704 | |
| 3705 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3706 | - $_note = $note; |
|
| 3707 | - } |
|
| 3705 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3706 | + $_note = $note; |
|
| 3707 | + } |
|
| 3708 | 3708 | |
| 3709 | - $this->set_status( 'publish',$_note ); |
|
| 3709 | + $this->set_status( 'publish',$_note ); |
|
| 3710 | 3710 | |
| 3711 | - } |
|
| 3711 | + } |
|
| 3712 | 3712 | |
| 3713 | - // Set checkout mode. |
|
| 3714 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3715 | - $this->set_mode( $mode ); |
|
| 3713 | + // Set checkout mode. |
|
| 3714 | + $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3715 | + $this->set_mode( $mode ); |
|
| 3716 | 3716 | |
| 3717 | - // Save the invoice. |
|
| 3717 | + // Save the invoice. |
|
| 3718 | 3718 | $this->save(); |
| 3719 | - } |
|
| 3720 | - |
|
| 3721 | - |
|
| 3722 | - /** |
|
| 3723 | - * Save data to the database. |
|
| 3724 | - * |
|
| 3725 | - * @since 1.0.19 |
|
| 3726 | - * @return int invoice ID |
|
| 3727 | - */ |
|
| 3728 | - public function save() { |
|
| 3729 | - $this->maybe_set_date_paid(); |
|
| 3730 | - parent::save(); |
|
| 3731 | - $this->status_transition(); |
|
| 3732 | - return $this->get_id(); |
|
| 3733 | - } |
|
| 3719 | + } |
|
| 3720 | + |
|
| 3721 | + |
|
| 3722 | + /** |
|
| 3723 | + * Save data to the database. |
|
| 3724 | + * |
|
| 3725 | + * @since 1.0.19 |
|
| 3726 | + * @return int invoice ID |
|
| 3727 | + */ |
|
| 3728 | + public function save() { |
|
| 3729 | + $this->maybe_set_date_paid(); |
|
| 3730 | + parent::save(); |
|
| 3731 | + $this->status_transition(); |
|
| 3732 | + return $this->get_id(); |
|
| 3733 | + } |
|
| 3734 | 3734 | |
| 3735 | 3735 | } |
@@ -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. |
@@ -133,40 +133,40 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
| 135 | 135 | */ |
| 136 | - public function __construct( $invoice = false ) { |
|
| 136 | + public function __construct($invoice = false) { |
|
| 137 | 137 | |
| 138 | - parent::__construct( $invoice ); |
|
| 138 | + parent::__construct($invoice); |
|
| 139 | 139 | |
| 140 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 141 | - $this->set_id( $invoice ); |
|
| 142 | - } elseif ( $invoice instanceof self ) { |
|
| 143 | - $this->set_id( $invoice->get_id() ); |
|
| 144 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 145 | - $this->set_id( $invoice->ID ); |
|
| 146 | - } elseif ( is_array( $invoice ) ) { |
|
| 147 | - $this->set_props( $invoice ); |
|
| 140 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
| 141 | + $this->set_id($invoice); |
|
| 142 | + } elseif ($invoice instanceof self) { |
|
| 143 | + $this->set_id($invoice->get_id()); |
|
| 144 | + } elseif (!empty($invoice->ID)) { |
|
| 145 | + $this->set_id($invoice->ID); |
|
| 146 | + } elseif (is_array($invoice)) { |
|
| 147 | + $this->set_props($invoice); |
|
| 148 | 148 | |
| 149 | - if ( isset( $invoice['ID'] ) ) { |
|
| 150 | - $this->set_id( $invoice['ID'] ); |
|
| 149 | + if (isset($invoice['ID'])) { |
|
| 150 | + $this->set_id($invoice['ID']); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 154 | - $this->set_id( $invoice_id ); |
|
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - }else { |
|
| 160 | - $this->set_object_read( true ); |
|
| 153 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
| 154 | + $this->set_id($invoice_id); |
|
| 155 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
| 156 | + $this->set_id($invoice_id); |
|
| 157 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
| 158 | + $this->set_id($invoice_id); |
|
| 159 | + } else { |
|
| 160 | + $this->set_object_read(true); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Load the datastore. |
| 164 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 164 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 165 | 165 | |
| 166 | - if ( $this->get_id() > 0 ) { |
|
| 167 | - $this->post = get_post( $this->get_id() ); |
|
| 166 | + if ($this->get_id() > 0) { |
|
| 167 | + $this->post = get_post($this->get_id()); |
|
| 168 | 168 | $this->ID = $this->get_id(); |
| 169 | - $this->data_store->read( $this ); |
|
| 169 | + $this->data_store->read($this); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
@@ -181,42 +181,42 @@ discard block |
||
| 181 | 181 | * @since 1.0.15 |
| 182 | 182 | * @return int |
| 183 | 183 | */ |
| 184 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 184 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
| 185 | 185 | global $wpdb; |
| 186 | 186 | |
| 187 | 187 | // Trim the value. |
| 188 | - $value = trim( $value ); |
|
| 188 | + $value = trim($value); |
|
| 189 | 189 | |
| 190 | - if ( empty( $value ) ) { |
|
| 190 | + if (empty($value)) { |
|
| 191 | 191 | return 0; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // Valid fields. |
| 195 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
| 195 | + $fields = array('key', 'number', 'transaction_id'); |
|
| 196 | 196 | |
| 197 | 197 | // Ensure a field has been passed. |
| 198 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 198 | + if (empty($field) || !in_array($field, $fields)) { |
|
| 199 | 199 | return 0; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // Maybe retrieve from the cache. |
| 203 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 204 | - if ( ! empty( $invoice_id ) ) { |
|
| 203 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 204 | + if (!empty($invoice_id)) { |
|
| 205 | 205 | return $invoice_id; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Fetch from the db. |
| 209 | 209 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 210 | 210 | $invoice_id = $wpdb->get_var( |
| 211 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
| 211 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | - if ( empty( $invoice_id ) ) { |
|
| 214 | + if (empty($invoice_id)) { |
|
| 215 | 215 | return 0; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Update the cache with our data |
| 219 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 219 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 220 | 220 | |
| 221 | 221 | return $invoice_id; |
| 222 | 222 | } |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | /** |
| 225 | 225 | * Checks if an invoice key is set. |
| 226 | 226 | */ |
| 227 | - public function _isset( $key ) { |
|
| 228 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 227 | + public function _isset($key) { |
|
| 228 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /* |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | * @param string $context View or edit context. |
| 251 | 251 | * @return int |
| 252 | 252 | */ |
| 253 | - public function get_parent_id( $context = 'view' ) { |
|
| 254 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 253 | + public function get_parent_id($context = 'view') { |
|
| 254 | + return (int) $this->get_prop('parent_id', $context); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @return WPInv_Invoice |
| 262 | 262 | */ |
| 263 | 263 | public function get_parent_payment() { |
| 264 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 264 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | * @param string $context View or edit context. |
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | - public function get_status( $context = 'view' ) { |
|
| 285 | - return $this->get_prop( 'status', $context ); |
|
| 284 | + public function get_status($context = 'view') { |
|
| 285 | + return $this->get_prop('status', $context); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function get_all_statuses() { |
| 295 | 295 | |
| 296 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 296 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
| 297 | 297 | |
| 298 | 298 | // For backwards compatibility. |
| 299 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 299 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
| 300 | 300 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | public function get_status_nicename() { |
| 313 | 313 | $statuses = $this->get_all_statuses(); |
| 314 | 314 | |
| 315 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 315 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 316 | 316 | |
| 317 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
| 317 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -324,27 +324,27 @@ discard block |
||
| 324 | 324 | * @param string $context View or edit context. |
| 325 | 325 | * @return string |
| 326 | 326 | */ |
| 327 | - public function get_version( $context = 'view' ) { |
|
| 328 | - return $this->get_prop( 'version', $context ); |
|
| 327 | + public function get_version($context = 'view') { |
|
| 328 | + return $this->get_prop('version', $context); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | 332 | * @deprecated |
| 333 | 333 | */ |
| 334 | - public function get_invoice_date( $formatted = true ) { |
|
| 334 | + public function get_invoice_date($formatted = true) { |
|
| 335 | 335 | $date_completed = $this->get_date_completed(); |
| 336 | 336 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 337 | 337 | |
| 338 | - if ( $invoice_date == '' ) { |
|
| 338 | + if ($invoice_date == '') { |
|
| 339 | 339 | $date_created = $this->get_date_created(); |
| 340 | 340 | $invoice_date = $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ( $formatted && $invoice_date ) { |
|
| 344 | - $invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) ); |
|
| 343 | + if ($formatted && $invoice_date) { |
|
| 344 | + $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date)); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this ); |
|
| 347 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
| 354 | 354 | * @param string $context View or edit context. |
| 355 | 355 | * @return string |
| 356 | 356 | */ |
| 357 | - public function get_date_created( $context = 'view' ) { |
|
| 358 | - return $this->get_prop( 'date_created', $context ); |
|
| 357 | + public function get_date_created($context = 'view') { |
|
| 358 | + return $this->get_prop('date_created', $context); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | * @param string $context View or edit context. |
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | - public function get_created_date( $context = 'view' ) { |
|
| 369 | - return $this->get_date_created( $context ); |
|
| 368 | + public function get_created_date($context = 'view') { |
|
| 369 | + return $this->get_date_created($context); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -376,11 +376,11 @@ discard block |
||
| 376 | 376 | * @param string $context View or edit context. |
| 377 | 377 | * @return string |
| 378 | 378 | */ |
| 379 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 380 | - $date = $this->get_date_created( $context ); |
|
| 379 | + public function get_date_created_gmt($context = 'view') { |
|
| 380 | + $date = $this->get_date_created($context); |
|
| 381 | 381 | |
| 382 | - if ( $date ) { |
|
| 383 | - $date = get_gmt_from_date( $date ); |
|
| 382 | + if ($date) { |
|
| 383 | + $date = get_gmt_from_date($date); |
|
| 384 | 384 | } |
| 385 | 385 | return $date; |
| 386 | 386 | } |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | * @param string $context View or edit context. |
| 393 | 393 | * @return string |
| 394 | 394 | */ |
| 395 | - public function get_date_modified( $context = 'view' ) { |
|
| 396 | - return $this->get_prop( 'date_modified', $context ); |
|
| 395 | + public function get_date_modified($context = 'view') { |
|
| 396 | + return $this->get_prop('date_modified', $context); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | * @param string $context View or edit context. |
| 404 | 404 | * @return string |
| 405 | 405 | */ |
| 406 | - public function get_modified_date( $context = 'view' ) { |
|
| 407 | - return $this->get_date_modified( $context ); |
|
| 406 | + public function get_modified_date($context = 'view') { |
|
| 407 | + return $this->get_date_modified($context); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | * @param string $context View or edit context. |
| 415 | 415 | * @return string |
| 416 | 416 | */ |
| 417 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 418 | - $date = $this->get_date_modified( $context ); |
|
| 417 | + public function get_date_modified_gmt($context = 'view') { |
|
| 418 | + $date = $this->get_date_modified($context); |
|
| 419 | 419 | |
| 420 | - if ( $date ) { |
|
| 421 | - $date = get_gmt_from_date( $date ); |
|
| 420 | + if ($date) { |
|
| 421 | + $date = get_gmt_from_date($date); |
|
| 422 | 422 | } |
| 423 | 423 | return $date; |
| 424 | 424 | } |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | * @param string $context View or edit context. |
| 431 | 431 | * @return string |
| 432 | 432 | */ |
| 433 | - public function get_due_date( $context = 'view' ) { |
|
| 434 | - return $this->get_prop( 'due_date', $context ); |
|
| 433 | + public function get_due_date($context = 'view') { |
|
| 434 | + return $this->get_prop('due_date', $context); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -441,8 +441,8 @@ discard block |
||
| 441 | 441 | * @param string $context View or edit context. |
| 442 | 442 | * @return string |
| 443 | 443 | */ |
| 444 | - public function get_date_due( $context = 'view' ) { |
|
| 445 | - return $this->get_due_date( $context ); |
|
| 444 | + public function get_date_due($context = 'view') { |
|
| 445 | + return $this->get_due_date($context); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | * @param string $context View or edit context. |
| 453 | 453 | * @return string |
| 454 | 454 | */ |
| 455 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 456 | - $date = $this->get_due_date( $context ); |
|
| 455 | + public function get_due_date_gmt($context = 'view') { |
|
| 456 | + $date = $this->get_due_date($context); |
|
| 457 | 457 | |
| 458 | - if ( $date ) { |
|
| 459 | - $date = get_gmt_from_date( $date ); |
|
| 458 | + if ($date) { |
|
| 459 | + $date = get_gmt_from_date($date); |
|
| 460 | 460 | } |
| 461 | 461 | return $date; |
| 462 | 462 | } |
@@ -468,8 +468,8 @@ discard block |
||
| 468 | 468 | * @param string $context View or edit context. |
| 469 | 469 | * @return string |
| 470 | 470 | */ |
| 471 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 472 | - return $this->get_due_date_gmt( $context ); |
|
| 471 | + public function get_gmt_date_due($context = 'view') { |
|
| 472 | + return $this->get_due_date_gmt($context); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
@@ -479,8 +479,8 @@ discard block |
||
| 479 | 479 | * @param string $context View or edit context. |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | - public function get_completed_date( $context = 'view' ) { |
|
| 483 | - return $this->get_prop( 'completed_date', $context ); |
|
| 482 | + public function get_completed_date($context = 'view') { |
|
| 483 | + return $this->get_prop('completed_date', $context); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -490,8 +490,8 @@ discard block |
||
| 490 | 490 | * @param string $context View or edit context. |
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | - public function get_date_completed( $context = 'view' ) { |
|
| 494 | - return $this->get_completed_date( $context ); |
|
| 493 | + public function get_date_completed($context = 'view') { |
|
| 494 | + return $this->get_completed_date($context); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
@@ -501,11 +501,11 @@ discard block |
||
| 501 | 501 | * @param string $context View or edit context. |
| 502 | 502 | * @return string |
| 503 | 503 | */ |
| 504 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 505 | - $date = $this->get_completed_date( $context ); |
|
| 504 | + public function get_completed_date_gmt($context = 'view') { |
|
| 505 | + $date = $this->get_completed_date($context); |
|
| 506 | 506 | |
| 507 | - if ( $date ) { |
|
| 508 | - $date = get_gmt_from_date( $date ); |
|
| 507 | + if ($date) { |
|
| 508 | + $date = get_gmt_from_date($date); |
|
| 509 | 509 | } |
| 510 | 510 | return $date; |
| 511 | 511 | } |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | * @param string $context View or edit context. |
| 518 | 518 | * @return string |
| 519 | 519 | */ |
| 520 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 521 | - return $this->get_completed_date_gmt( $context ); |
|
| 520 | + public function get_gmt_completed_date($context = 'view') { |
|
| 521 | + return $this->get_completed_date_gmt($context); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -528,12 +528,12 @@ discard block |
||
| 528 | 528 | * @param string $context View or edit context. |
| 529 | 529 | * @return string |
| 530 | 530 | */ |
| 531 | - public function get_number( $context = 'view' ) { |
|
| 532 | - $number = $this->get_prop( 'number', $context ); |
|
| 531 | + public function get_number($context = 'view') { |
|
| 532 | + $number = $this->get_prop('number', $context); |
|
| 533 | 533 | |
| 534 | - if ( empty( $number ) ) { |
|
| 534 | + if (empty($number)) { |
|
| 535 | 535 | $number = $this->generate_number(); |
| 536 | - $this->set_number( $number ); |
|
| 536 | + $this->set_number($number); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | return $number; |
@@ -546,12 +546,12 @@ discard block |
||
| 546 | 546 | * @param string $context View or edit context. |
| 547 | 547 | * @return string |
| 548 | 548 | */ |
| 549 | - public function get_key( $context = 'view' ) { |
|
| 550 | - $key = $this->get_prop( 'key', $context ); |
|
| 549 | + public function get_key($context = 'view') { |
|
| 550 | + $key = $this->get_prop('key', $context); |
|
| 551 | 551 | |
| 552 | - if ( empty( $key ) ) { |
|
| 553 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
| 554 | - $this->set_key( $key ); |
|
| 552 | + if (empty($key)) { |
|
| 553 | + $key = $this->generate_key($this->get_type() . '_'); |
|
| 554 | + $this->set_key($key); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | return $key; |
@@ -564,23 +564,23 @@ discard block |
||
| 564 | 564 | * @param string $context View or edit context. |
| 565 | 565 | * @return string |
| 566 | 566 | */ |
| 567 | - public function get_type( $context = 'view' ) { |
|
| 568 | - return $this->get_prop( 'type', $context ); |
|
| 567 | + public function get_type($context = 'view') { |
|
| 568 | + return $this->get_prop('type', $context); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
| 572 | 572 | * @deprecated |
| 573 | 573 | */ |
| 574 | - public function get_invoice_quote_type( $post_id ) { |
|
| 575 | - if ( empty( $post_id ) ) { |
|
| 574 | + public function get_invoice_quote_type($post_id) { |
|
| 575 | + if (empty($post_id)) { |
|
| 576 | 576 | return ''; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - $type = get_post_type( $post_id ); |
|
| 579 | + $type = get_post_type($post_id); |
|
| 580 | 580 | |
| 581 | - if ( 'wpi_invoice' === $type ) { |
|
| 581 | + if ('wpi_invoice' === $type) { |
|
| 582 | 582 | $post_type = __('Invoice', 'invoicing'); |
| 583 | - } else{ |
|
| 583 | + } else { |
|
| 584 | 584 | $post_type = __('Quote', 'invoicing'); |
| 585 | 585 | } |
| 586 | 586 | |
@@ -594,8 +594,8 @@ discard block |
||
| 594 | 594 | * @param string $context View or edit context. |
| 595 | 595 | * @return string |
| 596 | 596 | */ |
| 597 | - public function get_post_type( $context = 'view' ) { |
|
| 598 | - return $this->get_prop( 'post_type', $context ); |
|
| 597 | + public function get_post_type($context = 'view') { |
|
| 598 | + return $this->get_prop('post_type', $context); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
@@ -605,8 +605,8 @@ discard block |
||
| 605 | 605 | * @param string $context View or edit context. |
| 606 | 606 | * @return string |
| 607 | 607 | */ |
| 608 | - public function get_mode( $context = 'view' ) { |
|
| 609 | - return $this->get_prop( 'mode', $context ); |
|
| 608 | + public function get_mode($context = 'view') { |
|
| 609 | + return $this->get_prop('mode', $context); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
@@ -616,12 +616,12 @@ discard block |
||
| 616 | 616 | * @param string $context View or edit context. |
| 617 | 617 | * @return string |
| 618 | 618 | */ |
| 619 | - public function get_path( $context = 'view' ) { |
|
| 620 | - $path = $this->get_prop( 'path', $context ); |
|
| 619 | + public function get_path($context = 'view') { |
|
| 620 | + $path = $this->get_prop('path', $context); |
|
| 621 | 621 | |
| 622 | - if ( empty( $path ) ) { |
|
| 623 | - $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type ); |
|
| 624 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
| 622 | + if (empty($path)) { |
|
| 623 | + $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type); |
|
| 624 | + $path = sanitize_title($prefix . $this->get_id()); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | return $path; |
@@ -634,10 +634,10 @@ discard block |
||
| 634 | 634 | * @param string $context View or edit context. |
| 635 | 635 | * @return string |
| 636 | 636 | */ |
| 637 | - public function get_name( $context = 'view' ) { |
|
| 638 | - $name = $this->get_prop( 'title', $context ); |
|
| 637 | + public function get_name($context = 'view') { |
|
| 638 | + $name = $this->get_prop('title', $context); |
|
| 639 | 639 | |
| 640 | - return empty( $name ) ? $this->get_number( $context ) : $name; |
|
| 640 | + return empty($name) ? $this->get_number($context) : $name; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -647,8 +647,8 @@ discard block |
||
| 647 | 647 | * @param string $context View or edit context. |
| 648 | 648 | * @return string |
| 649 | 649 | */ |
| 650 | - public function get_title( $context = 'view' ) { |
|
| 651 | - return $this->get_name( $context ); |
|
| 650 | + public function get_title($context = 'view') { |
|
| 651 | + return $this->get_name($context); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
@@ -658,8 +658,8 @@ discard block |
||
| 658 | 658 | * @param string $context View or edit context. |
| 659 | 659 | * @return string |
| 660 | 660 | */ |
| 661 | - public function get_description( $context = 'view' ) { |
|
| 662 | - return $this->get_prop( 'description', $context ); |
|
| 661 | + public function get_description($context = 'view') { |
|
| 662 | + return $this->get_prop('description', $context); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** |
@@ -669,8 +669,8 @@ discard block |
||
| 669 | 669 | * @param string $context View or edit context. |
| 670 | 670 | * @return string |
| 671 | 671 | */ |
| 672 | - public function get_excerpt( $context = 'view' ) { |
|
| 673 | - return $this->get_description( $context ); |
|
| 672 | + public function get_excerpt($context = 'view') { |
|
| 673 | + return $this->get_description($context); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
@@ -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_summary( $context = 'view' ) { |
|
| 684 | - return $this->get_description( $context ); |
|
| 683 | + public function get_summary($context = 'view') { |
|
| 684 | + return $this->get_description($context); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -691,25 +691,25 @@ discard block |
||
| 691 | 691 | * @param string $context View or edit context. |
| 692 | 692 | * @return array |
| 693 | 693 | */ |
| 694 | - public function get_user_info( $context = 'view' ) { |
|
| 694 | + public function get_user_info($context = 'view') { |
|
| 695 | 695 | |
| 696 | 696 | $user_info = array( |
| 697 | - 'user_id' => $this->get_user_id( $context ), |
|
| 698 | - 'email' => $this->get_email( $context ), |
|
| 699 | - 'first_name' => $this->get_first_name( $context ), |
|
| 700 | - 'last_name' => $this->get_last_name( $context ), |
|
| 701 | - 'address' => $this->get_address( $context ), |
|
| 702 | - 'phone' => $this->get_phone( $context ), |
|
| 703 | - 'city' => $this->get_city( $context ), |
|
| 704 | - 'country' => $this->get_country( $context ), |
|
| 705 | - 'state' => $this->get_state( $context ), |
|
| 706 | - 'zip' => $this->get_zip( $context ), |
|
| 707 | - 'company' => $this->get_company( $context ), |
|
| 708 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 709 | - 'discount' => $this->get_discount_code( $context ), |
|
| 697 | + 'user_id' => $this->get_user_id($context), |
|
| 698 | + 'email' => $this->get_email($context), |
|
| 699 | + 'first_name' => $this->get_first_name($context), |
|
| 700 | + 'last_name' => $this->get_last_name($context), |
|
| 701 | + 'address' => $this->get_address($context), |
|
| 702 | + 'phone' => $this->get_phone($context), |
|
| 703 | + 'city' => $this->get_city($context), |
|
| 704 | + 'country' => $this->get_country($context), |
|
| 705 | + 'state' => $this->get_state($context), |
|
| 706 | + 'zip' => $this->get_zip($context), |
|
| 707 | + 'company' => $this->get_company($context), |
|
| 708 | + 'vat_number' => $this->get_vat_number($context), |
|
| 709 | + 'discount' => $this->get_discount_code($context), |
|
| 710 | 710 | ); |
| 711 | 711 | |
| 712 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 712 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 713 | 713 | |
| 714 | 714 | } |
| 715 | 715 | |
@@ -720,8 +720,8 @@ discard block |
||
| 720 | 720 | * @param string $context View or edit context. |
| 721 | 721 | * @return int |
| 722 | 722 | */ |
| 723 | - public function get_author( $context = 'view' ) { |
|
| 724 | - return (int) $this->get_prop( 'author', $context ); |
|
| 723 | + public function get_author($context = 'view') { |
|
| 724 | + return (int) $this->get_prop('author', $context); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
@@ -731,8 +731,8 @@ discard block |
||
| 731 | 731 | * @param string $context View or edit context. |
| 732 | 732 | * @return int |
| 733 | 733 | */ |
| 734 | - public function get_user_id( $context = 'view' ) { |
|
| 735 | - return $this->get_author( $context ); |
|
| 734 | + public function get_user_id($context = 'view') { |
|
| 735 | + return $this->get_author($context); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -742,8 +742,8 @@ discard block |
||
| 742 | 742 | * @param string $context View or edit context. |
| 743 | 743 | * @return int |
| 744 | 744 | */ |
| 745 | - public function get_customer_id( $context = 'view' ) { |
|
| 746 | - return $this->get_author( $context ); |
|
| 745 | + public function get_customer_id($context = 'view') { |
|
| 746 | + return $this->get_author($context); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | * @param string $context View or edit context. |
| 754 | 754 | * @return string |
| 755 | 755 | */ |
| 756 | - public function get_ip( $context = 'view' ) { |
|
| 757 | - return $this->get_prop( 'user_ip', $context ); |
|
| 756 | + public function get_ip($context = 'view') { |
|
| 757 | + return $this->get_prop('user_ip', $context); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | * @param string $context View or edit context. |
| 765 | 765 | * @return string |
| 766 | 766 | */ |
| 767 | - public function get_user_ip( $context = 'view' ) { |
|
| 768 | - return $this->get_ip( $context ); |
|
| 767 | + public function get_user_ip($context = 'view') { |
|
| 768 | + return $this->get_ip($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 string |
| 777 | 777 | */ |
| 778 | - public function get_customer_ip( $context = 'view' ) { |
|
| 779 | - return $this->get_ip( $context ); |
|
| 778 | + public function get_customer_ip($context = 'view') { |
|
| 779 | + return $this->get_ip($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 string |
| 788 | 788 | */ |
| 789 | - public function get_first_name( $context = 'view' ) { |
|
| 790 | - return $this->get_prop( 'first_name', $context ); |
|
| 789 | + public function get_first_name($context = 'view') { |
|
| 790 | + return $this->get_prop('first_name', $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 int |
| 799 | 799 | */ |
| 800 | - public function get_user_first_name( $context = 'view' ) { |
|
| 801 | - return $this->get_first_name( $context ); |
|
| 800 | + public function get_user_first_name($context = 'view') { |
|
| 801 | + return $this->get_first_name($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 int |
| 810 | 810 | */ |
| 811 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 812 | - return $this->get_first_name( $context ); |
|
| 811 | + public function get_customer_first_name($context = 'view') { |
|
| 812 | + return $this->get_first_name($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_last_name( $context = 'view' ) { |
|
| 823 | - return $this->get_prop( 'last_name', $context ); |
|
| 822 | + public function get_last_name($context = 'view') { |
|
| 823 | + return $this->get_prop('last_name', $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 int |
| 832 | 832 | */ |
| 833 | - public function get_user_last_name( $context = 'view' ) { |
|
| 834 | - return $this->get_last_name( $context ); |
|
| 833 | + public function get_user_last_name($context = 'view') { |
|
| 834 | + return $this->get_last_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 int |
| 843 | 843 | */ |
| 844 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 845 | - return $this->get_last_name( $context ); |
|
| 844 | + public function get_customer_last_name($context = 'view') { |
|
| 845 | + return $this->get_last_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_full_name( $context = 'view' ) { |
|
| 856 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 855 | + public function get_full_name($context = 'view') { |
|
| 856 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_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 int |
| 865 | 865 | */ |
| 866 | - public function get_user_full_name( $context = 'view' ) { |
|
| 867 | - return $this->get_full_name( $context ); |
|
| 866 | + public function get_user_full_name($context = 'view') { |
|
| 867 | + return $this->get_full_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 int |
| 876 | 876 | */ |
| 877 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 878 | - return $this->get_full_name( $context ); |
|
| 877 | + public function get_customer_full_name($context = 'view') { |
|
| 878 | + return $this->get_full_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_phone( $context = 'view' ) { |
|
| 889 | - return $this->get_prop( 'phone', $context ); |
|
| 888 | + public function get_phone($context = 'view') { |
|
| 889 | + return $this->get_prop('phone', $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 int |
| 898 | 898 | */ |
| 899 | - public function get_phone_number( $context = 'view' ) { |
|
| 900 | - return $this->get_phone( $context ); |
|
| 899 | + public function get_phone_number($context = 'view') { |
|
| 900 | + return $this->get_phone($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 int |
| 909 | 909 | */ |
| 910 | - public function get_user_phone( $context = 'view' ) { |
|
| 911 | - return $this->get_phone( $context ); |
|
| 910 | + public function get_user_phone($context = 'view') { |
|
| 911 | + return $this->get_phone($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 int |
| 920 | 920 | */ |
| 921 | - public function get_customer_phone( $context = 'view' ) { |
|
| 922 | - return $this->get_phone( $context ); |
|
| 921 | + public function get_customer_phone($context = 'view') { |
|
| 922 | + return $this->get_phone($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_email( $context = 'view' ) { |
|
| 933 | - return $this->get_prop( 'email', $context ); |
|
| 932 | + public function get_email($context = 'view') { |
|
| 933 | + return $this->get_prop('email', $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_email_address( $context = 'view' ) { |
|
| 944 | - return $this->get_email( $context ); |
|
| 943 | + public function get_email_address($context = 'view') { |
|
| 944 | + return $this->get_email($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 int |
| 953 | 953 | */ |
| 954 | - public function get_user_email( $context = 'view' ) { |
|
| 955 | - return $this->get_email( $context ); |
|
| 954 | + public function get_user_email($context = 'view') { |
|
| 955 | + return $this->get_email($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 int |
| 964 | 964 | */ |
| 965 | - public function get_customer_email( $context = 'view' ) { |
|
| 966 | - return $this->get_email( $context ); |
|
| 965 | + public function get_customer_email($context = 'view') { |
|
| 966 | + return $this->get_email($context); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
@@ -973,9 +973,9 @@ discard block |
||
| 973 | 973 | * @param string $context View or edit context. |
| 974 | 974 | * @return string |
| 975 | 975 | */ |
| 976 | - public function get_country( $context = 'view' ) { |
|
| 977 | - $country = $this->get_prop( 'country', $context ); |
|
| 978 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 976 | + public function get_country($context = 'view') { |
|
| 977 | + $country = $this->get_prop('country', $context); |
|
| 978 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | /** |
@@ -985,8 +985,8 @@ discard block |
||
| 985 | 985 | * @param string $context View or edit context. |
| 986 | 986 | * @return int |
| 987 | 987 | */ |
| 988 | - public function get_user_country( $context = 'view' ) { |
|
| 989 | - return $this->get_country( $context ); |
|
| 988 | + public function get_user_country($context = 'view') { |
|
| 989 | + return $this->get_country($context); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | /** |
@@ -996,8 +996,8 @@ discard block |
||
| 996 | 996 | * @param string $context View or edit context. |
| 997 | 997 | * @return int |
| 998 | 998 | */ |
| 999 | - public function get_customer_country( $context = 'view' ) { |
|
| 1000 | - return $this->get_country( $context ); |
|
| 999 | + public function get_customer_country($context = 'view') { |
|
| 1000 | + return $this->get_country($context); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | /** |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | * @param string $context View or edit context. |
| 1008 | 1008 | * @return string |
| 1009 | 1009 | */ |
| 1010 | - public function get_state( $context = 'view' ) { |
|
| 1011 | - $state = $this->get_prop( 'state', $context ); |
|
| 1012 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1010 | + public function get_state($context = 'view') { |
|
| 1011 | + $state = $this->get_prop('state', $context); |
|
| 1012 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | /** |
@@ -1019,8 +1019,8 @@ discard block |
||
| 1019 | 1019 | * @param string $context View or edit context. |
| 1020 | 1020 | * @return int |
| 1021 | 1021 | */ |
| 1022 | - public function get_user_state( $context = 'view' ) { |
|
| 1023 | - return $this->get_state( $context ); |
|
| 1022 | + public function get_user_state($context = 'view') { |
|
| 1023 | + return $this->get_state($context); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
@@ -1030,8 +1030,8 @@ discard block |
||
| 1030 | 1030 | * @param string $context View or edit context. |
| 1031 | 1031 | * @return int |
| 1032 | 1032 | */ |
| 1033 | - public function get_customer_state( $context = 'view' ) { |
|
| 1034 | - return $this->get_state( $context ); |
|
| 1033 | + public function get_customer_state($context = 'view') { |
|
| 1034 | + return $this->get_state($context); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | /** |
@@ -1041,8 +1041,8 @@ discard block |
||
| 1041 | 1041 | * @param string $context View or edit context. |
| 1042 | 1042 | * @return string |
| 1043 | 1043 | */ |
| 1044 | - public function get_city( $context = 'view' ) { |
|
| 1045 | - return $this->get_prop( 'city', $context ); |
|
| 1044 | + public function get_city($context = 'view') { |
|
| 1045 | + return $this->get_prop('city', $context); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | /** |
@@ -1052,8 +1052,8 @@ discard block |
||
| 1052 | 1052 | * @param string $context View or edit context. |
| 1053 | 1053 | * @return string |
| 1054 | 1054 | */ |
| 1055 | - public function get_user_city( $context = 'view' ) { |
|
| 1056 | - return $this->get_city( $context ); |
|
| 1055 | + public function get_user_city($context = 'view') { |
|
| 1056 | + return $this->get_city($context); |
|
| 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_customer_city( $context = 'view' ) { |
|
| 1067 | - return $this->get_city( $context ); |
|
| 1066 | + public function get_customer_city($context = 'view') { |
|
| 1067 | + return $this->get_city($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_zip( $context = 'view' ) { |
|
| 1078 | - return $this->get_prop( 'zip', $context ); |
|
| 1077 | + public function get_zip($context = 'view') { |
|
| 1078 | + return $this->get_prop('zip', $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_user_zip( $context = 'view' ) { |
|
| 1089 | - return $this->get_zip( $context ); |
|
| 1088 | + public function get_user_zip($context = 'view') { |
|
| 1089 | + return $this->get_zip($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_customer_zip( $context = 'view' ) { |
|
| 1100 | - return $this->get_zip( $context ); |
|
| 1099 | + public function get_customer_zip($context = 'view') { |
|
| 1100 | + return $this->get_zip($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_company( $context = 'view' ) { |
|
| 1111 | - return $this->get_prop( 'company', $context ); |
|
| 1110 | + public function get_company($context = 'view') { |
|
| 1111 | + return $this->get_prop('company', $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_user_company( $context = 'view' ) { |
|
| 1122 | - return $this->get_company( $context ); |
|
| 1121 | + public function get_user_company($context = 'view') { |
|
| 1122 | + return $this->get_company($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_customer_company( $context = 'view' ) { |
|
| 1133 | - return $this->get_company( $context ); |
|
| 1132 | + public function get_customer_company($context = 'view') { |
|
| 1133 | + return $this->get_company($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_vat_number( $context = 'view' ) { |
|
| 1144 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1143 | + public function get_vat_number($context = 'view') { |
|
| 1144 | + return $this->get_prop('vat_number', $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_user_vat_number( $context = 'view' ) { |
|
| 1155 | - return $this->get_vat_number( $context ); |
|
| 1154 | + public function get_user_vat_number($context = 'view') { |
|
| 1155 | + return $this->get_vat_number($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_customer_vat_number( $context = 'view' ) { |
|
| 1166 | - return $this->get_vat_number( $context ); |
|
| 1165 | + public function get_customer_vat_number($context = 'view') { |
|
| 1166 | + return $this->get_vat_number($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_vat_rate( $context = 'view' ) { |
|
| 1177 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1176 | + public function get_vat_rate($context = 'view') { |
|
| 1177 | + return $this->get_prop('vat_rate', $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_user_vat_rate( $context = 'view' ) { |
|
| 1188 | - return $this->get_vat_rate( $context ); |
|
| 1187 | + public function get_user_vat_rate($context = 'view') { |
|
| 1188 | + return $this->get_vat_rate($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_customer_vat_rate( $context = 'view' ) { |
|
| 1199 | - return $this->get_vat_rate( $context ); |
|
| 1198 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1199 | + return $this->get_vat_rate($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_address( $context = 'view' ) { |
|
| 1210 | - return $this->get_prop( 'address', $context ); |
|
| 1209 | + public function get_address($context = 'view') { |
|
| 1210 | + return $this->get_prop('address', $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_user_address( $context = 'view' ) { |
|
| 1221 | - return $this->get_address( $context ); |
|
| 1220 | + public function get_user_address($context = 'view') { |
|
| 1221 | + return $this->get_address($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_customer_address( $context = 'view' ) { |
|
| 1232 | - return $this->get_address( $context ); |
|
| 1231 | + public function get_customer_address($context = 'view') { |
|
| 1232 | + return $this->get_address($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 bool |
| 1241 | 1241 | */ |
| 1242 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1243 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1242 | + public function get_is_viewed($context = 'view') { |
|
| 1243 | + return (bool) $this->get_prop('is_viewed', $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 bool |
| 1252 | 1252 | */ |
| 1253 | - public function get_email_cc( $context = 'view' ) { |
|
| 1254 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1253 | + public function get_email_cc($context = 'view') { |
|
| 1254 | + return $this->get_prop('email_cc', $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 bool |
| 1263 | 1263 | */ |
| 1264 | - public function get_template( $context = 'view' ) { |
|
| 1265 | - return $this->get_prop( 'template', $context ); |
|
| 1264 | + public function get_template($context = 'view') { |
|
| 1265 | + return $this->get_prop('template', $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 bool |
| 1274 | 1274 | */ |
| 1275 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1276 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1275 | + public function get_address_confirmed($context = 'view') { |
|
| 1276 | + return (bool) $this->get_prop('address_confirmed', $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_user_address_confirmed( $context = 'view' ) { |
|
| 1287 | - return $this->get_address_confirmed( $context ); |
|
| 1286 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1287 | + return $this->get_address_confirmed($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_customer_address_confirmed( $context = 'view' ) { |
|
| 1298 | - return $this->get_address_confirmed( $context ); |
|
| 1297 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1298 | + return $this->get_address_confirmed($context); |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1305,12 +1305,12 @@ discard block |
||
| 1305 | 1305 | * @param string $context View or edit context. |
| 1306 | 1306 | * @return float |
| 1307 | 1307 | */ |
| 1308 | - public function get_subtotal( $context = 'view' ) { |
|
| 1309 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1308 | + public function get_subtotal($context = 'view') { |
|
| 1309 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1310 | 1310 | |
| 1311 | 1311 | // Backwards compatibility. |
| 1312 | - if ( is_bool( $context ) && $context ) { |
|
| 1313 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
| 1312 | + if (is_bool($context) && $context) { |
|
| 1313 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | return $subtotal; |
@@ -1323,8 +1323,8 @@ discard block |
||
| 1323 | 1323 | * @param string $context View or edit context. |
| 1324 | 1324 | * @return float |
| 1325 | 1325 | */ |
| 1326 | - public function get_total_discount( $context = 'view' ) { |
|
| 1327 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1326 | + public function get_total_discount($context = 'view') { |
|
| 1327 | + return (float) $this->get_prop('total_discount', $context); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | /** |
@@ -1334,18 +1334,18 @@ discard block |
||
| 1334 | 1334 | * @param string $context View or edit context. |
| 1335 | 1335 | * @return float |
| 1336 | 1336 | */ |
| 1337 | - public function get_total_tax( $context = 'view' ) { |
|
| 1338 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1337 | + public function get_total_tax($context = 'view') { |
|
| 1338 | + return (float) $this->get_prop('total_tax', $context); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /** |
| 1342 | 1342 | * @deprecated |
| 1343 | 1343 | */ |
| 1344 | - public function get_final_tax( $currency = false ) { |
|
| 1344 | + public function get_final_tax($currency = false) { |
|
| 1345 | 1345 | $tax = $this->get_total_tax(); |
| 1346 | 1346 | |
| 1347 | - if ( $currency ) { |
|
| 1348 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1347 | + if ($currency) { |
|
| 1348 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | return $tax; |
@@ -1358,8 +1358,8 @@ discard block |
||
| 1358 | 1358 | * @param string $context View or edit context. |
| 1359 | 1359 | * @return float |
| 1360 | 1360 | */ |
| 1361 | - public function get_total_fees( $context = 'view' ) { |
|
| 1362 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1361 | + public function get_total_fees($context = 'view') { |
|
| 1362 | + return (float) $this->get_prop('total_fees', $context); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | /** |
@@ -1369,8 +1369,8 @@ discard block |
||
| 1369 | 1369 | * @param string $context View or edit context. |
| 1370 | 1370 | * @return float |
| 1371 | 1371 | */ |
| 1372 | - public function get_fees_total( $context = 'view' ) { |
|
| 1373 | - return $this->get_total_fees( $context ); |
|
| 1372 | + public function get_fees_total($context = 'view') { |
|
| 1373 | + return $this->get_total_fees($context); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | /** |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | */ |
| 1382 | 1382 | public function get_total() { |
| 1383 | 1383 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
| 1384 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1384 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | /** |
@@ -1393,7 +1393,7 @@ discard block |
||
| 1393 | 1393 | */ |
| 1394 | 1394 | public function get_initial_total() { |
| 1395 | 1395 | |
| 1396 | - if ( empty( $this->totals ) ) { |
|
| 1396 | + if (empty($this->totals)) { |
|
| 1397 | 1397 | $this->recalculate_total(); |
| 1398 | 1398 | } |
| 1399 | 1399 | |
@@ -1403,11 +1403,11 @@ discard block |
||
| 1403 | 1403 | $subtotal = $this->totals['subtotal']['initial']; |
| 1404 | 1404 | $total = $tax + $fee - $discount + $subtotal; |
| 1405 | 1405 | |
| 1406 | - if ( 0 > $total ) { |
|
| 1406 | + if (0 > $total) { |
|
| 1407 | 1407 | $total = 0; |
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1410 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | /** |
@@ -1419,7 +1419,7 @@ discard block |
||
| 1419 | 1419 | */ |
| 1420 | 1420 | public function get_recurring_total() { |
| 1421 | 1421 | |
| 1422 | - if ( empty( $this->totals ) ) { |
|
| 1422 | + if (empty($this->totals)) { |
|
| 1423 | 1423 | $this->recalculate_total(); |
| 1424 | 1424 | } |
| 1425 | 1425 | |
@@ -1429,11 +1429,11 @@ discard block |
||
| 1429 | 1429 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1430 | 1430 | $total = $tax + $fee - $discount + $subtotal; |
| 1431 | 1431 | |
| 1432 | - if ( 0 > $total ) { |
|
| 1432 | + if (0 > $total) { |
|
| 1433 | 1433 | $total = 0; |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1436 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | /** |
@@ -1444,10 +1444,10 @@ discard block |
||
| 1444 | 1444 | * @param string $currency Whether to include the currency. |
| 1445 | 1445 | * @return float |
| 1446 | 1446 | */ |
| 1447 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1447 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1448 | 1448 | |
| 1449 | 1449 | // Maybe recalculate totals. |
| 1450 | - if ( empty( $this->totals ) ) { |
|
| 1450 | + if (empty($this->totals)) { |
|
| 1451 | 1451 | $this->recalculate_total(); |
| 1452 | 1452 | } |
| 1453 | 1453 | |
@@ -1467,8 +1467,8 @@ discard block |
||
| 1467 | 1467 | $currency |
| 1468 | 1468 | ); |
| 1469 | 1469 | |
| 1470 | - if ( isset( $data[$field] ) ) { |
|
| 1471 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1470 | + if (isset($data[$field])) { |
|
| 1471 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | |
| 1474 | 1474 | return $data; |
@@ -1481,8 +1481,8 @@ discard block |
||
| 1481 | 1481 | * @param string $context View or edit context. |
| 1482 | 1482 | * @return array |
| 1483 | 1483 | */ |
| 1484 | - public function get_fees( $context = 'view' ) { |
|
| 1485 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1484 | + public function get_fees($context = 'view') { |
|
| 1485 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | /** |
@@ -1492,8 +1492,8 @@ discard block |
||
| 1492 | 1492 | * @param string $context View or edit context. |
| 1493 | 1493 | * @return array |
| 1494 | 1494 | */ |
| 1495 | - public function get_discounts( $context = 'view' ) { |
|
| 1496 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1495 | + public function get_discounts($context = 'view') { |
|
| 1496 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | /** |
@@ -1503,8 +1503,8 @@ discard block |
||
| 1503 | 1503 | * @param string $context View or edit context. |
| 1504 | 1504 | * @return array |
| 1505 | 1505 | */ |
| 1506 | - public function get_taxes( $context = 'view' ) { |
|
| 1507 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1506 | + public function get_taxes($context = 'view') { |
|
| 1507 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | /** |
@@ -1514,8 +1514,8 @@ discard block |
||
| 1514 | 1514 | * @param string $context View or edit context. |
| 1515 | 1515 | * @return GetPaid_Form_Item[] |
| 1516 | 1516 | */ |
| 1517 | - public function get_items( $context = 'view' ) { |
|
| 1518 | - return $this->get_prop( 'items', $context ); |
|
| 1517 | + public function get_items($context = 'view') { |
|
| 1518 | + return $this->get_prop('items', $context); |
|
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | /** |
@@ -1525,8 +1525,8 @@ discard block |
||
| 1525 | 1525 | * @param string $context View or edit context. |
| 1526 | 1526 | * @return int |
| 1527 | 1527 | */ |
| 1528 | - public function get_payment_form( $context = 'view' ) { |
|
| 1529 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1528 | + public function get_payment_form($context = 'view') { |
|
| 1529 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | /** |
@@ -1536,8 +1536,8 @@ discard block |
||
| 1536 | 1536 | * @param string $context View or edit context. |
| 1537 | 1537 | * @return string |
| 1538 | 1538 | */ |
| 1539 | - public function get_submission_id( $context = 'view' ) { |
|
| 1540 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1539 | + public function get_submission_id($context = 'view') { |
|
| 1540 | + return $this->get_prop('submission_id', $context); |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | /** |
@@ -1547,8 +1547,8 @@ discard block |
||
| 1547 | 1547 | * @param string $context View or edit context. |
| 1548 | 1548 | * @return string |
| 1549 | 1549 | */ |
| 1550 | - public function get_discount_code( $context = 'view' ) { |
|
| 1551 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1550 | + public function get_discount_code($context = 'view') { |
|
| 1551 | + return $this->get_prop('discount_code', $context); |
|
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | 1554 | /** |
@@ -1558,8 +1558,8 @@ discard block |
||
| 1558 | 1558 | * @param string $context View or edit context. |
| 1559 | 1559 | * @return string |
| 1560 | 1560 | */ |
| 1561 | - public function get_gateway( $context = 'view' ) { |
|
| 1562 | - return $this->get_prop( 'gateway', $context ); |
|
| 1561 | + public function get_gateway($context = 'view') { |
|
| 1562 | + return $this->get_prop('gateway', $context); |
|
| 1563 | 1563 | } |
| 1564 | 1564 | |
| 1565 | 1565 | /** |
@@ -1569,8 +1569,8 @@ discard block |
||
| 1569 | 1569 | * @return string |
| 1570 | 1570 | */ |
| 1571 | 1571 | public function get_gateway_title() { |
| 1572 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1573 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1572 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1573 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | /** |
@@ -1580,8 +1580,8 @@ discard block |
||
| 1580 | 1580 | * @param string $context View or edit context. |
| 1581 | 1581 | * @return string |
| 1582 | 1582 | */ |
| 1583 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1584 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1583 | + public function get_transaction_id($context = 'view') { |
|
| 1584 | + return $this->get_prop('transaction_id', $context); |
|
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | /** |
@@ -1591,9 +1591,9 @@ discard block |
||
| 1591 | 1591 | * @param string $context View or edit context. |
| 1592 | 1592 | * @return string |
| 1593 | 1593 | */ |
| 1594 | - public function get_currency( $context = 'view' ) { |
|
| 1595 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1596 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1594 | + public function get_currency($context = 'view') { |
|
| 1595 | + $currency = $this->get_prop('currency', $context); |
|
| 1596 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | 1599 | /** |
@@ -1603,8 +1603,8 @@ discard block |
||
| 1603 | 1603 | * @param string $context View or edit context. |
| 1604 | 1604 | * @return bool |
| 1605 | 1605 | */ |
| 1606 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1607 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1606 | + public function get_disable_taxes($context = 'view') { |
|
| 1607 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | /** |
@@ -1614,12 +1614,12 @@ discard block |
||
| 1614 | 1614 | * @param string $context View or edit context. |
| 1615 | 1615 | * @return int |
| 1616 | 1616 | */ |
| 1617 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1618 | - $subscription_id = $this->get_prop( 'subscription_id', $context ); |
|
| 1617 | + public function get_subscription_id($context = 'view') { |
|
| 1618 | + $subscription_id = $this->get_prop('subscription_id', $context); |
|
| 1619 | 1619 | |
| 1620 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1620 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1621 | 1621 | $parent = $this->get_parent(); |
| 1622 | - return $parent->get_subscription_id( $context ); |
|
| 1622 | + return $parent->get_subscription_id($context); |
|
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | 1625 | return $subscription_id; |
@@ -1632,20 +1632,20 @@ discard block |
||
| 1632 | 1632 | * @param string $context View or edit context. |
| 1633 | 1633 | * @return array |
| 1634 | 1634 | */ |
| 1635 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1635 | + public function get_payment_meta($context = 'view') { |
|
| 1636 | 1636 | |
| 1637 | 1637 | return array( |
| 1638 | - 'price' => $this->get_total( $context ), |
|
| 1639 | - 'date' => $this->get_date_created( $context ), |
|
| 1640 | - 'user_email' => $this->get_email( $context ), |
|
| 1641 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1642 | - 'currency' => $this->get_currency( $context ), |
|
| 1643 | - 'items' => $this->get_items( $context ), |
|
| 1644 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1638 | + 'price' => $this->get_total($context), |
|
| 1639 | + 'date' => $this->get_date_created($context), |
|
| 1640 | + 'user_email' => $this->get_email($context), |
|
| 1641 | + 'invoice_key' => $this->get_key($context), |
|
| 1642 | + 'currency' => $this->get_currency($context), |
|
| 1643 | + 'items' => $this->get_items($context), |
|
| 1644 | + 'user_info' => $this->get_user_info($context), |
|
| 1645 | 1645 | 'cart_details' => $this->get_cart_details(), |
| 1646 | - 'status' => $this->get_status( $context ), |
|
| 1647 | - 'fees' => $this->get_fees( $context ), |
|
| 1648 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1646 | + 'status' => $this->get_status($context), |
|
| 1647 | + 'fees' => $this->get_fees($context), |
|
| 1648 | + 'taxes' => $this->get_taxes($context), |
|
| 1649 | 1649 | ); |
| 1650 | 1650 | |
| 1651 | 1651 | } |
@@ -1660,7 +1660,7 @@ discard block |
||
| 1660 | 1660 | $items = $this->get_items(); |
| 1661 | 1661 | $cart_details = array(); |
| 1662 | 1662 | |
| 1663 | - foreach ( $items as $item_id => $item ) { |
|
| 1663 | + foreach ($items as $item_id => $item) { |
|
| 1664 | 1664 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1665 | 1665 | } |
| 1666 | 1666 | |
@@ -1672,11 +1672,11 @@ discard block |
||
| 1672 | 1672 | * |
| 1673 | 1673 | * @return null|GetPaid_Form_Item|int |
| 1674 | 1674 | */ |
| 1675 | - public function get_recurring( $object = false ) { |
|
| 1675 | + public function get_recurring($object = false) { |
|
| 1676 | 1676 | |
| 1677 | 1677 | // Are we returning an object? |
| 1678 | - if ( $object ) { |
|
| 1679 | - return $this->get_item( $this->recurring_item ); |
|
| 1678 | + if ($object) { |
|
| 1679 | + return $this->get_item($this->recurring_item); |
|
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | return $this->recurring_item; |
@@ -1691,15 +1691,15 @@ discard block |
||
| 1691 | 1691 | public function get_subscription_name() { |
| 1692 | 1692 | |
| 1693 | 1693 | // Retrieve the recurring name |
| 1694 | - $item = $this->get_recurring( true ); |
|
| 1694 | + $item = $this->get_recurring(true); |
|
| 1695 | 1695 | |
| 1696 | 1696 | // Abort if it does not exist. |
| 1697 | - if ( empty( $item ) ) { |
|
| 1697 | + if (empty($item)) { |
|
| 1698 | 1698 | return ''; |
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | 1701 | // Return the item name. |
| 1702 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1702 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | 1705 | /** |
@@ -1709,9 +1709,9 @@ discard block |
||
| 1709 | 1709 | * @return string |
| 1710 | 1710 | */ |
| 1711 | 1711 | public function get_view_url() { |
| 1712 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1713 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1714 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1712 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1713 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1714 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | 1717 | /** |
@@ -1720,25 +1720,25 @@ discard block |
||
| 1720 | 1720 | * @since 1.0.19 |
| 1721 | 1721 | * @return string |
| 1722 | 1722 | */ |
| 1723 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1723 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1724 | 1724 | |
| 1725 | 1725 | // Retrieve the checkout url. |
| 1726 | 1726 | $pay_url = wpinv_get_checkout_uri(); |
| 1727 | 1727 | |
| 1728 | 1728 | // Maybe force ssl. |
| 1729 | - if ( is_ssl() ) { |
|
| 1730 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1729 | + if (is_ssl()) { |
|
| 1730 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | 1733 | // Add the invoice key. |
| 1734 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1734 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1735 | 1735 | |
| 1736 | 1736 | // (Maybe?) add a secret |
| 1737 | - if ( $secret ) { |
|
| 1738 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1737 | + if ($secret) { |
|
| 1738 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1741 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | /** |
@@ -1753,14 +1753,14 @@ discard block |
||
| 1753 | 1753 | $receipt_url = wpinv_get_success_page_uri(); |
| 1754 | 1754 | |
| 1755 | 1755 | // Maybe force ssl. |
| 1756 | - if ( is_ssl() ) { |
|
| 1757 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
| 1756 | + if (is_ssl()) { |
|
| 1757 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
| 1758 | 1758 | } |
| 1759 | 1759 | |
| 1760 | 1760 | // Add the invoice key. |
| 1761 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1761 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
| 1762 | 1762 | |
| 1763 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
| 1763 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | 1766 | /** |
@@ -1773,8 +1773,8 @@ discard block |
||
| 1773 | 1773 | * @param string $context View or edit context. |
| 1774 | 1774 | * @return mixed Value of the given invoice property (if set). |
| 1775 | 1775 | */ |
| 1776 | - public function get( $key, $context = 'view' ) { |
|
| 1777 | - return $this->get_prop( $key, $context ); |
|
| 1776 | + public function get($key, $context = 'view') { |
|
| 1777 | + return $this->get_prop($key, $context); |
|
| 1778 | 1778 | } |
| 1779 | 1779 | |
| 1780 | 1780 | /* |
@@ -1797,11 +1797,11 @@ discard block |
||
| 1797 | 1797 | * @param mixed $value new value. |
| 1798 | 1798 | * @return mixed Value of the given invoice property (if set). |
| 1799 | 1799 | */ |
| 1800 | - public function set( $key, $value ) { |
|
| 1800 | + public function set($key, $value) { |
|
| 1801 | 1801 | |
| 1802 | 1802 | $setter = "set_$key"; |
| 1803 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1804 | - $this->{$setter}( $value ); |
|
| 1803 | + if (is_callable(array($this, $setter))) { |
|
| 1804 | + $this->{$setter}($value); |
|
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | 1807 | } |
@@ -1815,48 +1815,48 @@ discard block |
||
| 1815 | 1815 | * @param bool $manual_update Is this a manual status change?. |
| 1816 | 1816 | * @return array details of change. |
| 1817 | 1817 | */ |
| 1818 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1818 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1819 | 1819 | $old_status = $this->get_status(); |
| 1820 | 1820 | |
| 1821 | 1821 | $statuses = $this->get_all_statuses(); |
| 1822 | 1822 | |
| 1823 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1824 | - unset( $statuses[ 'draft' ] ); |
|
| 1823 | + if (isset($statuses['draft'])) { |
|
| 1824 | + unset($statuses['draft']); |
|
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | 1827 | |
| 1828 | - $this->set_prop( 'status', $new_status ); |
|
| 1828 | + $this->set_prop('status', $new_status); |
|
| 1829 | 1829 | |
| 1830 | 1830 | // If setting the status, ensure it's set to a valid status. |
| 1831 | - if ( true === $this->object_read ) { |
|
| 1831 | + if (true === $this->object_read) { |
|
| 1832 | 1832 | |
| 1833 | 1833 | // Only allow valid new status. |
| 1834 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1834 | + if (!array_key_exists($new_status, $statuses)) { |
|
| 1835 | 1835 | $new_status = 'wpi-pending'; |
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1839 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1839 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
| 1840 | 1840 | $old_status = 'wpi-pending'; |
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | 1843 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
| 1844 | - if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) { |
|
| 1844 | + if ($new_status == 'wpi-renewal' && $old_status == 'publish') { |
|
| 1845 | 1845 | $old_status = 'wpi-pending'; |
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1850 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
| 1851 | 1851 | $this->status_transition = array( |
| 1852 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1852 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1853 | 1853 | 'to' => $new_status, |
| 1854 | 1854 | 'note' => $note, |
| 1855 | 1855 | 'manual' => (bool) $manual_update, |
| 1856 | 1856 | ); |
| 1857 | 1857 | |
| 1858 | - if ( $manual_update ) { |
|
| 1859 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1858 | + if ($manual_update) { |
|
| 1859 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1860 | 1860 | } |
| 1861 | 1861 | |
| 1862 | 1862 | $this->maybe_set_date_paid(); |
@@ -1879,8 +1879,8 @@ discard block |
||
| 1879 | 1879 | */ |
| 1880 | 1880 | public function maybe_set_date_paid() { |
| 1881 | 1881 | |
| 1882 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1883 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1882 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 1883 | + $this->set_date_completed(current_time('mysql')); |
|
| 1884 | 1884 | } |
| 1885 | 1885 | } |
| 1886 | 1886 | |
@@ -1889,11 +1889,11 @@ discard block |
||
| 1889 | 1889 | * |
| 1890 | 1890 | * @since 1.0.19 |
| 1891 | 1891 | */ |
| 1892 | - public function set_parent_id( $value ) { |
|
| 1893 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1892 | + public function set_parent_id($value) { |
|
| 1893 | + if ($value && ($value === $this->get_id())) { |
|
| 1894 | 1894 | return; |
| 1895 | 1895 | } |
| 1896 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1896 | + $this->set_prop('parent_id', absint($value)); |
|
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | 1899 | /** |
@@ -1901,8 +1901,8 @@ discard block |
||
| 1901 | 1901 | * |
| 1902 | 1902 | * @since 1.0.19 |
| 1903 | 1903 | */ |
| 1904 | - public function set_version( $value ) { |
|
| 1905 | - $this->set_prop( 'version', $value ); |
|
| 1904 | + public function set_version($value) { |
|
| 1905 | + $this->set_prop('version', $value); |
|
| 1906 | 1906 | } |
| 1907 | 1907 | |
| 1908 | 1908 | /** |
@@ -1912,15 +1912,15 @@ discard block |
||
| 1912 | 1912 | * @param string $value Value to set. |
| 1913 | 1913 | * @return bool Whether or not the date was set. |
| 1914 | 1914 | */ |
| 1915 | - public function set_date_created( $value ) { |
|
| 1916 | - $date = strtotime( $value ); |
|
| 1915 | + public function set_date_created($value) { |
|
| 1916 | + $date = strtotime($value); |
|
| 1917 | 1917 | |
| 1918 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1919 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1918 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1919 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 1920 | 1920 | return true; |
| 1921 | 1921 | } |
| 1922 | 1922 | |
| 1923 | - return $this->set_prop( 'date_created', '' ); |
|
| 1923 | + return $this->set_prop('date_created', ''); |
|
| 1924 | 1924 | |
| 1925 | 1925 | } |
| 1926 | 1926 | |
@@ -1931,15 +1931,15 @@ discard block |
||
| 1931 | 1931 | * @param string $value Value to set. |
| 1932 | 1932 | * @return bool Whether or not the date was set. |
| 1933 | 1933 | */ |
| 1934 | - public function set_due_date( $value ) { |
|
| 1935 | - $date = strtotime( $value ); |
|
| 1934 | + public function set_due_date($value) { |
|
| 1935 | + $date = strtotime($value); |
|
| 1936 | 1936 | |
| 1937 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1938 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1937 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1938 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 1939 | 1939 | return true; |
| 1940 | 1940 | } |
| 1941 | 1941 | |
| 1942 | - $this->set_prop( 'due_date', '' ); |
|
| 1942 | + $this->set_prop('due_date', ''); |
|
| 1943 | 1943 | return false; |
| 1944 | 1944 | |
| 1945 | 1945 | } |
@@ -1950,8 +1950,8 @@ discard block |
||
| 1950 | 1950 | * @since 1.0.19 |
| 1951 | 1951 | * @param string $value New name. |
| 1952 | 1952 | */ |
| 1953 | - public function set_date_due( $value ) { |
|
| 1954 | - $this->set_due_date( $value ); |
|
| 1953 | + public function set_date_due($value) { |
|
| 1954 | + $this->set_due_date($value); |
|
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | 1957 | /** |
@@ -1961,15 +1961,15 @@ discard block |
||
| 1961 | 1961 | * @param string $value Value to set. |
| 1962 | 1962 | * @return bool Whether or not the date was set. |
| 1963 | 1963 | */ |
| 1964 | - public function set_completed_date( $value ) { |
|
| 1965 | - $date = strtotime( $value ); |
|
| 1964 | + public function set_completed_date($value) { |
|
| 1965 | + $date = strtotime($value); |
|
| 1966 | 1966 | |
| 1967 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1968 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1967 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1968 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 1969 | 1969 | return true; |
| 1970 | 1970 | } |
| 1971 | 1971 | |
| 1972 | - $this->set_prop( 'completed_date', '' ); |
|
| 1972 | + $this->set_prop('completed_date', ''); |
|
| 1973 | 1973 | return false; |
| 1974 | 1974 | |
| 1975 | 1975 | } |
@@ -1980,8 +1980,8 @@ discard block |
||
| 1980 | 1980 | * @since 1.0.19 |
| 1981 | 1981 | * @param string $value New name. |
| 1982 | 1982 | */ |
| 1983 | - public function set_date_completed( $value ) { |
|
| 1984 | - $this->set_completed_date( $value ); |
|
| 1983 | + public function set_date_completed($value) { |
|
| 1984 | + $this->set_completed_date($value); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | /** |
@@ -1991,15 +1991,15 @@ discard block |
||
| 1991 | 1991 | * @param string $value Value to set. |
| 1992 | 1992 | * @return bool Whether or not the date was set. |
| 1993 | 1993 | */ |
| 1994 | - public function set_date_modified( $value ) { |
|
| 1995 | - $date = strtotime( $value ); |
|
| 1994 | + public function set_date_modified($value) { |
|
| 1995 | + $date = strtotime($value); |
|
| 1996 | 1996 | |
| 1997 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1998 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1997 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1998 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 1999 | 1999 | return true; |
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | - $this->set_prop( 'date_modified', '' ); |
|
| 2002 | + $this->set_prop('date_modified', ''); |
|
| 2003 | 2003 | return false; |
| 2004 | 2004 | |
| 2005 | 2005 | } |
@@ -2010,9 +2010,9 @@ discard block |
||
| 2010 | 2010 | * @since 1.0.19 |
| 2011 | 2011 | * @param string $value New number. |
| 2012 | 2012 | */ |
| 2013 | - public function set_number( $value ) { |
|
| 2014 | - $number = sanitize_text_field( $value ); |
|
| 2015 | - $this->set_prop( 'number', $number ); |
|
| 2013 | + public function set_number($value) { |
|
| 2014 | + $number = sanitize_text_field($value); |
|
| 2015 | + $this->set_prop('number', $number); |
|
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | 2018 | /** |
@@ -2021,9 +2021,9 @@ discard block |
||
| 2021 | 2021 | * @since 1.0.19 |
| 2022 | 2022 | * @param string $value Type. |
| 2023 | 2023 | */ |
| 2024 | - public function set_type( $value ) { |
|
| 2025 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 2026 | - $this->set_prop( 'type', $type ); |
|
| 2024 | + public function set_type($value) { |
|
| 2025 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 2026 | + $this->set_prop('type', $type); |
|
| 2027 | 2027 | } |
| 2028 | 2028 | |
| 2029 | 2029 | /** |
@@ -2032,10 +2032,10 @@ discard block |
||
| 2032 | 2032 | * @since 1.0.19 |
| 2033 | 2033 | * @param string $value Post type. |
| 2034 | 2034 | */ |
| 2035 | - public function set_post_type( $value ) { |
|
| 2036 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 2037 | - $this->set_type( $value ); |
|
| 2038 | - $this->set_prop( 'post_type', $value ); |
|
| 2035 | + public function set_post_type($value) { |
|
| 2036 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 2037 | + $this->set_type($value); |
|
| 2038 | + $this->set_prop('post_type', $value); |
|
| 2039 | 2039 | } |
| 2040 | 2040 | } |
| 2041 | 2041 | |
@@ -2045,9 +2045,9 @@ discard block |
||
| 2045 | 2045 | * @since 1.0.19 |
| 2046 | 2046 | * @param string $value New key. |
| 2047 | 2047 | */ |
| 2048 | - public function set_key( $value ) { |
|
| 2049 | - $key = sanitize_text_field( $value ); |
|
| 2050 | - $this->set_prop( 'key', $key ); |
|
| 2048 | + public function set_key($value) { |
|
| 2049 | + $key = sanitize_text_field($value); |
|
| 2050 | + $this->set_prop('key', $key); |
|
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | 2053 | /** |
@@ -2056,9 +2056,9 @@ discard block |
||
| 2056 | 2056 | * @since 1.0.19 |
| 2057 | 2057 | * @param string $value mode. |
| 2058 | 2058 | */ |
| 2059 | - public function set_mode( $value ) { |
|
| 2060 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2061 | - $this->set_prop( 'value', $value ); |
|
| 2059 | + public function set_mode($value) { |
|
| 2060 | + if (!in_array($value, array('live', 'test'))) { |
|
| 2061 | + $this->set_prop('value', $value); |
|
| 2062 | 2062 | } |
| 2063 | 2063 | } |
| 2064 | 2064 | |
@@ -2068,8 +2068,8 @@ discard block |
||
| 2068 | 2068 | * @since 1.0.19 |
| 2069 | 2069 | * @param string $value path. |
| 2070 | 2070 | */ |
| 2071 | - public function set_path( $value ) { |
|
| 2072 | - $this->set_prop( 'path', $value ); |
|
| 2071 | + public function set_path($value) { |
|
| 2072 | + $this->set_prop('path', $value); |
|
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | 2075 | /** |
@@ -2078,9 +2078,9 @@ discard block |
||
| 2078 | 2078 | * @since 1.0.19 |
| 2079 | 2079 | * @param string $value New name. |
| 2080 | 2080 | */ |
| 2081 | - public function set_name( $value ) { |
|
| 2082 | - $name = sanitize_text_field( $value ); |
|
| 2083 | - $this->set_prop( 'name', $name ); |
|
| 2081 | + public function set_name($value) { |
|
| 2082 | + $name = sanitize_text_field($value); |
|
| 2083 | + $this->set_prop('name', $name); |
|
| 2084 | 2084 | } |
| 2085 | 2085 | |
| 2086 | 2086 | /** |
@@ -2089,8 +2089,8 @@ discard block |
||
| 2089 | 2089 | * @since 1.0.19 |
| 2090 | 2090 | * @param string $value New name. |
| 2091 | 2091 | */ |
| 2092 | - public function set_title( $value ) { |
|
| 2093 | - $this->set_name( $value ); |
|
| 2092 | + public function set_title($value) { |
|
| 2093 | + $this->set_name($value); |
|
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | 2096 | /** |
@@ -2099,9 +2099,9 @@ discard block |
||
| 2099 | 2099 | * @since 1.0.19 |
| 2100 | 2100 | * @param string $value New description. |
| 2101 | 2101 | */ |
| 2102 | - public function set_description( $value ) { |
|
| 2103 | - $description = wp_kses_post( $value ); |
|
| 2104 | - return $this->set_prop( 'description', $description ); |
|
| 2102 | + public function set_description($value) { |
|
| 2103 | + $description = wp_kses_post($value); |
|
| 2104 | + return $this->set_prop('description', $description); |
|
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | 2107 | /** |
@@ -2110,8 +2110,8 @@ discard block |
||
| 2110 | 2110 | * @since 1.0.19 |
| 2111 | 2111 | * @param string $value New description. |
| 2112 | 2112 | */ |
| 2113 | - public function set_excerpt( $value ) { |
|
| 2114 | - $this->set_description( $value ); |
|
| 2113 | + public function set_excerpt($value) { |
|
| 2114 | + $this->set_description($value); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | 2117 | /** |
@@ -2120,8 +2120,8 @@ discard block |
||
| 2120 | 2120 | * @since 1.0.19 |
| 2121 | 2121 | * @param string $value New description. |
| 2122 | 2122 | */ |
| 2123 | - public function set_summary( $value ) { |
|
| 2124 | - $this->set_description( $value ); |
|
| 2123 | + public function set_summary($value) { |
|
| 2124 | + $this->set_description($value); |
|
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | 2127 | /** |
@@ -2130,12 +2130,12 @@ discard block |
||
| 2130 | 2130 | * @since 1.0.19 |
| 2131 | 2131 | * @param int $value New author. |
| 2132 | 2132 | */ |
| 2133 | - public function set_author( $value ) { |
|
| 2134 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2133 | + public function set_author($value) { |
|
| 2134 | + $user = get_user_by('id', (int) $value); |
|
| 2135 | 2135 | |
| 2136 | - if ( $user && $user->ID ) { |
|
| 2137 | - $this->set_prop( 'author', $user->ID ); |
|
| 2138 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2136 | + if ($user && $user->ID) { |
|
| 2137 | + $this->set_prop('author', $user->ID); |
|
| 2138 | + $this->set_prop('email', $user->user_email); |
|
| 2139 | 2139 | } |
| 2140 | 2140 | |
| 2141 | 2141 | } |
@@ -2146,8 +2146,8 @@ discard block |
||
| 2146 | 2146 | * @since 1.0.19 |
| 2147 | 2147 | * @param int $value New user id. |
| 2148 | 2148 | */ |
| 2149 | - public function set_user_id( $value ) { |
|
| 2150 | - $this->set_author( $value ); |
|
| 2149 | + public function set_user_id($value) { |
|
| 2150 | + $this->set_author($value); |
|
| 2151 | 2151 | } |
| 2152 | 2152 | |
| 2153 | 2153 | /** |
@@ -2156,8 +2156,8 @@ discard block |
||
| 2156 | 2156 | * @since 1.0.19 |
| 2157 | 2157 | * @param int $value New user id. |
| 2158 | 2158 | */ |
| 2159 | - public function set_customer_id( $value ) { |
|
| 2160 | - $this->set_author( $value ); |
|
| 2159 | + public function set_customer_id($value) { |
|
| 2160 | + $this->set_author($value); |
|
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | /** |
@@ -2166,8 +2166,8 @@ discard block |
||
| 2166 | 2166 | * @since 1.0.19 |
| 2167 | 2167 | * @param string $value ip address. |
| 2168 | 2168 | */ |
| 2169 | - public function set_ip( $value ) { |
|
| 2170 | - $this->set_prop( 'ip', $value ); |
|
| 2169 | + public function set_ip($value) { |
|
| 2170 | + $this->set_prop('ip', $value); |
|
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | 2173 | /** |
@@ -2176,8 +2176,8 @@ discard block |
||
| 2176 | 2176 | * @since 1.0.19 |
| 2177 | 2177 | * @param string $value ip address. |
| 2178 | 2178 | */ |
| 2179 | - public function set_user_ip( $value ) { |
|
| 2180 | - $this->set_ip( $value ); |
|
| 2179 | + public function set_user_ip($value) { |
|
| 2180 | + $this->set_ip($value); |
|
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | /** |
@@ -2186,8 +2186,8 @@ discard block |
||
| 2186 | 2186 | * @since 1.0.19 |
| 2187 | 2187 | * @param string $value first name. |
| 2188 | 2188 | */ |
| 2189 | - public function set_first_name( $value ) { |
|
| 2190 | - $this->set_prop( 'first_name', $value ); |
|
| 2189 | + public function set_first_name($value) { |
|
| 2190 | + $this->set_prop('first_name', $value); |
|
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | /** |
@@ -2196,8 +2196,8 @@ discard block |
||
| 2196 | 2196 | * @since 1.0.19 |
| 2197 | 2197 | * @param string $value first name. |
| 2198 | 2198 | */ |
| 2199 | - public function set_user_first_name( $value ) { |
|
| 2200 | - $this->set_first_name( $value ); |
|
| 2199 | + public function set_user_first_name($value) { |
|
| 2200 | + $this->set_first_name($value); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | 2203 | /** |
@@ -2206,8 +2206,8 @@ discard block |
||
| 2206 | 2206 | * @since 1.0.19 |
| 2207 | 2207 | * @param string $value first name. |
| 2208 | 2208 | */ |
| 2209 | - public function set_customer_first_name( $value ) { |
|
| 2210 | - $this->set_first_name( $value ); |
|
| 2209 | + public function set_customer_first_name($value) { |
|
| 2210 | + $this->set_first_name($value); |
|
| 2211 | 2211 | } |
| 2212 | 2212 | |
| 2213 | 2213 | /** |
@@ -2216,8 +2216,8 @@ discard block |
||
| 2216 | 2216 | * @since 1.0.19 |
| 2217 | 2217 | * @param string $value last name. |
| 2218 | 2218 | */ |
| 2219 | - public function set_last_name( $value ) { |
|
| 2220 | - $this->set_prop( 'last_name', $value ); |
|
| 2219 | + public function set_last_name($value) { |
|
| 2220 | + $this->set_prop('last_name', $value); |
|
| 2221 | 2221 | } |
| 2222 | 2222 | |
| 2223 | 2223 | /** |
@@ -2226,8 +2226,8 @@ discard block |
||
| 2226 | 2226 | * @since 1.0.19 |
| 2227 | 2227 | * @param string $value last name. |
| 2228 | 2228 | */ |
| 2229 | - public function set_user_last_name( $value ) { |
|
| 2230 | - $this->set_last_name( $value ); |
|
| 2229 | + public function set_user_last_name($value) { |
|
| 2230 | + $this->set_last_name($value); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | /** |
@@ -2236,8 +2236,8 @@ discard block |
||
| 2236 | 2236 | * @since 1.0.19 |
| 2237 | 2237 | * @param string $value last name. |
| 2238 | 2238 | */ |
| 2239 | - public function set_customer_last_name( $value ) { |
|
| 2240 | - $this->set_last_name( $value ); |
|
| 2239 | + public function set_customer_last_name($value) { |
|
| 2240 | + $this->set_last_name($value); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | /** |
@@ -2246,8 +2246,8 @@ discard block |
||
| 2246 | 2246 | * @since 1.0.19 |
| 2247 | 2247 | * @param string $value phone. |
| 2248 | 2248 | */ |
| 2249 | - public function set_phone( $value ) { |
|
| 2250 | - $this->set_prop( 'phone', $value ); |
|
| 2249 | + public function set_phone($value) { |
|
| 2250 | + $this->set_prop('phone', $value); |
|
| 2251 | 2251 | } |
| 2252 | 2252 | |
| 2253 | 2253 | /** |
@@ -2256,8 +2256,8 @@ discard block |
||
| 2256 | 2256 | * @since 1.0.19 |
| 2257 | 2257 | * @param string $value phone. |
| 2258 | 2258 | */ |
| 2259 | - public function set_user_phone( $value ) { |
|
| 2260 | - $this->set_phone( $value ); |
|
| 2259 | + public function set_user_phone($value) { |
|
| 2260 | + $this->set_phone($value); |
|
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | /** |
@@ -2266,8 +2266,8 @@ discard block |
||
| 2266 | 2266 | * @since 1.0.19 |
| 2267 | 2267 | * @param string $value phone. |
| 2268 | 2268 | */ |
| 2269 | - public function set_customer_phone( $value ) { |
|
| 2270 | - $this->set_phone( $value ); |
|
| 2269 | + public function set_customer_phone($value) { |
|
| 2270 | + $this->set_phone($value); |
|
| 2271 | 2271 | } |
| 2272 | 2272 | |
| 2273 | 2273 | /** |
@@ -2276,8 +2276,8 @@ discard block |
||
| 2276 | 2276 | * @since 1.0.19 |
| 2277 | 2277 | * @param string $value phone. |
| 2278 | 2278 | */ |
| 2279 | - public function set_phone_number( $value ) { |
|
| 2280 | - $this->set_phone( $value ); |
|
| 2279 | + public function set_phone_number($value) { |
|
| 2280 | + $this->set_phone($value); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | /** |
@@ -2286,8 +2286,8 @@ discard block |
||
| 2286 | 2286 | * @since 1.0.19 |
| 2287 | 2287 | * @param string $value email address. |
| 2288 | 2288 | */ |
| 2289 | - public function set_email( $value ) { |
|
| 2290 | - $this->set_prop( 'email', $value ); |
|
| 2289 | + public function set_email($value) { |
|
| 2290 | + $this->set_prop('email', $value); |
|
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | 2293 | /** |
@@ -2296,8 +2296,8 @@ discard block |
||
| 2296 | 2296 | * @since 1.0.19 |
| 2297 | 2297 | * @param string $value email address. |
| 2298 | 2298 | */ |
| 2299 | - public function set_user_email( $value ) { |
|
| 2300 | - $this->set_email( $value ); |
|
| 2299 | + public function set_user_email($value) { |
|
| 2300 | + $this->set_email($value); |
|
| 2301 | 2301 | } |
| 2302 | 2302 | |
| 2303 | 2303 | /** |
@@ -2306,8 +2306,8 @@ discard block |
||
| 2306 | 2306 | * @since 1.0.19 |
| 2307 | 2307 | * @param string $value email address. |
| 2308 | 2308 | */ |
| 2309 | - public function set_email_address( $value ) { |
|
| 2310 | - $this->set_email( $value ); |
|
| 2309 | + public function set_email_address($value) { |
|
| 2310 | + $this->set_email($value); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | |
| 2313 | 2313 | /** |
@@ -2316,8 +2316,8 @@ discard block |
||
| 2316 | 2316 | * @since 1.0.19 |
| 2317 | 2317 | * @param string $value email address. |
| 2318 | 2318 | */ |
| 2319 | - public function set_customer_email( $value ) { |
|
| 2320 | - $this->set_email( $value ); |
|
| 2319 | + public function set_customer_email($value) { |
|
| 2320 | + $this->set_email($value); |
|
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | /** |
@@ -2326,8 +2326,8 @@ discard block |
||
| 2326 | 2326 | * @since 1.0.19 |
| 2327 | 2327 | * @param string $value country. |
| 2328 | 2328 | */ |
| 2329 | - public function set_country( $value ) { |
|
| 2330 | - $this->set_prop( 'country', $value ); |
|
| 2329 | + public function set_country($value) { |
|
| 2330 | + $this->set_prop('country', $value); |
|
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | 2333 | /** |
@@ -2336,8 +2336,8 @@ discard block |
||
| 2336 | 2336 | * @since 1.0.19 |
| 2337 | 2337 | * @param string $value country. |
| 2338 | 2338 | */ |
| 2339 | - public function set_user_country( $value ) { |
|
| 2340 | - $this->set_country( $value ); |
|
| 2339 | + public function set_user_country($value) { |
|
| 2340 | + $this->set_country($value); |
|
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | 2343 | /** |
@@ -2346,8 +2346,8 @@ discard block |
||
| 2346 | 2346 | * @since 1.0.19 |
| 2347 | 2347 | * @param string $value country. |
| 2348 | 2348 | */ |
| 2349 | - public function set_customer_country( $value ) { |
|
| 2350 | - $this->set_country( $value ); |
|
| 2349 | + public function set_customer_country($value) { |
|
| 2350 | + $this->set_country($value); |
|
| 2351 | 2351 | } |
| 2352 | 2352 | |
| 2353 | 2353 | /** |
@@ -2356,8 +2356,8 @@ discard block |
||
| 2356 | 2356 | * @since 1.0.19 |
| 2357 | 2357 | * @param string $value state. |
| 2358 | 2358 | */ |
| 2359 | - public function set_state( $value ) { |
|
| 2360 | - $this->set_prop( 'state', $value ); |
|
| 2359 | + public function set_state($value) { |
|
| 2360 | + $this->set_prop('state', $value); |
|
| 2361 | 2361 | } |
| 2362 | 2362 | |
| 2363 | 2363 | /** |
@@ -2366,8 +2366,8 @@ discard block |
||
| 2366 | 2366 | * @since 1.0.19 |
| 2367 | 2367 | * @param string $value state. |
| 2368 | 2368 | */ |
| 2369 | - public function set_user_state( $value ) { |
|
| 2370 | - $this->set_state( $value ); |
|
| 2369 | + public function set_user_state($value) { |
|
| 2370 | + $this->set_state($value); |
|
| 2371 | 2371 | } |
| 2372 | 2372 | |
| 2373 | 2373 | /** |
@@ -2376,8 +2376,8 @@ discard block |
||
| 2376 | 2376 | * @since 1.0.19 |
| 2377 | 2377 | * @param string $value state. |
| 2378 | 2378 | */ |
| 2379 | - public function set_customer_state( $value ) { |
|
| 2380 | - $this->set_state( $value ); |
|
| 2379 | + public function set_customer_state($value) { |
|
| 2380 | + $this->set_state($value); |
|
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | 2383 | /** |
@@ -2386,8 +2386,8 @@ discard block |
||
| 2386 | 2386 | * @since 1.0.19 |
| 2387 | 2387 | * @param string $value city. |
| 2388 | 2388 | */ |
| 2389 | - public function set_city( $value ) { |
|
| 2390 | - $this->set_prop( 'city', $value ); |
|
| 2389 | + public function set_city($value) { |
|
| 2390 | + $this->set_prop('city', $value); |
|
| 2391 | 2391 | } |
| 2392 | 2392 | |
| 2393 | 2393 | /** |
@@ -2396,8 +2396,8 @@ discard block |
||
| 2396 | 2396 | * @since 1.0.19 |
| 2397 | 2397 | * @param string $value city. |
| 2398 | 2398 | */ |
| 2399 | - public function set_user_city( $value ) { |
|
| 2400 | - $this->set_city( $value ); |
|
| 2399 | + public function set_user_city($value) { |
|
| 2400 | + $this->set_city($value); |
|
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | /** |
@@ -2406,8 +2406,8 @@ discard block |
||
| 2406 | 2406 | * @since 1.0.19 |
| 2407 | 2407 | * @param string $value city. |
| 2408 | 2408 | */ |
| 2409 | - public function set_customer_city( $value ) { |
|
| 2410 | - $this->set_city( $value ); |
|
| 2409 | + public function set_customer_city($value) { |
|
| 2410 | + $this->set_city($value); |
|
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | 2413 | /** |
@@ -2416,8 +2416,8 @@ discard block |
||
| 2416 | 2416 | * @since 1.0.19 |
| 2417 | 2417 | * @param string $value zip. |
| 2418 | 2418 | */ |
| 2419 | - public function set_zip( $value ) { |
|
| 2420 | - $this->set_prop( 'zip', $value ); |
|
| 2419 | + public function set_zip($value) { |
|
| 2420 | + $this->set_prop('zip', $value); |
|
| 2421 | 2421 | } |
| 2422 | 2422 | |
| 2423 | 2423 | /** |
@@ -2426,8 +2426,8 @@ discard block |
||
| 2426 | 2426 | * @since 1.0.19 |
| 2427 | 2427 | * @param string $value zip. |
| 2428 | 2428 | */ |
| 2429 | - public function set_user_zip( $value ) { |
|
| 2430 | - $this->set_zip( $value ); |
|
| 2429 | + public function set_user_zip($value) { |
|
| 2430 | + $this->set_zip($value); |
|
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | 2433 | /** |
@@ -2436,8 +2436,8 @@ discard block |
||
| 2436 | 2436 | * @since 1.0.19 |
| 2437 | 2437 | * @param string $value zip. |
| 2438 | 2438 | */ |
| 2439 | - public function set_customer_zip( $value ) { |
|
| 2440 | - $this->set_zip( $value ); |
|
| 2439 | + public function set_customer_zip($value) { |
|
| 2440 | + $this->set_zip($value); |
|
| 2441 | 2441 | } |
| 2442 | 2442 | |
| 2443 | 2443 | /** |
@@ -2446,8 +2446,8 @@ discard block |
||
| 2446 | 2446 | * @since 1.0.19 |
| 2447 | 2447 | * @param string $value company. |
| 2448 | 2448 | */ |
| 2449 | - public function set_company( $value ) { |
|
| 2450 | - $this->set_prop( 'company', $value ); |
|
| 2449 | + public function set_company($value) { |
|
| 2450 | + $this->set_prop('company', $value); |
|
| 2451 | 2451 | } |
| 2452 | 2452 | |
| 2453 | 2453 | /** |
@@ -2456,8 +2456,8 @@ discard block |
||
| 2456 | 2456 | * @since 1.0.19 |
| 2457 | 2457 | * @param string $value company. |
| 2458 | 2458 | */ |
| 2459 | - public function set_user_company( $value ) { |
|
| 2460 | - $this->set_company( $value ); |
|
| 2459 | + public function set_user_company($value) { |
|
| 2460 | + $this->set_company($value); |
|
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | 2463 | /** |
@@ -2466,8 +2466,8 @@ discard block |
||
| 2466 | 2466 | * @since 1.0.19 |
| 2467 | 2467 | * @param string $value company. |
| 2468 | 2468 | */ |
| 2469 | - public function set_customer_company( $value ) { |
|
| 2470 | - $this->set_company( $value ); |
|
| 2469 | + public function set_customer_company($value) { |
|
| 2470 | + $this->set_company($value); |
|
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | 2473 | /** |
@@ -2476,8 +2476,8 @@ discard block |
||
| 2476 | 2476 | * @since 1.0.19 |
| 2477 | 2477 | * @param string $value var number. |
| 2478 | 2478 | */ |
| 2479 | - public function set_vat_number( $value ) { |
|
| 2480 | - $this->set_prop( 'vat_number', $value ); |
|
| 2479 | + public function set_vat_number($value) { |
|
| 2480 | + $this->set_prop('vat_number', $value); |
|
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | 2483 | /** |
@@ -2486,8 +2486,8 @@ discard block |
||
| 2486 | 2486 | * @since 1.0.19 |
| 2487 | 2487 | * @param string $value var number. |
| 2488 | 2488 | */ |
| 2489 | - public function set_user_vat_number( $value ) { |
|
| 2490 | - $this->set_vat_number( $value ); |
|
| 2489 | + public function set_user_vat_number($value) { |
|
| 2490 | + $this->set_vat_number($value); |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | /** |
@@ -2496,8 +2496,8 @@ discard block |
||
| 2496 | 2496 | * @since 1.0.19 |
| 2497 | 2497 | * @param string $value var number. |
| 2498 | 2498 | */ |
| 2499 | - public function set_customer_vat_number( $value ) { |
|
| 2500 | - $this->set_vat_number( $value ); |
|
| 2499 | + public function set_customer_vat_number($value) { |
|
| 2500 | + $this->set_vat_number($value); |
|
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | 2503 | /** |
@@ -2506,8 +2506,8 @@ discard block |
||
| 2506 | 2506 | * @since 1.0.19 |
| 2507 | 2507 | * @param string $value var rate. |
| 2508 | 2508 | */ |
| 2509 | - public function set_vat_rate( $value ) { |
|
| 2510 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2509 | + public function set_vat_rate($value) { |
|
| 2510 | + $this->set_prop('vat_rate', $value); |
|
| 2511 | 2511 | } |
| 2512 | 2512 | |
| 2513 | 2513 | /** |
@@ -2516,8 +2516,8 @@ discard block |
||
| 2516 | 2516 | * @since 1.0.19 |
| 2517 | 2517 | * @param string $value var number. |
| 2518 | 2518 | */ |
| 2519 | - public function set_user_vat_rate( $value ) { |
|
| 2520 | - $this->set_vat_rate( $value ); |
|
| 2519 | + public function set_user_vat_rate($value) { |
|
| 2520 | + $this->set_vat_rate($value); |
|
| 2521 | 2521 | } |
| 2522 | 2522 | |
| 2523 | 2523 | /** |
@@ -2526,8 +2526,8 @@ discard block |
||
| 2526 | 2526 | * @since 1.0.19 |
| 2527 | 2527 | * @param string $value var number. |
| 2528 | 2528 | */ |
| 2529 | - public function set_customer_vat_rate( $value ) { |
|
| 2530 | - $this->set_vat_rate( $value ); |
|
| 2529 | + public function set_customer_vat_rate($value) { |
|
| 2530 | + $this->set_vat_rate($value); |
|
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | 2533 | /** |
@@ -2536,8 +2536,8 @@ discard block |
||
| 2536 | 2536 | * @since 1.0.19 |
| 2537 | 2537 | * @param string $value address. |
| 2538 | 2538 | */ |
| 2539 | - public function set_address( $value ) { |
|
| 2540 | - $this->set_prop( 'address', $value ); |
|
| 2539 | + public function set_address($value) { |
|
| 2540 | + $this->set_prop('address', $value); |
|
| 2541 | 2541 | } |
| 2542 | 2542 | |
| 2543 | 2543 | /** |
@@ -2546,8 +2546,8 @@ discard block |
||
| 2546 | 2546 | * @since 1.0.19 |
| 2547 | 2547 | * @param string $value address. |
| 2548 | 2548 | */ |
| 2549 | - public function set_user_address( $value ) { |
|
| 2550 | - $this->set_address( $value ); |
|
| 2549 | + public function set_user_address($value) { |
|
| 2550 | + $this->set_address($value); |
|
| 2551 | 2551 | } |
| 2552 | 2552 | |
| 2553 | 2553 | /** |
@@ -2556,8 +2556,8 @@ discard block |
||
| 2556 | 2556 | * @since 1.0.19 |
| 2557 | 2557 | * @param string $value address. |
| 2558 | 2558 | */ |
| 2559 | - public function set_customer_address( $value ) { |
|
| 2560 | - $this->set_address( $value ); |
|
| 2559 | + public function set_customer_address($value) { |
|
| 2560 | + $this->set_address($value); |
|
| 2561 | 2561 | } |
| 2562 | 2562 | |
| 2563 | 2563 | /** |
@@ -2566,8 +2566,8 @@ discard block |
||
| 2566 | 2566 | * @since 1.0.19 |
| 2567 | 2567 | * @param int|bool $value confirmed. |
| 2568 | 2568 | */ |
| 2569 | - public function set_is_viewed( $value ) { |
|
| 2570 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2569 | + public function set_is_viewed($value) { |
|
| 2570 | + $this->set_prop('is_viewed', $value); |
|
| 2571 | 2571 | } |
| 2572 | 2572 | |
| 2573 | 2573 | /** |
@@ -2576,8 +2576,8 @@ discard block |
||
| 2576 | 2576 | * @since 1.0.19 |
| 2577 | 2577 | * @param string $value email recipients. |
| 2578 | 2578 | */ |
| 2579 | - public function set_email_cc( $value ) { |
|
| 2580 | - $this->set_prop( 'email_cc', $value ); |
|
| 2579 | + public function set_email_cc($value) { |
|
| 2580 | + $this->set_prop('email_cc', $value); |
|
| 2581 | 2581 | } |
| 2582 | 2582 | |
| 2583 | 2583 | /** |
@@ -2586,9 +2586,9 @@ discard block |
||
| 2586 | 2586 | * @since 1.0.19 |
| 2587 | 2587 | * @param string $value email recipients. |
| 2588 | 2588 | */ |
| 2589 | - public function set_template( $value ) { |
|
| 2590 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2591 | - $this->set_prop( 'template', $value ); |
|
| 2589 | + public function set_template($value) { |
|
| 2590 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2591 | + $this->set_prop('template', $value); |
|
| 2592 | 2592 | } |
| 2593 | 2593 | } |
| 2594 | 2594 | |
@@ -2598,8 +2598,8 @@ discard block |
||
| 2598 | 2598 | * @since 1.0.19 |
| 2599 | 2599 | * @param int|bool $value confirmed. |
| 2600 | 2600 | */ |
| 2601 | - public function set_address_confirmed( $value ) { |
|
| 2602 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2601 | + public function set_address_confirmed($value) { |
|
| 2602 | + $this->set_prop('address_confirmed', $value); |
|
| 2603 | 2603 | } |
| 2604 | 2604 | |
| 2605 | 2605 | /** |
@@ -2608,8 +2608,8 @@ discard block |
||
| 2608 | 2608 | * @since 1.0.19 |
| 2609 | 2609 | * @param int|bool $value confirmed. |
| 2610 | 2610 | */ |
| 2611 | - public function set_user_address_confirmed( $value ) { |
|
| 2612 | - $this->set_address_confirmed( $value ); |
|
| 2611 | + public function set_user_address_confirmed($value) { |
|
| 2612 | + $this->set_address_confirmed($value); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | |
| 2615 | 2615 | /** |
@@ -2618,8 +2618,8 @@ discard block |
||
| 2618 | 2618 | * @since 1.0.19 |
| 2619 | 2619 | * @param int|bool $value confirmed. |
| 2620 | 2620 | */ |
| 2621 | - public function set_customer_address_confirmed( $value ) { |
|
| 2622 | - $this->set_address_confirmed( $value ); |
|
| 2621 | + public function set_customer_address_confirmed($value) { |
|
| 2622 | + $this->set_address_confirmed($value); |
|
| 2623 | 2623 | } |
| 2624 | 2624 | |
| 2625 | 2625 | /** |
@@ -2628,8 +2628,8 @@ discard block |
||
| 2628 | 2628 | * @since 1.0.19 |
| 2629 | 2629 | * @param float $value sub total. |
| 2630 | 2630 | */ |
| 2631 | - public function set_subtotal( $value ) { |
|
| 2632 | - $this->set_prop( 'subtotal', $value ); |
|
| 2631 | + public function set_subtotal($value) { |
|
| 2632 | + $this->set_prop('subtotal', $value); |
|
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | 2635 | /** |
@@ -2638,8 +2638,8 @@ discard block |
||
| 2638 | 2638 | * @since 1.0.19 |
| 2639 | 2639 | * @param float $value discount total. |
| 2640 | 2640 | */ |
| 2641 | - public function set_total_discount( $value ) { |
|
| 2642 | - $this->set_prop( 'total_discount', $value ); |
|
| 2641 | + public function set_total_discount($value) { |
|
| 2642 | + $this->set_prop('total_discount', $value); |
|
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | /** |
@@ -2648,8 +2648,8 @@ discard block |
||
| 2648 | 2648 | * @since 1.0.19 |
| 2649 | 2649 | * @param float $value discount total. |
| 2650 | 2650 | */ |
| 2651 | - public function set_discount( $value ) { |
|
| 2652 | - $this->set_total_discount( $value ); |
|
| 2651 | + public function set_discount($value) { |
|
| 2652 | + $this->set_total_discount($value); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | |
| 2655 | 2655 | /** |
@@ -2658,8 +2658,8 @@ discard block |
||
| 2658 | 2658 | * @since 1.0.19 |
| 2659 | 2659 | * @param float $value tax total. |
| 2660 | 2660 | */ |
| 2661 | - public function set_total_tax( $value ) { |
|
| 2662 | - $this->set_prop( 'total_tax', $value ); |
|
| 2661 | + public function set_total_tax($value) { |
|
| 2662 | + $this->set_prop('total_tax', $value); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | /** |
@@ -2668,8 +2668,8 @@ discard block |
||
| 2668 | 2668 | * @since 1.0.19 |
| 2669 | 2669 | * @param float $value tax total. |
| 2670 | 2670 | */ |
| 2671 | - public function set_tax_total( $value ) { |
|
| 2672 | - $this->set_total_tax( $value ); |
|
| 2671 | + public function set_tax_total($value) { |
|
| 2672 | + $this->set_total_tax($value); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
@@ -2678,8 +2678,8 @@ discard block |
||
| 2678 | 2678 | * @since 1.0.19 |
| 2679 | 2679 | * @param float $value fees total. |
| 2680 | 2680 | */ |
| 2681 | - public function set_total_fees( $value ) { |
|
| 2682 | - $this->set_prop( 'total_fees', $value ); |
|
| 2681 | + public function set_total_fees($value) { |
|
| 2682 | + $this->set_prop('total_fees', $value); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
@@ -2688,8 +2688,8 @@ discard block |
||
| 2688 | 2688 | * @since 1.0.19 |
| 2689 | 2689 | * @param float $value fees total. |
| 2690 | 2690 | */ |
| 2691 | - public function set_fees_total( $value ) { |
|
| 2692 | - $this->set_total_fees( $value ); |
|
| 2691 | + public function set_fees_total($value) { |
|
| 2692 | + $this->set_total_fees($value); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
@@ -2698,18 +2698,18 @@ discard block |
||
| 2698 | 2698 | * @since 1.0.19 |
| 2699 | 2699 | * @param array $value fees. |
| 2700 | 2700 | */ |
| 2701 | - public function set_fees( $value ) { |
|
| 2701 | + public function set_fees($value) { |
|
| 2702 | 2702 | |
| 2703 | - $this->set_prop( 'fees', array() ); |
|
| 2703 | + $this->set_prop('fees', array()); |
|
| 2704 | 2704 | |
| 2705 | 2705 | // Ensure that we have an array. |
| 2706 | - if ( ! is_array( $value ) ) { |
|
| 2706 | + if (!is_array($value)) { |
|
| 2707 | 2707 | return; |
| 2708 | 2708 | } |
| 2709 | 2709 | |
| 2710 | - foreach ( $value as $name => $data ) { |
|
| 2711 | - if ( isset( $data['amount'] ) ) { |
|
| 2712 | - $this->add_fee( $name, $data['amount'], $data['recurring'] ); |
|
| 2710 | + foreach ($value as $name => $data) { |
|
| 2711 | + if (isset($data['amount'])) { |
|
| 2712 | + $this->add_fee($name, $data['amount'], $data['recurring']); |
|
| 2713 | 2713 | } |
| 2714 | 2714 | } |
| 2715 | 2715 | |
@@ -2721,8 +2721,8 @@ discard block |
||
| 2721 | 2721 | * @since 1.0.19 |
| 2722 | 2722 | * @param array $value taxes. |
| 2723 | 2723 | */ |
| 2724 | - public function set_taxes( $value ) { |
|
| 2725 | - $this->set_prop( 'taxes', $value ); |
|
| 2724 | + public function set_taxes($value) { |
|
| 2725 | + $this->set_prop('taxes', $value); |
|
| 2726 | 2726 | } |
| 2727 | 2727 | |
| 2728 | 2728 | /** |
@@ -2731,17 +2731,17 @@ discard block |
||
| 2731 | 2731 | * @since 1.0.19 |
| 2732 | 2732 | * @param array $value discounts. |
| 2733 | 2733 | */ |
| 2734 | - public function set_discounts( $value ) { |
|
| 2735 | - $this->set_prop( 'discounts', array() ); |
|
| 2734 | + public function set_discounts($value) { |
|
| 2735 | + $this->set_prop('discounts', array()); |
|
| 2736 | 2736 | |
| 2737 | 2737 | // Ensure that we have an array. |
| 2738 | - if ( ! is_array( $value ) ) { |
|
| 2738 | + if (!is_array($value)) { |
|
| 2739 | 2739 | return; |
| 2740 | 2740 | } |
| 2741 | 2741 | |
| 2742 | - foreach ( $value as $name => $data ) { |
|
| 2743 | - if ( isset( $data['amount'] ) ) { |
|
| 2744 | - $this->add_discount( $name, $data['amount'], $data['recurring'] ); |
|
| 2742 | + foreach ($value as $name => $data) { |
|
| 2743 | + if (isset($data['amount'])) { |
|
| 2744 | + $this->add_discount($name, $data['amount'], $data['recurring']); |
|
| 2745 | 2745 | } |
| 2746 | 2746 | } |
| 2747 | 2747 | } |
@@ -2752,18 +2752,18 @@ discard block |
||
| 2752 | 2752 | * @since 1.0.19 |
| 2753 | 2753 | * @param GetPaid_Form_Item[] $value items. |
| 2754 | 2754 | */ |
| 2755 | - public function set_items( $value ) { |
|
| 2755 | + public function set_items($value) { |
|
| 2756 | 2756 | |
| 2757 | 2757 | // Remove existing items. |
| 2758 | - $this->set_prop( 'items', array() ); |
|
| 2758 | + $this->set_prop('items', array()); |
|
| 2759 | 2759 | |
| 2760 | 2760 | // Ensure that we have an array. |
| 2761 | - if ( ! is_array( $value ) ) { |
|
| 2761 | + if (!is_array($value)) { |
|
| 2762 | 2762 | return; |
| 2763 | 2763 | } |
| 2764 | 2764 | |
| 2765 | - foreach ( $value as $item ) { |
|
| 2766 | - $this->add_item( $item ); |
|
| 2765 | + foreach ($value as $item) { |
|
| 2766 | + $this->add_item($item); |
|
| 2767 | 2767 | } |
| 2768 | 2768 | |
| 2769 | 2769 | } |
@@ -2774,8 +2774,8 @@ discard block |
||
| 2774 | 2774 | * @since 1.0.19 |
| 2775 | 2775 | * @param int $value payment form. |
| 2776 | 2776 | */ |
| 2777 | - public function set_payment_form( $value ) { |
|
| 2778 | - $this->set_prop( 'payment_form', $value ); |
|
| 2777 | + public function set_payment_form($value) { |
|
| 2778 | + $this->set_prop('payment_form', $value); |
|
| 2779 | 2779 | } |
| 2780 | 2780 | |
| 2781 | 2781 | /** |
@@ -2784,8 +2784,8 @@ discard block |
||
| 2784 | 2784 | * @since 1.0.19 |
| 2785 | 2785 | * @param string $value submission id. |
| 2786 | 2786 | */ |
| 2787 | - public function set_submission_id( $value ) { |
|
| 2788 | - $this->set_prop( 'submission_id', $value ); |
|
| 2787 | + public function set_submission_id($value) { |
|
| 2788 | + $this->set_prop('submission_id', $value); |
|
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | 2791 | /** |
@@ -2794,8 +2794,8 @@ discard block |
||
| 2794 | 2794 | * @since 1.0.19 |
| 2795 | 2795 | * @param string $value discount code. |
| 2796 | 2796 | */ |
| 2797 | - public function set_discount_code( $value ) { |
|
| 2798 | - $this->set_prop( 'discount_code', $value ); |
|
| 2797 | + public function set_discount_code($value) { |
|
| 2798 | + $this->set_prop('discount_code', $value); |
|
| 2799 | 2799 | } |
| 2800 | 2800 | |
| 2801 | 2801 | /** |
@@ -2804,8 +2804,8 @@ discard block |
||
| 2804 | 2804 | * @since 1.0.19 |
| 2805 | 2805 | * @param string $value gateway. |
| 2806 | 2806 | */ |
| 2807 | - public function set_gateway( $value ) { |
|
| 2808 | - $this->set_prop( 'gateway', $value ); |
|
| 2807 | + public function set_gateway($value) { |
|
| 2808 | + $this->set_prop('gateway', $value); |
|
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | 2811 | /** |
@@ -2814,8 +2814,8 @@ discard block |
||
| 2814 | 2814 | * @since 1.0.19 |
| 2815 | 2815 | * @param string $value transaction id. |
| 2816 | 2816 | */ |
| 2817 | - public function set_transaction_id( $value ) { |
|
| 2818 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2817 | + public function set_transaction_id($value) { |
|
| 2818 | + $this->set_prop('transaction_id', $value); |
|
| 2819 | 2819 | } |
| 2820 | 2820 | |
| 2821 | 2821 | /** |
@@ -2824,8 +2824,8 @@ discard block |
||
| 2824 | 2824 | * @since 1.0.19 |
| 2825 | 2825 | * @param string $value currency id. |
| 2826 | 2826 | */ |
| 2827 | - public function set_currency( $value ) { |
|
| 2828 | - $this->set_prop( 'currency', $value ); |
|
| 2827 | + public function set_currency($value) { |
|
| 2828 | + $this->set_prop('currency', $value); |
|
| 2829 | 2829 | } |
| 2830 | 2830 | |
| 2831 | 2831 | /** |
@@ -2834,8 +2834,8 @@ discard block |
||
| 2834 | 2834 | * @since 1.0.19 |
| 2835 | 2835 | * @param bool $value value. |
| 2836 | 2836 | */ |
| 2837 | - public function set_disable_taxes( $value ) { |
|
| 2838 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2837 | + public function set_disable_taxes($value) { |
|
| 2838 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 2839 | 2839 | } |
| 2840 | 2840 | |
| 2841 | 2841 | /** |
@@ -2844,8 +2844,8 @@ discard block |
||
| 2844 | 2844 | * @since 1.0.19 |
| 2845 | 2845 | * @param string $value subscription id. |
| 2846 | 2846 | */ |
| 2847 | - public function set_subscription_id( $value ) { |
|
| 2848 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2847 | + public function set_subscription_id($value) { |
|
| 2848 | + $this->set_prop('subscription_id', $value); |
|
| 2849 | 2849 | } |
| 2850 | 2850 | |
| 2851 | 2851 | /* |
@@ -2862,28 +2862,28 @@ discard block |
||
| 2862 | 2862 | */ |
| 2863 | 2863 | public function is_parent() { |
| 2864 | 2864 | $parent = $this->get_parent_id(); |
| 2865 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 2865 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 2866 | 2866 | } |
| 2867 | 2867 | |
| 2868 | 2868 | /** |
| 2869 | 2869 | * Checks if this is a renewal invoice. |
| 2870 | 2870 | */ |
| 2871 | 2871 | public function is_renewal() { |
| 2872 | - return ! $this->is_parent(); |
|
| 2872 | + return !$this->is_parent(); |
|
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | 2875 | /** |
| 2876 | 2876 | * Checks if this is a recurring invoice. |
| 2877 | 2877 | */ |
| 2878 | 2878 | public function is_recurring() { |
| 2879 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
| 2879 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
| 2880 | 2880 | } |
| 2881 | 2881 | |
| 2882 | 2882 | /** |
| 2883 | 2883 | * Checks if this is a taxable invoice. |
| 2884 | 2884 | */ |
| 2885 | 2885 | public function is_taxable() { |
| 2886 | - return ! $this->get_disable_taxes(); |
|
| 2886 | + return !$this->get_disable_taxes(); |
|
| 2887 | 2887 | } |
| 2888 | 2888 | |
| 2889 | 2889 | /** |
@@ -2894,49 +2894,49 @@ discard block |
||
| 2894 | 2894 | |
| 2895 | 2895 | $requires_vat = false; |
| 2896 | 2896 | |
| 2897 | - if ( $this->country ) { |
|
| 2897 | + if ($this->country) { |
|
| 2898 | 2898 | $wpi_country = $this->country; |
| 2899 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
| 2899 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
| 2900 | 2900 | } |
| 2901 | 2901 | |
| 2902 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
| 2902 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
| 2903 | 2903 | } |
| 2904 | 2904 | |
| 2905 | 2905 | /** |
| 2906 | 2906 | * Checks to see if the invoice requires payment. |
| 2907 | 2907 | */ |
| 2908 | 2908 | public function is_free() { |
| 2909 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
| 2909 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
| 2910 | 2910 | |
| 2911 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2911 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
| 2912 | 2912 | $is_free = false; |
| 2913 | 2913 | } |
| 2914 | 2914 | |
| 2915 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 2915 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 2916 | 2916 | } |
| 2917 | 2917 | |
| 2918 | 2918 | /** |
| 2919 | 2919 | * Checks if the invoice is paid. |
| 2920 | 2920 | */ |
| 2921 | 2921 | public function is_paid() { |
| 2922 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 2923 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 2922 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 2923 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 2924 | 2924 | } |
| 2925 | 2925 | |
| 2926 | 2926 | /** |
| 2927 | 2927 | * Checks if the invoice needs payment. |
| 2928 | 2928 | */ |
| 2929 | 2929 | public function needs_payment() { |
| 2930 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2931 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 2930 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
| 2931 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 2932 | 2932 | } |
| 2933 | 2933 | |
| 2934 | 2934 | /** |
| 2935 | 2935 | * Checks if the invoice is refunded. |
| 2936 | 2936 | */ |
| 2937 | 2937 | public function is_refunded() { |
| 2938 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 2939 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 2938 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 2939 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 2940 | 2940 | } |
| 2941 | 2941 | |
| 2942 | 2942 | /** |
@@ -2944,30 +2944,30 @@ discard block |
||
| 2944 | 2944 | */ |
| 2945 | 2945 | public function is_due() { |
| 2946 | 2946 | $due_date = $this->get_due_date(); |
| 2947 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 2947 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
| 2948 | 2948 | } |
| 2949 | 2949 | |
| 2950 | 2950 | /** |
| 2951 | 2951 | * Checks if the invoice is draft. |
| 2952 | 2952 | */ |
| 2953 | 2953 | public function is_draft() { |
| 2954 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 2954 | + return $this->has_status('draft, auto-draft'); |
|
| 2955 | 2955 | } |
| 2956 | 2956 | |
| 2957 | 2957 | /** |
| 2958 | 2958 | * Checks if the invoice has a given status. |
| 2959 | 2959 | */ |
| 2960 | - public function has_status( $status ) { |
|
| 2961 | - $status = wpinv_parse_list( $status ); |
|
| 2962 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 2960 | + public function has_status($status) { |
|
| 2961 | + $status = wpinv_parse_list($status); |
|
| 2962 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 2963 | 2963 | } |
| 2964 | 2964 | |
| 2965 | 2965 | /** |
| 2966 | 2966 | * Checks if the invoice is of a given type. |
| 2967 | 2967 | */ |
| 2968 | - public function is_type( $type ) { |
|
| 2969 | - $type = wpinv_parse_list( $type ); |
|
| 2970 | - return in_array( $this->get_type(), $type ); |
|
| 2968 | + public function is_type($type) { |
|
| 2969 | + $type = wpinv_parse_list($type); |
|
| 2970 | + return in_array($this->get_type(), $type); |
|
| 2971 | 2971 | } |
| 2972 | 2972 | |
| 2973 | 2973 | /** |
@@ -2999,8 +2999,8 @@ discard block |
||
| 2999 | 2999 | * |
| 3000 | 3000 | */ |
| 3001 | 3001 | public function is_initial_free() { |
| 3002 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 3003 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 3002 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 3003 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 3004 | 3004 | } |
| 3005 | 3005 | |
| 3006 | 3006 | /** |
@@ -3010,11 +3010,11 @@ discard block |
||
| 3010 | 3010 | public function item_has_free_trial() { |
| 3011 | 3011 | |
| 3012 | 3012 | // Ensure we have a recurring item. |
| 3013 | - if ( ! $this->is_recurring() ) { |
|
| 3013 | + if (!$this->is_recurring()) { |
|
| 3014 | 3014 | return false; |
| 3015 | 3015 | } |
| 3016 | 3016 | |
| 3017 | - $item = $this->get_recurring( true ); |
|
| 3017 | + $item = $this->get_recurring(true); |
|
| 3018 | 3018 | return $item->has_free_trial(); |
| 3019 | 3019 | } |
| 3020 | 3020 | |
@@ -3022,7 +3022,7 @@ discard block |
||
| 3022 | 3022 | * Check if the free trial is a result of a discount. |
| 3023 | 3023 | */ |
| 3024 | 3024 | public function is_free_trial_from_discount() { |
| 3025 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3025 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 3026 | 3026 | } |
| 3027 | 3027 | |
| 3028 | 3028 | /** |
@@ -3031,17 +3031,17 @@ discard block |
||
| 3031 | 3031 | public function discount_first_payment_only() { |
| 3032 | 3032 | |
| 3033 | 3033 | $discount_code = $this->get_discount_code(); |
| 3034 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
| 3034 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
| 3035 | 3035 | return true; |
| 3036 | 3036 | } |
| 3037 | 3037 | |
| 3038 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3038 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3039 | 3039 | |
| 3040 | - if ( ! $discount || ! $discount->exists() ) { |
|
| 3040 | + if (!$discount || !$discount->exists()) { |
|
| 3041 | 3041 | return true; |
| 3042 | 3042 | } |
| 3043 | 3043 | |
| 3044 | - return ! $discount->get_is_recurring(); |
|
| 3044 | + return !$discount->get_is_recurring(); |
|
| 3045 | 3045 | } |
| 3046 | 3046 | |
| 3047 | 3047 | /* |
@@ -3059,19 +3059,19 @@ discard block |
||
| 3059 | 3059 | * @param GetPaid_Form_Item $item |
| 3060 | 3060 | * @return WP_Error|Bool |
| 3061 | 3061 | */ |
| 3062 | - public function add_item( $item ) { |
|
| 3062 | + public function add_item($item) { |
|
| 3063 | 3063 | |
| 3064 | 3064 | // Make sure that it is available for purchase. |
| 3065 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3066 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3065 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 3066 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3067 | 3067 | } |
| 3068 | 3068 | |
| 3069 | 3069 | // Do we have a recurring item? |
| 3070 | - if ( $item->is_recurring() ) { |
|
| 3070 | + if ($item->is_recurring()) { |
|
| 3071 | 3071 | |
| 3072 | 3072 | // An invoice can only contain one recurring item. |
| 3073 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3074 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3073 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
| 3074 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
| 3075 | 3075 | } |
| 3076 | 3076 | |
| 3077 | 3077 | $this->recurring_item = $item->get_id(); |
@@ -3082,9 +3082,9 @@ discard block |
||
| 3082 | 3082 | |
| 3083 | 3083 | // Retrieve all items. |
| 3084 | 3084 | $items = $this->get_items(); |
| 3085 | - $items[ (int) $item->get_id() ] = $item; |
|
| 3085 | + $items[(int) $item->get_id()] = $item; |
|
| 3086 | 3086 | |
| 3087 | - $this->set_prop( 'items', $items ); |
|
| 3087 | + $this->set_prop('items', $items); |
|
| 3088 | 3088 | return true; |
| 3089 | 3089 | } |
| 3090 | 3090 | |
@@ -3093,10 +3093,10 @@ discard block |
||
| 3093 | 3093 | * |
| 3094 | 3094 | * @since 1.0.19 |
| 3095 | 3095 | */ |
| 3096 | - public function get_item( $item_id ) { |
|
| 3096 | + public function get_item($item_id) { |
|
| 3097 | 3097 | $items = $this->get_items(); |
| 3098 | 3098 | $item_id = (int) $item_id; |
| 3099 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3099 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
| 3100 | 3100 | } |
| 3101 | 3101 | |
| 3102 | 3102 | /** |
@@ -3104,17 +3104,17 @@ discard block |
||
| 3104 | 3104 | * |
| 3105 | 3105 | * @since 1.0.19 |
| 3106 | 3106 | */ |
| 3107 | - public function remove_item( $item_id ) { |
|
| 3107 | + public function remove_item($item_id) { |
|
| 3108 | 3108 | $items = $this->get_items(); |
| 3109 | 3109 | $item_id = (int) $item_id; |
| 3110 | 3110 | |
| 3111 | - if ( $item_id == $this->recurring_item ) { |
|
| 3111 | + if ($item_id == $this->recurring_item) { |
|
| 3112 | 3112 | $this->recurring_item = null; |
| 3113 | 3113 | } |
| 3114 | 3114 | |
| 3115 | - if ( isset( $items[ $item_id ] ) ) { |
|
| 3116 | - unset( $items[ $item_id ] ); |
|
| 3117 | - $this->set_prop( 'items', $items ); |
|
| 3115 | + if (isset($items[$item_id])) { |
|
| 3116 | + unset($items[$item_id]); |
|
| 3117 | + $this->set_prop('items', $items); |
|
| 3118 | 3118 | } |
| 3119 | 3119 | } |
| 3120 | 3120 | |
@@ -3125,27 +3125,27 @@ discard block |
||
| 3125 | 3125 | * @param float $value |
| 3126 | 3126 | * @return WP_Error|Bool |
| 3127 | 3127 | */ |
| 3128 | - public function add_fee( $fee, $value, $recurring = false ) { |
|
| 3128 | + public function add_fee($fee, $value, $recurring = false) { |
|
| 3129 | 3129 | |
| 3130 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3130 | + $amount = wpinv_sanitize_amount($value); |
|
| 3131 | 3131 | $fees = $this->get_fees(); |
| 3132 | 3132 | |
| 3133 | - if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
|
| 3133 | + if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) { |
|
| 3134 | 3134 | |
| 3135 | - $amount = $fees[ $fee ]['amount'] += $amount; |
|
| 3136 | - $fees[ $fee ] = array( |
|
| 3135 | + $amount = $fees[$fee]['amount'] += $amount; |
|
| 3136 | + $fees[$fee] = array( |
|
| 3137 | 3137 | 'amount' => $amount, |
| 3138 | 3138 | 'recurring' => (bool) $recurring, |
| 3139 | 3139 | ); |
| 3140 | 3140 | |
| 3141 | 3141 | } else { |
| 3142 | - $fees[ $fee ] = array( |
|
| 3142 | + $fees[$fee] = array( |
|
| 3143 | 3143 | 'amount' => $amount, |
| 3144 | 3144 | 'recurring' => (bool) $recurring, |
| 3145 | 3145 | ); |
| 3146 | 3146 | } |
| 3147 | 3147 | |
| 3148 | - $this->set_prop( 'fees', $fee ); |
|
| 3148 | + $this->set_prop('fees', $fee); |
|
| 3149 | 3149 | |
| 3150 | 3150 | } |
| 3151 | 3151 | |
@@ -3154,9 +3154,9 @@ discard block |
||
| 3154 | 3154 | * |
| 3155 | 3155 | * @since 1.0.19 |
| 3156 | 3156 | */ |
| 3157 | - public function get_fee( $fee ) { |
|
| 3157 | + public function get_fee($fee) { |
|
| 3158 | 3158 | $fees = $this->get_fees(); |
| 3159 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3159 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3160 | 3160 | } |
| 3161 | 3161 | |
| 3162 | 3162 | /** |
@@ -3164,11 +3164,11 @@ discard block |
||
| 3164 | 3164 | * |
| 3165 | 3165 | * @since 1.0.19 |
| 3166 | 3166 | */ |
| 3167 | - public function remove_fee( $fee ) { |
|
| 3167 | + public function remove_fee($fee) { |
|
| 3168 | 3168 | $fees = $this->get_fees(); |
| 3169 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3170 | - unset( $fees[ $fee ] ); |
|
| 3171 | - $this->set_prop( 'fees', $fees ); |
|
| 3169 | + if (isset($fees[$fee])) { |
|
| 3170 | + unset($fees[$fee]); |
|
| 3171 | + $this->set_prop('fees', $fees); |
|
| 3172 | 3172 | } |
| 3173 | 3173 | } |
| 3174 | 3174 | |
@@ -3179,27 +3179,27 @@ discard block |
||
| 3179 | 3179 | * @param float $value |
| 3180 | 3180 | * @return WP_Error|Bool |
| 3181 | 3181 | */ |
| 3182 | - public function add_discount( $discount, $value, $recurring = false ) { |
|
| 3182 | + public function add_discount($discount, $value, $recurring = false) { |
|
| 3183 | 3183 | |
| 3184 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3184 | + $amount = wpinv_sanitize_amount($value); |
|
| 3185 | 3185 | $discounts = $this->get_discounts(); |
| 3186 | 3186 | |
| 3187 | - if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
|
| 3187 | + if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) { |
|
| 3188 | 3188 | |
| 3189 | - $amount = $discounts[ $discount ]['amount'] += $amount; |
|
| 3190 | - $discounts[ $discount ] = array( |
|
| 3189 | + $amount = $discounts[$discount]['amount'] += $amount; |
|
| 3190 | + $discounts[$discount] = array( |
|
| 3191 | 3191 | 'amount' => $amount, |
| 3192 | 3192 | 'recurring' => (bool) $recurring, |
| 3193 | 3193 | ); |
| 3194 | 3194 | |
| 3195 | 3195 | } else { |
| 3196 | - $discounts[ $discount ] = array( |
|
| 3196 | + $discounts[$discount] = array( |
|
| 3197 | 3197 | 'amount' => $amount, |
| 3198 | 3198 | 'recurring' => (bool) $recurring, |
| 3199 | 3199 | ); |
| 3200 | 3200 | } |
| 3201 | 3201 | |
| 3202 | - $this->set_prop( 'discounts', $discount ); |
|
| 3202 | + $this->set_prop('discounts', $discount); |
|
| 3203 | 3203 | |
| 3204 | 3204 | } |
| 3205 | 3205 | |
@@ -3208,15 +3208,15 @@ discard block |
||
| 3208 | 3208 | * |
| 3209 | 3209 | * @since 1.0.19 |
| 3210 | 3210 | */ |
| 3211 | - public function get_discount( $discount = false ) { |
|
| 3211 | + public function get_discount($discount = false) { |
|
| 3212 | 3212 | |
| 3213 | 3213 | // Backwards compatibilty. |
| 3214 | - if ( empty( $discount ) ) { |
|
| 3214 | + if (empty($discount)) { |
|
| 3215 | 3215 | return $this->get_total_discount(); |
| 3216 | 3216 | } |
| 3217 | 3217 | |
| 3218 | 3218 | $discounts = $this->get_discounts(); |
| 3219 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3219 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3220 | 3220 | } |
| 3221 | 3221 | |
| 3222 | 3222 | /** |
@@ -3224,11 +3224,11 @@ discard block |
||
| 3224 | 3224 | * |
| 3225 | 3225 | * @since 1.0.19 |
| 3226 | 3226 | */ |
| 3227 | - public function remove_discount( $discount ) { |
|
| 3227 | + public function remove_discount($discount) { |
|
| 3228 | 3228 | $discounts = $this->get_discounts(); |
| 3229 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3230 | - unset( $discounts[ $discount ] ); |
|
| 3231 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3229 | + if (isset($discounts[$discount])) { |
|
| 3230 | + unset($discounts[$discount]); |
|
| 3231 | + $this->set_prop('discounts', $discounts); |
|
| 3232 | 3232 | } |
| 3233 | 3233 | } |
| 3234 | 3234 | |
@@ -3238,31 +3238,31 @@ discard block |
||
| 3238 | 3238 | * @param string $tax |
| 3239 | 3239 | * @param float $value |
| 3240 | 3240 | */ |
| 3241 | - public function add_tax( $tax, $value, $recurring = true ) { |
|
| 3241 | + public function add_tax($tax, $value, $recurring = true) { |
|
| 3242 | 3242 | |
| 3243 | - if ( ! $this->is_taxable() ) { |
|
| 3243 | + if (!$this->is_taxable()) { |
|
| 3244 | 3244 | return; |
| 3245 | 3245 | } |
| 3246 | 3246 | |
| 3247 | - $amount = wpinv_sanitize_amount( $value ); |
|
| 3247 | + $amount = wpinv_sanitize_amount($value); |
|
| 3248 | 3248 | $taxes = $this->get_taxes(); |
| 3249 | 3249 | |
| 3250 | - if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
|
| 3250 | + if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) { |
|
| 3251 | 3251 | |
| 3252 | - $amount = $taxes[ $tax ]['amount'] += $amount; |
|
| 3253 | - $taxes[ $tax ] = array( |
|
| 3252 | + $amount = $taxes[$tax]['amount'] += $amount; |
|
| 3253 | + $taxes[$tax] = array( |
|
| 3254 | 3254 | 'amount' => $amount, |
| 3255 | 3255 | 'recurring' => (bool) $recurring, |
| 3256 | 3256 | ); |
| 3257 | 3257 | |
| 3258 | 3258 | } else { |
| 3259 | - $taxes[ $tax ] = array( |
|
| 3259 | + $taxes[$tax] = array( |
|
| 3260 | 3260 | 'amount' => $amount, |
| 3261 | 3261 | 'recurring' => (bool) $recurring, |
| 3262 | 3262 | ); |
| 3263 | 3263 | } |
| 3264 | 3264 | |
| 3265 | - $this->set_prop( 'taxes', $tax ); |
|
| 3265 | + $this->set_prop('taxes', $tax); |
|
| 3266 | 3266 | |
| 3267 | 3267 | } |
| 3268 | 3268 | |
@@ -3271,15 +3271,15 @@ discard block |
||
| 3271 | 3271 | * |
| 3272 | 3272 | * @since 1.0.19 |
| 3273 | 3273 | */ |
| 3274 | - public function get_tax( $tax = null ) { |
|
| 3274 | + public function get_tax($tax = null) { |
|
| 3275 | 3275 | |
| 3276 | 3276 | // Backwards compatility. |
| 3277 | - if ( empty( $tax ) ) { |
|
| 3277 | + if (empty($tax)) { |
|
| 3278 | 3278 | return $this->get_total_tax(); |
| 3279 | 3279 | } |
| 3280 | 3280 | |
| 3281 | 3281 | $taxes = $this->get_taxes(); |
| 3282 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3282 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3283 | 3283 | } |
| 3284 | 3284 | |
| 3285 | 3285 | /** |
@@ -3287,11 +3287,11 @@ discard block |
||
| 3287 | 3287 | * |
| 3288 | 3288 | * @since 1.0.19 |
| 3289 | 3289 | */ |
| 3290 | - public function remove_tax( $tax ) { |
|
| 3290 | + public function remove_tax($tax) { |
|
| 3291 | 3291 | $taxes = $this->get_discounts(); |
| 3292 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3293 | - unset( $taxes[ $tax ] ); |
|
| 3294 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3292 | + if (isset($taxes[$tax])) { |
|
| 3293 | + unset($taxes[$tax]); |
|
| 3294 | + $this->set_prop('taxes', $taxes); |
|
| 3295 | 3295 | } |
| 3296 | 3296 | } |
| 3297 | 3297 | |
@@ -3302,19 +3302,19 @@ discard block |
||
| 3302 | 3302 | * @return float The recalculated subtotal |
| 3303 | 3303 | */ |
| 3304 | 3304 | public function recalculate_subtotal() { |
| 3305 | - $items = $this->get_items(); |
|
| 3305 | + $items = $this->get_items(); |
|
| 3306 | 3306 | $subtotal = 0; |
| 3307 | 3307 | $recurring = 0; |
| 3308 | 3308 | |
| 3309 | - foreach ( $items as $item ) { |
|
| 3309 | + foreach ($items as $item) { |
|
| 3310 | 3310 | $subtotal += $item->get_sub_total(); |
| 3311 | 3311 | $recurring += $item->get_recurring_sub_total(); |
| 3312 | 3312 | } |
| 3313 | 3313 | |
| 3314 | - if ( $this->is_renewal() ) { |
|
| 3315 | - $this->set_subtotal( $recurring ); |
|
| 3314 | + if ($this->is_renewal()) { |
|
| 3315 | + $this->set_subtotal($recurring); |
|
| 3316 | 3316 | } else { |
| 3317 | - $this->set_subtotal( $subtotal ); |
|
| 3317 | + $this->set_subtotal($subtotal); |
|
| 3318 | 3318 | } |
| 3319 | 3319 | |
| 3320 | 3320 | $this->totals['subtotal'] = array( |
@@ -3336,9 +3336,9 @@ discard block |
||
| 3336 | 3336 | $discount = 0; |
| 3337 | 3337 | $recurring = 0; |
| 3338 | 3338 | |
| 3339 | - foreach ( $discounts as $data ) { |
|
| 3339 | + foreach ($discounts as $data) { |
|
| 3340 | 3340 | |
| 3341 | - if ( $data['recurring'] ) { |
|
| 3341 | + if ($data['recurring']) { |
|
| 3342 | 3342 | $recurring += $data['amount']; |
| 3343 | 3343 | } else { |
| 3344 | 3344 | $discount += $data['amount']; |
@@ -3346,10 +3346,10 @@ discard block |
||
| 3346 | 3346 | |
| 3347 | 3347 | } |
| 3348 | 3348 | |
| 3349 | - if ( $this->is_renewal() ) { |
|
| 3350 | - $this->set_total_discount( $recurring ); |
|
| 3349 | + if ($this->is_renewal()) { |
|
| 3350 | + $this->set_total_discount($recurring); |
|
| 3351 | 3351 | } else { |
| 3352 | - $this->set_total_discount( $discount ); |
|
| 3352 | + $this->set_total_discount($discount); |
|
| 3353 | 3353 | } |
| 3354 | 3354 | |
| 3355 | 3355 | $this->totals['discount'] = array( |
@@ -3368,13 +3368,13 @@ discard block |
||
| 3368 | 3368 | * @return float The recalculated tax |
| 3369 | 3369 | */ |
| 3370 | 3370 | public function recalculate_total_tax() { |
| 3371 | - $taxes = $this->get_taxes(); |
|
| 3371 | + $taxes = $this->get_taxes(); |
|
| 3372 | 3372 | $tax = 0; |
| 3373 | 3373 | $recurring = 0; |
| 3374 | 3374 | |
| 3375 | - foreach ( $taxes as $data ) { |
|
| 3375 | + foreach ($taxes as $data) { |
|
| 3376 | 3376 | |
| 3377 | - if ( $data['recurring'] ) { |
|
| 3377 | + if ($data['recurring']) { |
|
| 3378 | 3378 | $recurring += $data['amount']; |
| 3379 | 3379 | } else { |
| 3380 | 3380 | $tax += $data['amount']; |
@@ -3382,10 +3382,10 @@ discard block |
||
| 3382 | 3382 | |
| 3383 | 3383 | } |
| 3384 | 3384 | |
| 3385 | - if ( $this->is_renewal() ) { |
|
| 3386 | - $this->set_total_tax( $recurring ); |
|
| 3385 | + if ($this->is_renewal()) { |
|
| 3386 | + $this->set_total_tax($recurring); |
|
| 3387 | 3387 | } else { |
| 3388 | - $this->set_total_tax( $tax ); |
|
| 3388 | + $this->set_total_tax($tax); |
|
| 3389 | 3389 | } |
| 3390 | 3390 | |
| 3391 | 3391 | $this->totals['tax'] = array( |
@@ -3408,9 +3408,9 @@ discard block |
||
| 3408 | 3408 | $fee = 0; |
| 3409 | 3409 | $recurring = 0; |
| 3410 | 3410 | |
| 3411 | - foreach ( $fees as $data ) { |
|
| 3411 | + foreach ($fees as $data) { |
|
| 3412 | 3412 | |
| 3413 | - if ( $data['recurring'] ) { |
|
| 3413 | + if ($data['recurring']) { |
|
| 3414 | 3414 | $recurring += $data['amount']; |
| 3415 | 3415 | } else { |
| 3416 | 3416 | $fee += $data['amount']; |
@@ -3418,10 +3418,10 @@ discard block |
||
| 3418 | 3418 | |
| 3419 | 3419 | } |
| 3420 | 3420 | |
| 3421 | - if ( $this->is_renewal() ) { |
|
| 3422 | - $this->set_total_fees( $recurring ); |
|
| 3421 | + if ($this->is_renewal()) { |
|
| 3422 | + $this->set_total_fees($recurring); |
|
| 3423 | 3423 | } else { |
| 3424 | - $this->set_total_fees( $fee ); |
|
| 3424 | + $this->set_total_fees($fee); |
|
| 3425 | 3425 | } |
| 3426 | 3426 | |
| 3427 | 3427 | $this->totals['fee'] = array( |
@@ -3429,7 +3429,7 @@ discard block |
||
| 3429 | 3429 | 'recurring' => $recurring, |
| 3430 | 3430 | ); |
| 3431 | 3431 | |
| 3432 | - $this->set_total_fees( $fee ); |
|
| 3432 | + $this->set_total_fees($fee); |
|
| 3433 | 3433 | return $this->is_renewal() ? $recurring : $fee; |
| 3434 | 3434 | } |
| 3435 | 3435 | |
@@ -3450,9 +3450,9 @@ discard block |
||
| 3450 | 3450 | /** |
| 3451 | 3451 | * @deprecated |
| 3452 | 3452 | */ |
| 3453 | - public function recalculate_totals( $temp = false ) { |
|
| 3454 | - $this->update_items( $temp ); |
|
| 3455 | - $this->save( true ); |
|
| 3453 | + public function recalculate_totals($temp = false) { |
|
| 3454 | + $this->update_items($temp); |
|
| 3455 | + $this->save(true); |
|
| 3456 | 3456 | return $this; |
| 3457 | 3457 | } |
| 3458 | 3458 | |
@@ -3469,33 +3469,33 @@ discard block |
||
| 3469 | 3469 | * @param string $note The note being added. |
| 3470 | 3470 | * |
| 3471 | 3471 | */ |
| 3472 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3472 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3473 | 3473 | |
| 3474 | 3474 | // Bail if no note specified or this invoice is not yet saved. |
| 3475 | - if ( ! $note || $this->get_id() == 0 ) { |
|
| 3475 | + if (!$note || $this->get_id() == 0) { |
|
| 3476 | 3476 | return false; |
| 3477 | 3477 | } |
| 3478 | 3478 | |
| 3479 | - if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) { |
|
| 3480 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3479 | + if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) { |
|
| 3480 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3481 | 3481 | $comment_author = $user->display_name; |
| 3482 | 3482 | $comment_author_email = $user->user_email; |
| 3483 | 3483 | } else { |
| 3484 | 3484 | $comment_author = 'System'; |
| 3485 | 3485 | $comment_author_email = 'system@'; |
| 3486 | - $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com'; |
|
| 3487 | - $comment_author_email = sanitize_email( $comment_author_email ); |
|
| 3486 | + $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com'; |
|
| 3487 | + $comment_author_email = sanitize_email($comment_author_email); |
|
| 3488 | 3488 | } |
| 3489 | 3489 | |
| 3490 | - do_action( 'wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type ); |
|
| 3490 | + do_action('wpinv_pre_insert_invoice_note', $this->get_id(), $note, $customer_type); |
|
| 3491 | 3491 | |
| 3492 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 3492 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 3493 | 3493 | 'comment_post_ID' => $this->get_id(), |
| 3494 | 3494 | 'comment_content' => $note, |
| 3495 | 3495 | 'comment_agent' => 'GetPaid', |
| 3496 | 3496 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 3497 | - 'comment_date' => current_time( 'mysql' ), |
|
| 3498 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 3497 | + 'comment_date' => current_time('mysql'), |
|
| 3498 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 3499 | 3499 | 'comment_approved' => 1, |
| 3500 | 3500 | 'comment_parent' => 0, |
| 3501 | 3501 | 'comment_author' => $comment_author, |
@@ -3503,13 +3503,13 @@ discard block |
||
| 3503 | 3503 | 'comment_author_url' => '', |
| 3504 | 3504 | 'comment_author_email' => $comment_author_email, |
| 3505 | 3505 | 'comment_type' => 'wpinv_note' |
| 3506 | - ) ) ); |
|
| 3506 | + ))); |
|
| 3507 | 3507 | |
| 3508 | - do_action( 'wpinv_insert_payment_note', $note_id, $this->get_id(), $note ); |
|
| 3508 | + do_action('wpinv_insert_payment_note', $note_id, $this->get_id(), $note); |
|
| 3509 | 3509 | |
| 3510 | - if ( $customer_type ) { |
|
| 3511 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 3512 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->get_id(), 'user_note' => $note ) ); |
|
| 3510 | + if ($customer_type) { |
|
| 3511 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
| 3512 | + do_action('wpinv_new_customer_note', array('invoice_id' => $this->get_id(), 'user_note' => $note)); |
|
| 3513 | 3513 | } |
| 3514 | 3514 | |
| 3515 | 3515 | return $note_id; |
@@ -3518,10 +3518,10 @@ discard block |
||
| 3518 | 3518 | /** |
| 3519 | 3519 | * Generates a unique key for the invoice. |
| 3520 | 3520 | */ |
| 3521 | - public function generate_key( $string = '' ) { |
|
| 3522 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3521 | + public function generate_key($string = '') { |
|
| 3522 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3523 | 3523 | return strtolower( |
| 3524 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3524 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3525 | 3525 | ); |
| 3526 | 3526 | } |
| 3527 | 3527 | |
@@ -3531,11 +3531,11 @@ discard block |
||
| 3531 | 3531 | public function generate_number() { |
| 3532 | 3532 | $number = $this->get_id(); |
| 3533 | 3533 | |
| 3534 | - if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) { |
|
| 3535 | - $number = wpinv_get_next_invoice_number( $this->post_type ); |
|
| 3534 | + if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) { |
|
| 3535 | + $number = wpinv_get_next_invoice_number($this->post_type); |
|
| 3536 | 3536 | } |
| 3537 | 3537 | |
| 3538 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 3538 | + $number = wpinv_format_invoice_number($number, $this->post_type); |
|
| 3539 | 3539 | |
| 3540 | 3540 | return $number; |
| 3541 | 3541 | } |
@@ -3549,47 +3549,47 @@ discard block |
||
| 3549 | 3549 | // Reset status transition variable. |
| 3550 | 3550 | $this->status_transition = false; |
| 3551 | 3551 | |
| 3552 | - if ( $status_transition ) { |
|
| 3552 | + if ($status_transition) { |
|
| 3553 | 3553 | try { |
| 3554 | 3554 | |
| 3555 | 3555 | // Fire a hook for the status change. |
| 3556 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 3556 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
| 3557 | 3557 | |
| 3558 | 3558 | // @deprecated this is deprecated and will be removed in the future. |
| 3559 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3559 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3560 | 3560 | |
| 3561 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3561 | + if (!empty($status_transition['from'])) { |
|
| 3562 | 3562 | |
| 3563 | 3563 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3564 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3564 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
| 3565 | 3565 | |
| 3566 | 3566 | // Fire another hook. |
| 3567 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 3568 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
| 3567 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
| 3568 | + do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this); |
|
| 3569 | 3569 | |
| 3570 | 3570 | // @deprecated this is deprecated and will be removed in the future. |
| 3571 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3571 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3572 | 3572 | |
| 3573 | 3573 | // Note the transition occurred. |
| 3574 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3574 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3575 | 3575 | |
| 3576 | 3576 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3577 | 3577 | if ( |
| 3578 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
| 3579 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3578 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true) |
|
| 3579 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3580 | 3580 | ) { |
| 3581 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
| 3581 | + do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition); |
|
| 3582 | 3582 | } |
| 3583 | 3583 | } else { |
| 3584 | 3584 | /* translators: %s: new invoice status */ |
| 3585 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3585 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
| 3586 | 3586 | |
| 3587 | 3587 | // Note the transition occurred. |
| 3588 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3588 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3589 | 3589 | |
| 3590 | 3590 | } |
| 3591 | - } catch ( Exception $e ) { |
|
| 3592 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3591 | + } catch (Exception $e) { |
|
| 3592 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3593 | 3593 | } |
| 3594 | 3594 | } |
| 3595 | 3595 | } |
@@ -3597,13 +3597,13 @@ discard block |
||
| 3597 | 3597 | /** |
| 3598 | 3598 | * Updates an invoice status. |
| 3599 | 3599 | */ |
| 3600 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3600 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3601 | 3601 | |
| 3602 | 3602 | // Fires before updating a status. |
| 3603 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3603 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3604 | 3604 | |
| 3605 | 3605 | // Update the status. |
| 3606 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3606 | + $this->set_status($new_status, $note, $manual); |
|
| 3607 | 3607 | |
| 3608 | 3608 | // Save the order. |
| 3609 | 3609 | return $this->save(); |
@@ -3614,18 +3614,18 @@ discard block |
||
| 3614 | 3614 | * @deprecated |
| 3615 | 3615 | */ |
| 3616 | 3616 | public function refresh_item_ids() { |
| 3617 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
| 3618 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3617 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
| 3618 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3619 | 3619 | } |
| 3620 | 3620 | |
| 3621 | 3621 | /** |
| 3622 | 3622 | * @deprecated |
| 3623 | 3623 | */ |
| 3624 | - public function update_items( $temp = false ) { |
|
| 3624 | + public function update_items($temp = false) { |
|
| 3625 | 3625 | |
| 3626 | - $this->set_items( $this->get_items() ); |
|
| 3626 | + $this->set_items($this->get_items()); |
|
| 3627 | 3627 | |
| 3628 | - if ( ! $temp ) { |
|
| 3628 | + if (!$temp) { |
|
| 3629 | 3629 | $this->save(); |
| 3630 | 3630 | } |
| 3631 | 3631 | |
@@ -3639,11 +3639,11 @@ discard block |
||
| 3639 | 3639 | |
| 3640 | 3640 | $discount_code = $this->get_discount_code(); |
| 3641 | 3641 | |
| 3642 | - if ( empty( $discount_code ) ) { |
|
| 3642 | + if (empty($discount_code)) { |
|
| 3643 | 3643 | return false; |
| 3644 | 3644 | } |
| 3645 | 3645 | |
| 3646 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3646 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3647 | 3647 | |
| 3648 | 3648 | // Ensure it is active. |
| 3649 | 3649 | return $discount->exists(); |
@@ -3654,7 +3654,7 @@ discard block |
||
| 3654 | 3654 | * Refunds an invoice. |
| 3655 | 3655 | */ |
| 3656 | 3656 | public function refund() { |
| 3657 | - $this->set_status( 'wpi-refunded' ); |
|
| 3657 | + $this->set_status('wpi-refunded'); |
|
| 3658 | 3658 | $this->save(); |
| 3659 | 3659 | } |
| 3660 | 3660 | |
@@ -3663,56 +3663,56 @@ discard block |
||
| 3663 | 3663 | * |
| 3664 | 3664 | * @param string $transaction_id |
| 3665 | 3665 | */ |
| 3666 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
| 3666 | + public function mark_paid($transaction_id = null, $note = '') { |
|
| 3667 | 3667 | |
| 3668 | 3668 | // Set the transaction id. |
| 3669 | - if ( empty( $transaction_id ) ) { |
|
| 3669 | + if (empty($transaction_id)) { |
|
| 3670 | 3670 | $transaction_id = $this->generate_key('trans_'); |
| 3671 | 3671 | } |
| 3672 | 3672 | |
| 3673 | - if ( ! $this->get_transaction_id() ) { |
|
| 3674 | - $this->set_transaction_id( $transaction_id ); |
|
| 3673 | + if (!$this->get_transaction_id()) { |
|
| 3674 | + $this->set_transaction_id($transaction_id); |
|
| 3675 | 3675 | } |
| 3676 | 3676 | |
| 3677 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3677 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
| 3678 | 3678 | return $this->save(); |
| 3679 | 3679 | } |
| 3680 | 3680 | |
| 3681 | 3681 | // Set the completed date. |
| 3682 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3682 | + $this->set_date_completed(current_time('mysql')); |
|
| 3683 | 3683 | |
| 3684 | 3684 | // Set the new status. |
| 3685 | - if ( $this->is_renewal() ) { |
|
| 3685 | + if ($this->is_renewal()) { |
|
| 3686 | 3686 | |
| 3687 | 3687 | $_note = sprintf( |
| 3688 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3689 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3688 | + __('Renewed via %s', 'invoicing'), |
|
| 3689 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3690 | 3690 | ); |
| 3691 | 3691 | |
| 3692 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3692 | + if ('none' == $this->get_gateway()) { |
|
| 3693 | 3693 | $_note = $note; |
| 3694 | 3694 | } |
| 3695 | 3695 | |
| 3696 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3696 | + $this->set_status('wpi-renewal', $_note); |
|
| 3697 | 3697 | |
| 3698 | 3698 | } else { |
| 3699 | 3699 | |
| 3700 | 3700 | $_note = sprintf( |
| 3701 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3702 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3701 | + __('Paid via %s', 'invoicing'), |
|
| 3702 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3703 | 3703 | ); |
| 3704 | 3704 | |
| 3705 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3705 | + if ('none' == $this->get_gateway()) { |
|
| 3706 | 3706 | $_note = $note; |
| 3707 | 3707 | } |
| 3708 | 3708 | |
| 3709 | - $this->set_status( 'publish',$_note ); |
|
| 3709 | + $this->set_status('publish', $_note); |
|
| 3710 | 3710 | |
| 3711 | 3711 | } |
| 3712 | 3712 | |
| 3713 | 3713 | // Set checkout mode. |
| 3714 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3715 | - $this->set_mode( $mode ); |
|
| 3714 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
| 3715 | + $this->set_mode($mode); |
|
| 3716 | 3716 | |
| 3717 | 3717 | // Save the invoice. |
| 3718 | 3718 | $this->save(); |
@@ -96,13 +96,13 @@ discard block |
||
| 96 | 96 | * @return array |
| 97 | 97 | */ |
| 98 | 98 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
| 99 | - $invoice_statuses = array( |
|
| 100 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
| 99 | + $invoice_statuses = array( |
|
| 100 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
| 101 | 101 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
| 102 | 102 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
| 103 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
| 104 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 105 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 103 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
| 104 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 105 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 106 | 106 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
| 107 | 107 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
| 108 | 108 | ); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 118 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | function wpinv_status_nicename( $status ) { |
@@ -712,13 +712,13 @@ discard block |
||
| 712 | 712 | * @param mixed $value Value. |
| 713 | 713 | */ |
| 714 | 714 | function getpaid_maybe_define_constant( $name, $value ) { |
| 715 | - if ( ! defined( $name ) ) { |
|
| 716 | - define( $name, $value ); |
|
| 717 | - } |
|
| 715 | + if ( ! defined( $name ) ) { |
|
| 716 | + define( $name, $value ); |
|
| 717 | + } |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | function wpinv_get_php_arg_separator_output() { |
| 721 | - return ini_get( 'arg_separator.output' ); |
|
| 721 | + return ini_get( 'arg_separator.output' ); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | function wpinv_rgb_from_hex( $color ) { |
@@ -1067,11 +1067,11 @@ discard block |
||
| 1067 | 1067 | $list = array(); |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - if ( ! is_array( $list ) ) { |
|
| 1071 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 1072 | - } |
|
| 1070 | + if ( ! is_array( $list ) ) { |
|
| 1071 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 1072 | + } |
|
| 1073 | 1073 | |
| 1074 | - return $list; |
|
| 1074 | + return $list; |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1091,9 +1091,9 @@ discard block |
||
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
| 1094 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
| 1094 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
| 1095 | 1095 | |
| 1096 | - return $data; |
|
| 1096 | + return $data; |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | /** |
@@ -1122,17 +1122,17 @@ discard block |
||
| 1122 | 1122 | */ |
| 1123 | 1123 | function wpinv_clean( $var ) { |
| 1124 | 1124 | |
| 1125 | - if ( is_array( $var ) ) { |
|
| 1126 | - return array_map( 'wpinv_clean', $var ); |
|
| 1125 | + if ( is_array( $var ) ) { |
|
| 1126 | + return array_map( 'wpinv_clean', $var ); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | if ( is_object( $var ) ) { |
| 1130 | - $object_vars = get_object_vars( $var ); |
|
| 1131 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 1132 | - $var->$property_name = wpinv_clean( $property_value ); |
|
| 1130 | + $object_vars = get_object_vars( $var ); |
|
| 1131 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
| 1132 | + $var->$property_name = wpinv_clean( $property_value ); |
|
| 1133 | 1133 | } |
| 1134 | 1134 | return $var; |
| 1135 | - } |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | 1137 | return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
| 1138 | 1138 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | */ |
| 1146 | 1146 | function getpaid_convert_price_string_to_options( $str ) { |
| 1147 | 1147 | |
| 1148 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 1148 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 1149 | 1149 | $options = array(); |
| 1150 | 1150 | |
| 1151 | 1151 | foreach ( $raw_options as $option ) { |
@@ -1218,15 +1218,15 @@ discard block |
||
| 1218 | 1218 | function getpaid_limit_length( $string, $limit ) { |
| 1219 | 1219 | $str_limit = $limit - 3; |
| 1220 | 1220 | |
| 1221 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 1222 | - if ( mb_strlen( $string ) > $limit ) { |
|
| 1223 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
| 1224 | - } |
|
| 1225 | - } else { |
|
| 1226 | - if ( strlen( $string ) > $limit ) { |
|
| 1227 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
| 1228 | - } |
|
| 1229 | - } |
|
| 1221 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 1222 | + if ( mb_strlen( $string ) > $limit ) { |
|
| 1223 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
| 1224 | + } |
|
| 1225 | + } else { |
|
| 1226 | + if ( strlen( $string ) > $limit ) { |
|
| 1227 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
| 1228 | + } |
|
| 1229 | + } |
|
| 1230 | 1230 | return $string; |
| 1231 | 1231 | |
| 1232 | 1232 | } |
@@ -7,86 +7,86 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function wpinv_item_quantities_enabled() { |
| 15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
| 15 | + $ret = wpinv_get_option('item_quantities', true); |
|
| 16 | 16 | |
| 17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
| 17 | + return (bool) apply_filters('wpinv_item_quantities_enabled', $ret); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function wpinv_get_ip() { |
| 21 | 21 | $ip = '127.0.0.1'; |
| 22 | 22 | |
| 23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
| 25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
| 27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
| 23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
| 25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
| 28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
| 31 | + return apply_filters('wpinv_get_ip', $ip); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function wpinv_get_user_agent() { |
| 35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
| 35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
| 37 | 37 | } else { |
| 38 | 38 | $user_agent = ''; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
| 41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
| 44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
| 45 | 45 | $is_negative = false; |
| 46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
| 47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
| 48 | - if ( $decimals === NULL ) { |
|
| 48 | + if ($decimals === NULL) { |
|
| 49 | 49 | $decimals = wpinv_decimals(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Sanitize the amount |
| 53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
| 57 | - $amount = str_replace( '.', '', $amount ); |
|
| 53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
| 54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
| 57 | + $amount = str_replace('.', '', $amount); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
| 61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
| 61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if( $amount < 0 ) { |
|
| 65 | + if ($amount < 0) { |
|
| 66 | 66 | $is_negative = true; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
| 69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
| 70 | 70 | |
| 71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
| 72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
| 71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
| 72 | + $amount = number_format((double) $amount, absint($decimals), '.', ''); |
|
| 73 | 73 | |
| 74 | - if( $is_negative ) { |
|
| 74 | + if ($is_negative) { |
|
| 75 | 75 | $amount *= -1; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
| 78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
| 79 | 79 | } |
| 80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 81 | 81 | |
| 82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
| 83 | - if ( $decimals === NULL ) { |
|
| 82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
| 83 | + if ($decimals === NULL) { |
|
| 84 | 84 | $decimals = wpinv_decimals(); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
| 87 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
| 89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,48 +95,48 @@ discard block |
||
| 95 | 95 | * @since 1.0.19 |
| 96 | 96 | * @return array |
| 97 | 97 | */ |
| 98 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
| 98 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
| 99 | 99 | $invoice_statuses = array( |
| 100 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
| 101 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
| 102 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 103 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
| 104 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 105 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 106 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 107 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
| 100 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
| 101 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
| 102 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
| 103 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
| 104 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
| 105 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
| 106 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
| 107 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | - if ( $draft ) { |
|
| 111 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
| 110 | + if ($draft) { |
|
| 111 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ( $trashed ) { |
|
| 115 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
| 114 | + if ($trashed) { |
|
| 115 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 118 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -function wpinv_status_nicename( $status ) { |
|
| 122 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
| 123 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
| 121 | +function wpinv_status_nicename($status) { |
|
| 122 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
| 123 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
| 124 | 124 | |
| 125 | 125 | return $status; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | function wpinv_get_currency() { |
| 129 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
| 129 | + $currency = wpinv_get_option('currency', 'USD'); |
|
| 130 | 130 | |
| 131 | - return apply_filters( 'wpinv_currency', $currency ); |
|
| 131 | + return apply_filters('wpinv_currency', $currency); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -function wpinv_currency_symbol( $currency = '' ) { |
|
| 135 | - if ( empty( $currency ) ) { |
|
| 134 | +function wpinv_currency_symbol($currency = '') { |
|
| 135 | + if (empty($currency)) { |
|
| 136 | 136 | $currency = wpinv_get_currency(); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
| 139 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
| 140 | 140 | 'AED' => 'د.إ', |
| 141 | 141 | 'AFN' => '؋', |
| 142 | 142 | 'ALL' => 'L', |
@@ -299,209 +299,209 @@ discard block |
||
| 299 | 299 | 'YER' => '﷼', |
| 300 | 300 | 'ZAR' => 'R', |
| 301 | 301 | 'ZMW' => 'ZK', |
| 302 | - ) ); |
|
| 302 | + )); |
|
| 303 | 303 | |
| 304 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
| 304 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
| 305 | 305 | |
| 306 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
| 306 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | function wpinv_currency_position() { |
| 310 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
| 310 | + $position = wpinv_get_option('currency_position', 'left'); |
|
| 311 | 311 | |
| 312 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
| 312 | + return apply_filters('wpinv_currency_position', $position); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | function wpinv_thousands_separator() { |
| 316 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
| 316 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
| 317 | 317 | |
| 318 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
| 318 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | function wpinv_decimal_separator() { |
| 322 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
| 322 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
| 323 | 323 | |
| 324 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
| 324 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | function wpinv_decimals() { |
| 328 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
| 328 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
| 329 | 329 | |
| 330 | - return absint( $decimals ); |
|
| 330 | + return absint($decimals); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | function wpinv_get_currencies() { |
| 334 | 334 | $currencies = array( |
| 335 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
| 336 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
| 337 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
| 338 | - 'AED' => __( 'United Arab Emirates', 'invoicing' ), |
|
| 339 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
| 340 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
| 341 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
| 342 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
| 343 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
| 344 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
| 345 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
| 346 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
| 347 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
| 348 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
| 349 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
| 350 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
| 351 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
| 352 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
| 353 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
| 354 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
| 355 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
| 356 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
| 357 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
| 358 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
| 359 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
| 360 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
| 361 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
| 362 | - 'BYN' => __( 'Belarusian Ruble', 'invoicing' ), |
|
| 363 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
| 364 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
| 365 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
| 366 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
| 367 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
| 368 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
| 369 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
| 370 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
| 371 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
| 372 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
| 373 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
| 374 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
| 375 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
| 376 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
| 377 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
| 378 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
| 379 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
| 380 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
| 381 | - 'ETB' => __( 'Ethiopian Irr', 'invoicing' ), |
|
| 382 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
| 383 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
| 384 | - 'GEL' => __( 'Georgian Lari', 'invoicing' ), |
|
| 385 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
| 386 | - 'GHS' => __( 'Ghana Cedi', 'invoicing' ), |
|
| 387 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
| 388 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
| 389 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
| 390 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
| 391 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
| 392 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
| 393 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
| 394 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
| 395 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
| 396 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
| 397 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
| 398 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
| 399 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
| 400 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
| 401 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
| 402 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
| 403 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
| 404 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
| 405 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
| 406 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
| 407 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
| 408 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
| 409 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
| 410 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
| 411 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
| 412 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
| 413 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
| 414 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
| 415 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
| 416 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
| 417 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
| 418 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
| 419 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
| 420 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
| 421 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
| 422 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
| 423 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
| 424 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
| 425 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
| 426 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
| 427 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
| 428 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
| 429 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
| 430 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
| 431 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
| 432 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
| 433 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
| 434 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
| 435 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
| 436 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
| 437 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
| 438 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
| 439 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
| 440 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
| 441 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
| 442 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
| 443 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
| 444 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
| 445 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
| 446 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
| 447 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
| 448 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
| 449 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
| 450 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
| 451 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
| 452 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
| 453 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
| 454 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
| 455 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
| 456 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
| 457 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
| 458 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
| 459 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
| 460 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
| 461 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
| 462 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
| 463 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
| 464 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
| 465 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
| 466 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
| 467 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
| 468 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
| 469 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
| 470 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
| 471 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
| 472 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
| 473 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
| 474 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
| 475 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
| 476 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
| 477 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
| 478 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
| 479 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
| 480 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
| 481 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
| 482 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
| 483 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
| 484 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
| 485 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
| 486 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
| 487 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
| 488 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
| 489 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
| 490 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
| 491 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
| 492 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
| 493 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
| 494 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
| 495 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
| 335 | + 'USD' => __('US Dollar', 'invoicing'), |
|
| 336 | + 'EUR' => __('Euro', 'invoicing'), |
|
| 337 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
| 338 | + 'AED' => __('United Arab Emirates', 'invoicing'), |
|
| 339 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
| 340 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
| 341 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
| 342 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
| 343 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
| 344 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
| 345 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
| 346 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
| 347 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
| 348 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
| 349 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
| 350 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
| 351 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
| 352 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
| 353 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
| 354 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
| 355 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
| 356 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
| 357 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
| 358 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
| 359 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
| 360 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
| 361 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
| 362 | + 'BYN' => __('Belarusian Ruble', 'invoicing'), |
|
| 363 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
| 364 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
| 365 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
| 366 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
| 367 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
| 368 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
| 369 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
| 370 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
| 371 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
| 372 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
| 373 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
| 374 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
| 375 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
| 376 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
| 377 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
| 378 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
| 379 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
| 380 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
| 381 | + 'ETB' => __('Ethiopian Irr', 'invoicing'), |
|
| 382 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
| 383 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
| 384 | + 'GEL' => __('Georgian Lari', 'invoicing'), |
|
| 385 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
| 386 | + 'GHS' => __('Ghana Cedi', 'invoicing'), |
|
| 387 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
| 388 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
| 389 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
| 390 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
| 391 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
| 392 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
| 393 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
| 394 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
| 395 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
| 396 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
| 397 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
| 398 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
| 399 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
| 400 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
| 401 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
| 402 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
| 403 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
| 404 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
| 405 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
| 406 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
| 407 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
| 408 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
| 409 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
| 410 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
| 411 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
| 412 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
| 413 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
| 414 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
| 415 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
| 416 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
| 417 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
| 418 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
| 419 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
| 420 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
| 421 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
| 422 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
| 423 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
| 424 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
| 425 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
| 426 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
| 427 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
| 428 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
| 429 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
| 430 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
| 431 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
| 432 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
| 433 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
| 434 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
| 435 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
| 436 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
| 437 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
| 438 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
| 439 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
| 440 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
| 441 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
| 442 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
| 443 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
| 444 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
| 445 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
| 446 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
| 447 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
| 448 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
| 449 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
| 450 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
| 451 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
| 452 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
| 453 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
| 454 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
| 455 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
| 456 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
| 457 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
| 458 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
| 459 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
| 460 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
| 461 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
| 462 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
| 463 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
| 464 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
| 465 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
| 466 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
| 467 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
| 468 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
| 469 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
| 470 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
| 471 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
| 472 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
| 473 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
| 474 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
| 475 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
| 476 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
| 477 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
| 478 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
| 479 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
| 480 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
| 481 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
| 482 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
| 483 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
| 484 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
| 485 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
| 486 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
| 487 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
| 488 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
| 489 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
| 490 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
| 491 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
| 492 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
| 493 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
| 494 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
| 495 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
| 496 | 496 | ); |
| 497 | 497 | |
| 498 | 498 | //asort( $currencies ); // this |
| 499 | 499 | |
| 500 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
| 500 | + return apply_filters('wpinv_currencies', $currencies); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
| 504 | - if( empty( $currency ) ) { |
|
| 503 | +function wpinv_price($amount = '', $currency = '') { |
|
| 504 | + if (empty($currency)) { |
|
| 505 | 505 | $currency = wpinv_get_currency(); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -509,14 +509,14 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | $negative = $amount < 0; |
| 511 | 511 | |
| 512 | - if ( $negative ) { |
|
| 513 | - $amount = substr( $amount, 1 ); |
|
| 512 | + if ($negative) { |
|
| 513 | + $amount = substr($amount, 1); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - $symbol = wpinv_currency_symbol( $currency ); |
|
| 516 | + $symbol = wpinv_currency_symbol($currency); |
|
| 517 | 517 | |
| 518 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
| 519 | - switch ( $currency ) { |
|
| 518 | + if ($position == 'left' || $position == 'left_space') { |
|
| 519 | + switch ($currency) { |
|
| 520 | 520 | case "GBP" : |
| 521 | 521 | case "BRL" : |
| 522 | 522 | case "EUR" : |
@@ -528,15 +528,15 @@ discard block |
||
| 528 | 528 | case "NZD" : |
| 529 | 529 | case "SGD" : |
| 530 | 530 | case "JPY" : |
| 531 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 531 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 532 | 532 | break; |
| 533 | 533 | default : |
| 534 | 534 | //$price = $currency . ' ' . $amount; |
| 535 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 535 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 536 | 536 | break; |
| 537 | 537 | } |
| 538 | 538 | } else { |
| 539 | - switch ( $currency ) { |
|
| 539 | + switch ($currency) { |
|
| 540 | 540 | case "GBP" : |
| 541 | 541 | case "BRL" : |
| 542 | 542 | case "EUR" : |
@@ -547,83 +547,83 @@ discard block |
||
| 547 | 547 | case "MXN" : |
| 548 | 548 | case "SGD" : |
| 549 | 549 | case "JPY" : |
| 550 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 550 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 551 | 551 | break; |
| 552 | 552 | default : |
| 553 | 553 | //$price = $amount . ' ' . $currency; |
| 554 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 554 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 555 | 555 | break; |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - if ( $negative ) { |
|
| 559 | + if ($negative) { |
|
| 560 | 560 | $price = '-' . $price; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
| 563 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
| 564 | 564 | |
| 565 | 565 | return $price; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
| 568 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
| 569 | 569 | $thousands_sep = wpinv_thousands_separator(); |
| 570 | 570 | $decimal_sep = wpinv_decimal_separator(); |
| 571 | 571 | |
| 572 | - if ( $decimals === NULL ) { |
|
| 572 | + if ($decimals === NULL) { |
|
| 573 | 573 | $decimals = wpinv_decimals(); |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 577 | - $whole = substr( $amount, 0, $sep_found ); |
|
| 578 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
| 576 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
| 577 | + $whole = substr($amount, 0, $sep_found); |
|
| 578 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
| 579 | 579 | $amount = $whole . '.' . $part; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 583 | - $amount = str_replace( ',', '', $amount ); |
|
| 582 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 583 | + $amount = str_replace(',', '', $amount); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 587 | - $amount = str_replace( ' ', '', $amount ); |
|
| 586 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 587 | + $amount = str_replace(' ', '', $amount); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - if ( empty( $amount ) ) { |
|
| 590 | + if (empty($amount)) { |
|
| 591 | 591 | $amount = 0; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
| 595 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 594 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
| 595 | + $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 596 | 596 | |
| 597 | - if ( $calculate ) { |
|
| 598 | - if ( $thousands_sep === "," ) { |
|
| 599 | - $formatted = str_replace( ",", "", $formatted ); |
|
| 597 | + if ($calculate) { |
|
| 598 | + if ($thousands_sep === ",") { |
|
| 599 | + $formatted = str_replace(",", "", $formatted); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - if ( $decimal_sep === "," ) { |
|
| 603 | - $formatted = str_replace( ",", ".", $formatted ); |
|
| 602 | + if ($decimal_sep === ",") { |
|
| 603 | + $formatted = str_replace(",", ".", $formatted); |
|
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
| 607 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
| 608 | 608 | } |
| 609 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 609 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 610 | 610 | |
| 611 | -function wpinv_sanitize_key( $key ) { |
|
| 611 | +function wpinv_sanitize_key($key) { |
|
| 612 | 612 | $raw_key = $key; |
| 613 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
| 613 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
| 614 | 614 | |
| 615 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
| 615 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | -function wpinv_get_file_extension( $str ) { |
|
| 619 | - $parts = explode( '.', $str ); |
|
| 620 | - return end( $parts ); |
|
| 618 | +function wpinv_get_file_extension($str) { |
|
| 619 | + $parts = explode('.', $str); |
|
| 620 | + return end($parts); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | -function wpinv_string_is_image_url( $str ) { |
|
| 624 | - $ext = wpinv_get_file_extension( $str ); |
|
| 623 | +function wpinv_string_is_image_url($str) { |
|
| 624 | + $ext = wpinv_get_file_extension($str); |
|
| 625 | 625 | |
| 626 | - switch ( strtolower( $ext ) ) { |
|
| 626 | + switch (strtolower($ext)) { |
|
| 627 | 627 | case 'jpeg'; |
| 628 | 628 | case 'jpg'; |
| 629 | 629 | $return = true; |
@@ -639,33 +639,33 @@ discard block |
||
| 639 | 639 | break; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
| 642 | + return (bool) apply_filters('wpinv_string_is_image', $return, $str); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
| 646 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
| 645 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
| 646 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
| 647 | 647 | |
| 648 | - if ( true === $should_log ) { |
|
| 648 | + if (true === $should_log) { |
|
| 649 | 649 | $label = ''; |
| 650 | - if ( $file && $file !== '' ) { |
|
| 651 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
| 650 | + if ($file && $file !== '') { |
|
| 651 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - if ( $title && $title !== '' ) { |
|
| 654 | + if ($title && $title !== '') { |
|
| 655 | 655 | $label = $label !== '' ? $label . ' ' : ''; |
| 656 | 656 | $label .= $title . ' '; |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
| 659 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
| 660 | 660 | |
| 661 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
| 662 | - error_log( $label . print_r( $log, true ) ); |
|
| 661 | + if (is_array($log) || is_object($log)) { |
|
| 662 | + error_log($label . print_r($log, true)); |
|
| 663 | 663 | } else { |
| 664 | - error_log( $label . $log ); |
|
| 664 | + error_log($label . $log); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - error_log( wp_debug_backtrace_summary() ); |
|
| 668 | - if ( $exit ) { |
|
| 667 | + error_log(wp_debug_backtrace_summary()); |
|
| 668 | + if ($exit) { |
|
| 669 | 669 | exit; |
| 670 | 670 | } |
| 671 | 671 | } |
@@ -673,32 +673,32 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | function wpinv_is_ajax_disabled() { |
| 675 | 675 | $retval = false; |
| 676 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
| 676 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
| 679 | +function wpinv_get_current_page_url($nocache = false) { |
|
| 680 | 680 | global $wp; |
| 681 | 681 | |
| 682 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 683 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 682 | + if (get_option('permalink_structure')) { |
|
| 683 | + $base = trailingslashit(home_url($wp->request)); |
|
| 684 | 684 | } else { |
| 685 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 686 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 685 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 686 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | $scheme = is_ssl() ? 'https' : 'http'; |
| 690 | - $uri = set_url_scheme( $base, $scheme ); |
|
| 690 | + $uri = set_url_scheme($base, $scheme); |
|
| 691 | 691 | |
| 692 | - if ( is_front_page() ) { |
|
| 693 | - $uri = home_url( '/' ); |
|
| 694 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
| 692 | + if (is_front_page()) { |
|
| 693 | + $uri = home_url('/'); |
|
| 694 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
| 695 | 695 | $uri = wpinv_get_checkout_uri(); |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
| 698 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
| 699 | 699 | |
| 700 | - if ( $nocache ) { |
|
| 701 | - $uri = wpinv_add_cache_busting( $uri ); |
|
| 700 | + if ($nocache) { |
|
| 701 | + $uri = wpinv_add_cache_busting($uri); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | return $uri; |
@@ -711,46 +711,46 @@ discard block |
||
| 711 | 711 | * @param string $name Constant name. |
| 712 | 712 | * @param mixed $value Value. |
| 713 | 713 | */ |
| 714 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
| 715 | - if ( ! defined( $name ) ) { |
|
| 716 | - define( $name, $value ); |
|
| 714 | +function getpaid_maybe_define_constant($name, $value) { |
|
| 715 | + if (!defined($name)) { |
|
| 716 | + define($name, $value); |
|
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | function wpinv_get_php_arg_separator_output() { |
| 721 | - return ini_get( 'arg_separator.output' ); |
|
| 721 | + return ini_get('arg_separator.output'); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | -function wpinv_rgb_from_hex( $color ) { |
|
| 725 | - $color = str_replace( '#', '', $color ); |
|
| 724 | +function wpinv_rgb_from_hex($color) { |
|
| 725 | + $color = str_replace('#', '', $color); |
|
| 726 | 726 | |
| 727 | 727 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
| 728 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
| 729 | - if ( empty( $color ) ) { |
|
| 728 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
| 729 | + if (empty($color)) { |
|
| 730 | 730 | return NULL; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - $color = str_split( $color ); |
|
| 733 | + $color = str_split($color); |
|
| 734 | 734 | |
| 735 | 735 | $rgb = array(); |
| 736 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
| 737 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
| 738 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
| 736 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
| 737 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
| 738 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
| 739 | 739 | |
| 740 | 740 | return $rgb; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
| 744 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 743 | +function wpinv_hex_darker($color, $factor = 30) { |
|
| 744 | + $base = wpinv_rgb_from_hex($color); |
|
| 745 | 745 | $color = '#'; |
| 746 | 746 | |
| 747 | - foreach ( $base as $k => $v ) { |
|
| 747 | + foreach ($base as $k => $v) { |
|
| 748 | 748 | $amount = $v / 100; |
| 749 | - $amount = round( $amount * $factor ); |
|
| 749 | + $amount = round($amount * $factor); |
|
| 750 | 750 | $new_decimal = $v - $amount; |
| 751 | 751 | |
| 752 | - $new_hex_component = dechex( $new_decimal ); |
|
| 753 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 752 | + $new_hex_component = dechex($new_decimal); |
|
| 753 | + if (strlen($new_hex_component) < 2) { |
|
| 754 | 754 | $new_hex_component = "0" . $new_hex_component; |
| 755 | 755 | } |
| 756 | 756 | $color .= $new_hex_component; |
@@ -759,18 +759,18 @@ discard block |
||
| 759 | 759 | return $color; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
| 763 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 762 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
| 763 | + $base = wpinv_rgb_from_hex($color); |
|
| 764 | 764 | $color = '#'; |
| 765 | 765 | |
| 766 | - foreach ( $base as $k => $v ) { |
|
| 766 | + foreach ($base as $k => $v) { |
|
| 767 | 767 | $amount = 255 - $v; |
| 768 | 768 | $amount = $amount / 100; |
| 769 | - $amount = round( $amount * $factor ); |
|
| 769 | + $amount = round($amount * $factor); |
|
| 770 | 770 | $new_decimal = $v + $amount; |
| 771 | 771 | |
| 772 | - $new_hex_component = dechex( $new_decimal ); |
|
| 773 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 772 | + $new_hex_component = dechex($new_decimal); |
|
| 773 | + if (strlen($new_hex_component) < 2) { |
|
| 774 | 774 | $new_hex_component = "0" . $new_hex_component; |
| 775 | 775 | } |
| 776 | 776 | $color .= $new_hex_component; |
@@ -779,22 +779,22 @@ discard block |
||
| 779 | 779 | return $color; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
| 783 | - $hex = str_replace( '#', '', $color ); |
|
| 782 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
| 783 | + $hex = str_replace('#', '', $color); |
|
| 784 | 784 | |
| 785 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 786 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 787 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 785 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
| 786 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
| 787 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
| 788 | 788 | |
| 789 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
| 789 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
| 790 | 790 | |
| 791 | 791 | return $brightness > 155 ? $dark : $light; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | -function wpinv_format_hex( $hex ) { |
|
| 795 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
| 794 | +function wpinv_format_hex($hex) { |
|
| 795 | + $hex = trim(str_replace('#', '', $hex)); |
|
| 796 | 796 | |
| 797 | - if ( strlen( $hex ) == 3 ) { |
|
| 797 | + if (strlen($hex) == 3) { |
|
| 798 | 798 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
| 799 | 799 | } |
| 800 | 800 | |
@@ -814,12 +814,12 @@ discard block |
||
| 814 | 814 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 815 | 815 | * @return string |
| 816 | 816 | */ |
| 817 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 818 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 819 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 817 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 818 | + if (function_exists('mb_strimwidth')) { |
|
| 819 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 822 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | /** |
@@ -831,28 +831,28 @@ discard block |
||
| 831 | 831 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 832 | 832 | * @return int Returns the number of characters in string. |
| 833 | 833 | */ |
| 834 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 835 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 836 | - return mb_strlen( $str, $encoding ); |
|
| 834 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 835 | + if (function_exists('mb_strlen')) { |
|
| 836 | + return mb_strlen($str, $encoding); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - return strlen( $str ); |
|
| 839 | + return strlen($str); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
| 843 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
| 844 | - return mb_strtolower( $str, $encoding ); |
|
| 842 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
| 843 | + if (function_exists('mb_strtolower')) { |
|
| 844 | + return mb_strtolower($str, $encoding); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - return strtolower( $str ); |
|
| 847 | + return strtolower($str); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
| 851 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
| 852 | - return mb_strtoupper( $str, $encoding ); |
|
| 850 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
| 851 | + if (function_exists('mb_strtoupper')) { |
|
| 852 | + return mb_strtoupper($str, $encoding); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - return strtoupper( $str ); |
|
| 855 | + return strtoupper($str); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -866,12 +866,12 @@ discard block |
||
| 866 | 866 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 867 | 867 | * @return int Returns the position of the first occurrence of search in the string. |
| 868 | 868 | */ |
| 869 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 870 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 871 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 869 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 870 | + if (function_exists('mb_strpos')) { |
|
| 871 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - return strpos( $str, $find, $offset ); |
|
| 874 | + return strpos($str, $find, $offset); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | /** |
@@ -885,12 +885,12 @@ discard block |
||
| 885 | 885 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 886 | 886 | * @return int Returns the position of the last occurrence of search. |
| 887 | 887 | */ |
| 888 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 889 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 890 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 888 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 889 | + if (function_exists('mb_strrpos')) { |
|
| 890 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - return strrpos( $str, $find, $offset ); |
|
| 893 | + return strrpos($str, $find, $offset); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | /** |
@@ -905,16 +905,16 @@ discard block |
||
| 905 | 905 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 906 | 906 | * @return string |
| 907 | 907 | */ |
| 908 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 909 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 910 | - if ( $length === null ) { |
|
| 911 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 908 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 909 | + if (function_exists('mb_substr')) { |
|
| 910 | + if ($length === null) { |
|
| 911 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 912 | 912 | } else { |
| 913 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 913 | + return mb_substr($str, $start, $length, $encoding); |
|
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | - return substr( $str, $start, $length ); |
|
| 917 | + return substr($str, $start, $length); |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | /** |
@@ -926,48 +926,48 @@ discard block |
||
| 926 | 926 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 927 | 927 | * @return string The width of string. |
| 928 | 928 | */ |
| 929 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 930 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 931 | - return mb_strwidth( $str, $encoding ); |
|
| 929 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 930 | + if (function_exists('mb_strwidth')) { |
|
| 931 | + return mb_strwidth($str, $encoding); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
| 934 | + return wpinv_utf8_strlen($str, $encoding); |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 938 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 939 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 937 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 938 | + if (function_exists('mb_strlen')) { |
|
| 939 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 940 | 940 | $str_end = ""; |
| 941 | 941 | |
| 942 | - if ( $lower_str_end ) { |
|
| 943 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 942 | + if ($lower_str_end) { |
|
| 943 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 944 | 944 | } else { |
| 945 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 945 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | return $first_letter . $str_end; |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - return ucfirst( $str ); |
|
| 951 | + return ucfirst($str); |
|
| 952 | 952 | } |
| 953 | 953 | |
| 954 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
| 955 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
| 956 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
| 954 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
| 955 | + if (function_exists('mb_convert_case')) { |
|
| 956 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - return ucwords( $str ); |
|
| 959 | + return ucwords($str); |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | -function wpinv_period_in_days( $period, $unit ) { |
|
| 963 | - $period = absint( $period ); |
|
| 962 | +function wpinv_period_in_days($period, $unit) { |
|
| 963 | + $period = absint($period); |
|
| 964 | 964 | |
| 965 | - if ( $period > 0 ) { |
|
| 966 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
| 965 | + if ($period > 0) { |
|
| 966 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
| 967 | 967 | $period = $period * 7; |
| 968 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
| 968 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
| 969 | 969 | $period = $period * 30; |
| 970 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
| 970 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
| 971 | 971 | $period = $period * 365; |
| 972 | 972 | } |
| 973 | 973 | } |
@@ -975,14 +975,14 @@ discard block |
||
| 975 | 975 | return $period; |
| 976 | 976 | } |
| 977 | 977 | |
| 978 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
| 979 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
| 980 | - return cal_days_in_month( $calendar, $month, $year ); |
|
| 978 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
| 979 | + if (function_exists('cal_days_in_month')) { |
|
| 980 | + return cal_days_in_month($calendar, $month, $year); |
|
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | // Fallback in case the calendar extension is not loaded in PHP |
| 984 | 984 | // Only supports Gregorian calendar |
| 985 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 985 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | /** |
@@ -993,11 +993,11 @@ discard block |
||
| 993 | 993 | * |
| 994 | 994 | * @return string |
| 995 | 995 | */ |
| 996 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
| 997 | - if ( $allow_html ) { |
|
| 998 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
| 996 | +function wpi_help_tip($tip, $allow_html = false) { |
|
| 997 | + if ($allow_html) { |
|
| 998 | + $tip = wpi_sanitize_tooltip($tip); |
|
| 999 | 999 | } else { |
| 1000 | - $tip = esc_attr( $tip ); |
|
| 1000 | + $tip = esc_attr($tip); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -1011,8 +1011,8 @@ discard block |
||
| 1011 | 1011 | * @param string $var |
| 1012 | 1012 | * @return string |
| 1013 | 1013 | */ |
| 1014 | -function wpi_sanitize_tooltip( $var ) { |
|
| 1015 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 1014 | +function wpi_sanitize_tooltip($var) { |
|
| 1015 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 1016 | 1016 | 'br' => array(), |
| 1017 | 1017 | 'em' => array(), |
| 1018 | 1018 | 'strong' => array(), |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | 'li' => array(), |
| 1023 | 1023 | 'ol' => array(), |
| 1024 | 1024 | 'p' => array(), |
| 1025 | - ) ) ); |
|
| 1025 | + ))); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | */ |
| 1033 | 1033 | function wpinv_get_screen_ids() { |
| 1034 | 1034 | |
| 1035 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
| 1035 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
| 1036 | 1036 | |
| 1037 | 1037 | $screen_ids = array( |
| 1038 | 1038 | 'toplevel_page_' . $screen_id, |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | 'invoicing_page_wpi-addons', |
| 1051 | 1051 | ); |
| 1052 | 1052 | |
| 1053 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
| 1053 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | /** |
@@ -1061,14 +1061,14 @@ discard block |
||
| 1061 | 1061 | * @param array|string $list List of values. |
| 1062 | 1062 | * @return array Sanitized array of values. |
| 1063 | 1063 | */ |
| 1064 | -function wpinv_parse_list( $list ) { |
|
| 1064 | +function wpinv_parse_list($list) { |
|
| 1065 | 1065 | |
| 1066 | - if ( empty( $list ) ) { |
|
| 1066 | + if (empty($list)) { |
|
| 1067 | 1067 | $list = array(); |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - if ( ! is_array( $list ) ) { |
|
| 1071 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 1070 | + if (!is_array($list)) { |
|
| 1071 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | return $list; |
@@ -1082,16 +1082,16 @@ discard block |
||
| 1082 | 1082 | * @param string $key Type of data to fetch. |
| 1083 | 1083 | * @return mixed Fetched data. |
| 1084 | 1084 | */ |
| 1085 | -function wpinv_get_data( $key ) { |
|
| 1085 | +function wpinv_get_data($key) { |
|
| 1086 | 1086 | |
| 1087 | 1087 | // Try fetching it from the cache. |
| 1088 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
| 1089 | - if( $data ) { |
|
| 1088 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
| 1089 | + if ($data) { |
|
| 1090 | 1090 | return $data; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
| 1094 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
| 1093 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
| 1094 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
| 1095 | 1095 | |
| 1096 | 1096 | return $data; |
| 1097 | 1097 | } |
@@ -1105,10 +1105,10 @@ discard block |
||
| 1105 | 1105 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 1106 | 1106 | * @return mixed Fetched data. |
| 1107 | 1107 | */ |
| 1108 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
| 1108 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
| 1109 | 1109 | |
| 1110 | - if ( ! empty( $options ) && $first_empty ) { |
|
| 1111 | - return array_merge( array( '' => '' ), $options ); |
|
| 1110 | + if (!empty($options) && $first_empty) { |
|
| 1111 | + return array_merge(array('' => ''), $options); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | return $options; |
| 1114 | 1114 | |
@@ -1120,21 +1120,21 @@ discard block |
||
| 1120 | 1120 | * @param mixed $var Data to sanitize. |
| 1121 | 1121 | * @return string|array |
| 1122 | 1122 | */ |
| 1123 | -function wpinv_clean( $var ) { |
|
| 1123 | +function wpinv_clean($var) { |
|
| 1124 | 1124 | |
| 1125 | - if ( is_array( $var ) ) { |
|
| 1126 | - return array_map( 'wpinv_clean', $var ); |
|
| 1125 | + if (is_array($var)) { |
|
| 1126 | + return array_map('wpinv_clean', $var); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - if ( is_object( $var ) ) { |
|
| 1130 | - $object_vars = get_object_vars( $var ); |
|
| 1131 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 1132 | - $var->$property_name = wpinv_clean( $property_value ); |
|
| 1129 | + if (is_object($var)) { |
|
| 1130 | + $object_vars = get_object_vars($var); |
|
| 1131 | + foreach ($object_vars as $property_name => $property_value) { |
|
| 1132 | + $var->$property_name = wpinv_clean($property_value); |
|
| 1133 | 1133 | } |
| 1134 | 1134 | return $var; |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
| 1137 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | /** |
@@ -1143,43 +1143,43 @@ discard block |
||
| 1143 | 1143 | * @param string $str Data to convert. |
| 1144 | 1144 | * @return string|array |
| 1145 | 1145 | */ |
| 1146 | -function getpaid_convert_price_string_to_options( $str ) { |
|
| 1146 | +function getpaid_convert_price_string_to_options($str) { |
|
| 1147 | 1147 | |
| 1148 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 1149 | - $options = array(); |
|
| 1148 | + $raw_options = array_map('trim', explode(',', $str)); |
|
| 1149 | + $options = array(); |
|
| 1150 | 1150 | |
| 1151 | - foreach ( $raw_options as $option ) { |
|
| 1151 | + foreach ($raw_options as $option) { |
|
| 1152 | 1152 | |
| 1153 | - if ( '' == $option ) { |
|
| 1153 | + if ('' == $option) { |
|
| 1154 | 1154 | continue; |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
| 1157 | + $option = array_map('trim', explode('|', $option)); |
|
| 1158 | 1158 | |
| 1159 | 1159 | $price = null; |
| 1160 | 1160 | $label = null; |
| 1161 | 1161 | |
| 1162 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
| 1163 | - $label = $option[0]; |
|
| 1162 | + if (isset($option[0]) && '' != $option[0]) { |
|
| 1163 | + $label = $option[0]; |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
| 1166 | + if (isset($option[1]) && '' != $option[1]) { |
|
| 1167 | 1167 | $price = $option[1]; |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | - if ( ! isset( $price ) ) { |
|
| 1170 | + if (!isset($price)) { |
|
| 1171 | 1171 | $price = $label; |
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
| 1174 | + if (!isset($price) || !is_numeric($price)) { |
|
| 1175 | 1175 | continue; |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - if ( ! isset( $label ) ) { |
|
| 1178 | + if (!isset($label)) { |
|
| 1179 | 1179 | $label = $price; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | - $options[ $price ] = $label; |
|
| 1182 | + $options[$price] = $label; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | return $options; |
@@ -1188,23 +1188,23 @@ discard block |
||
| 1188 | 1188 | /** |
| 1189 | 1189 | * Returns the help tip. |
| 1190 | 1190 | */ |
| 1191 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
| 1192 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
| 1193 | - $tip = esc_attr__( $tip ); |
|
| 1191 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
| 1192 | + $additional_classes = sanitize_html_class($additional_classes); |
|
| 1193 | + $tip = esc_attr__($tip); |
|
| 1194 | 1194 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
| 1198 | 1198 | * Formats a date |
| 1199 | 1199 | */ |
| 1200 | -function getpaid_format_date( $date ) { |
|
| 1200 | +function getpaid_format_date($date) { |
|
| 1201 | 1201 | |
| 1202 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
| 1202 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
| 1203 | 1203 | return ''; |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | |
| 1207 | - return date_i18n( get_option( 'date_format' ), strtotime( $date ) ); |
|
| 1207 | + return date_i18n(get_option('date_format'), strtotime($date)); |
|
| 1208 | 1208 | |
| 1209 | 1209 | } |
| 1210 | 1210 | |
@@ -1215,16 +1215,16 @@ discard block |
||
| 1215 | 1215 | * @param integer $limit Limit size in characters. |
| 1216 | 1216 | * @return string |
| 1217 | 1217 | */ |
| 1218 | -function getpaid_limit_length( $string, $limit ) { |
|
| 1218 | +function getpaid_limit_length($string, $limit) { |
|
| 1219 | 1219 | $str_limit = $limit - 3; |
| 1220 | 1220 | |
| 1221 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 1222 | - if ( mb_strlen( $string ) > $limit ) { |
|
| 1223 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
| 1221 | + if (function_exists('mb_strimwidth')) { |
|
| 1222 | + if (mb_strlen($string) > $limit) { |
|
| 1223 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
| 1224 | 1224 | } |
| 1225 | 1225 | } else { |
| 1226 | - if ( strlen( $string ) > $limit ) { |
|
| 1227 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
| 1226 | + if (strlen($string) > $limit) { |
|
| 1227 | + $string = substr($string, 0, $str_limit) . '...'; |
|
| 1228 | 1228 | } |
| 1229 | 1229 | } |
| 1230 | 1230 | return $string; |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,51 +21,51 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | |
| 26 | 26 | // Prepare the invoice. |
| 27 | - $invoice = new WPInv_Invoice( $post ); |
|
| 27 | + $invoice = new WPInv_Invoice($post); |
|
| 28 | 28 | |
| 29 | 29 | // Invoice items. |
| 30 | 30 | $items = $invoice->get_items(); |
| 31 | 31 | |
| 32 | 32 | // New item url. |
| 33 | - $new_item = admin_url( 'post-new.php?post_type=wpi_item' ); |
|
| 33 | + $new_item = admin_url('post-new.php?post_type=wpi_item'); |
|
| 34 | 34 | |
| 35 | 35 | // Totals. |
| 36 | - $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
| 36 | + $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
| 37 | 37 | |
| 38 | - if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
| 39 | - $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() ); |
|
| 40 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
| 38 | + if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
| 39 | + $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency()); |
|
| 40 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $totals = array( |
| 44 | 44 | |
| 45 | 45 | 'subtotal' => array( |
| 46 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
| 47 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ), |
|
| 46 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
| 47 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()), |
|
| 48 | 48 | ), |
| 49 | 49 | |
| 50 | 50 | 'discount' => array( |
| 51 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
| 52 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ), |
|
| 51 | + 'label' => __('Total Discount', 'invoicing'), |
|
| 52 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()), |
|
| 53 | 53 | ), |
| 54 | 54 | |
| 55 | 55 | 'tax' => array( |
| 56 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
| 57 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ), |
|
| 56 | + 'label' => __('Total Tax', 'invoicing'), |
|
| 57 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()), |
|
| 58 | 58 | ), |
| 59 | 59 | |
| 60 | 60 | 'total' => array( |
| 61 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
| 61 | + 'label' => __('Invoice Total', 'invoicing'), |
|
| 62 | 62 | 'value' => $total, |
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - if ( ! wpinv_use_taxes() ) { |
|
| 68 | - unset( $totals['tax'] ); |
|
| 67 | + if (!wpinv_use_taxes()) { |
|
| 68 | + unset($totals['tax']); |
|
| 69 | 69 | } |
| 70 | 70 | ?> |
| 71 | 71 | |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | </style> |
| 83 | 83 | |
| 84 | - <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class( $invoice->get_template( 'edit' ) ); ?> <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem"> |
|
| 84 | + <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class($invoice->get_template('edit')); ?> <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem"> |
|
| 85 | 85 | |
| 86 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
| 87 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
| 86 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
| 87 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
| 88 | 88 | |
| 89 | 89 | <div class="row"> |
| 90 | 90 | <div class="col-12 col-sm-6"> |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | array( |
| 94 | 94 | 'id' => 'wpinv_template', |
| 95 | 95 | 'name' => 'wpinv_template', |
| 96 | - 'label' => __( 'Template', 'invoicing' ), |
|
| 96 | + 'label' => __('Template', 'invoicing'), |
|
| 97 | 97 | 'label_type' => 'vertical', |
| 98 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
| 98 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
| 99 | 99 | 'class' => 'form-control-sm', |
| 100 | - 'value' => $invoice->get_template( 'edit' ), |
|
| 100 | + 'value' => $invoice->get_template('edit'), |
|
| 101 | 101 | 'options' => array( |
| 102 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 103 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
| 104 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
| 102 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 103 | + 'hours' => __('Hours', 'invoicing'), |
|
| 104 | + 'amount' => __('Amount Only', 'invoicing'), |
|
| 105 | 105 | ), |
| 106 | 106 | 'data-allow-clear' => 'false', |
| 107 | 107 | 'select2' => true, |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | array( |
| 118 | 118 | 'id' => 'wpinv_currency', |
| 119 | 119 | 'name' => 'wpinv_currency', |
| 120 | - 'label' => __( 'Currency', 'invoicing' ), |
|
| 120 | + 'label' => __('Currency', 'invoicing'), |
|
| 121 | 121 | 'label_type' => 'vertical', |
| 122 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
| 122 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
| 123 | 123 | 'class' => 'form-control-sm', |
| 124 | - 'value' => $invoice->get_currency( 'edit' ), |
|
| 124 | + 'value' => $invoice->get_currency('edit'), |
|
| 125 | 125 | 'required' => false, |
| 126 | 126 | 'data-allow-clear' => 'false', |
| 127 | 127 | 'select2' => true, |
@@ -133,24 +133,24 @@ discard block |
||
| 133 | 133 | </div> |
| 134 | 134 | </div> |
| 135 | 135 | |
| 136 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
| 136 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
| 137 | 137 | <?php endif; ?> |
| 138 | 138 | |
| 139 | 139 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
| 140 | 140 | <thead> |
| 141 | 141 | <tr> |
| 142 | - <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th> |
|
| 142 | + <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th> |
|
| 143 | 143 | <th class="getpaid-quantity hide-if-amount text-right"> |
| 144 | - <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
|
| 145 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
|
| 144 | + <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span> |
|
| 145 | + <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span> |
|
| 146 | 146 | </th> |
| 147 | 147 | <th class="getpaid-price hide-if-amount text-right"> |
| 148 | - <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span> |
|
| 149 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span> |
|
| 148 | + <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span> |
|
| 149 | + <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span> |
|
| 150 | 150 | </th> |
| 151 | 151 | <th class="getpaid-item-subtotal text-right"> |
| 152 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span> |
|
| 153 | - <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span> |
|
| 152 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span> |
|
| 153 | + <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span> |
|
| 154 | 154 | </th> |
| 155 | 155 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
| 156 | 156 | </tr> |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | <tbody class="getpaid_invoice_line_items"> |
| 159 | 159 | <tr class="hide-if-has-items hide-if-not-editable"> |
| 160 | 160 | <td colspan="2" class="pt-4 pb-4"> |
| 161 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button> |
|
| 162 | - <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a> |
|
| 161 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button> |
|
| 162 | + <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a> |
|
| 163 | 163 | </td> |
| 164 | 164 | <td class="hide-if-amount"> </th> |
| 165 | 165 | <td class="hide-if-amount"> </th> |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | <div class="col-12 col-sm-6 offset-sm-6"> |
| 192 | 192 | <table class="getpaid-invoice-totals text-right w-100"> |
| 193 | 193 | <tbody> |
| 194 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
| 195 | - <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 196 | - <td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td> |
|
| 194 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
| 195 | + <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>"> |
|
| 196 | + <td class="label"><?php echo sanitize_text_field($data['label']) ?>:</td> |
|
| 197 | 197 | <td width="1%"></td> |
| 198 | - <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
|
| 198 | + <td class="value"><?php echo wp_kses_post($data['value']) ?></td> |
|
| 199 | 199 | </tr> |
| 200 | 200 | <?php endforeach; ?> |
| 201 | 201 | </tbody> |
@@ -208,18 +208,18 @@ discard block |
||
| 208 | 208 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
| 209 | 209 | <div class="row"> |
| 210 | 210 | <div class="text-left col-12 col-sm-8"> |
| 211 | - <button type="button" class="button add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button> |
|
| 212 | - <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a> |
|
| 213 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
| 211 | + <button type="button" class="button add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button> |
|
| 212 | + <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a> |
|
| 213 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
| 214 | 214 | </div> |
| 215 | 215 | <div class="text-right col-12 col-sm-4"> |
| 216 | - <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button> |
|
| 216 | + <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button> |
|
| 217 | 217 | </div> |
| 218 | 218 | </div> |
| 219 | 219 | </div> |
| 220 | 220 | |
| 221 | 221 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
| 222 | - <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
| 222 | + <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
| 223 | 223 | </div> |
| 224 | 224 | |
| 225 | 225 | <!-- Add items to an invoice --> |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 228 | 228 | <div class="modal-content"> |
| 229 | 229 | <div class="modal-header"> |
| 230 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5> |
|
| 231 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
| 230 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5> |
|
| 231 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
| 232 | 232 | <span aria-hidden="true">×</span> |
| 233 | 233 | </button> |
| 234 | 234 | </div> |
@@ -236,17 +236,17 @@ discard block |
||
| 236 | 236 | <table class="widefat"> |
| 237 | 237 | <thead> |
| 238 | 238 | <tr> |
| 239 | - <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th> |
|
| 239 | + <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th> |
|
| 240 | 240 | <th class="pr-0 text-right hide-if-amount"> |
| 241 | - <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
|
| 242 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
|
| 241 | + <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span> |
|
| 242 | + <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span> |
|
| 243 | 243 | </th> |
| 244 | 244 | </tr> |
| 245 | 245 | </thead> |
| 246 | 246 | <tbody> |
| 247 | 247 | <tr> |
| 248 | 248 | <td class="pl-0 text-left"> |
| 249 | - <select class="getpaid-item-search regular-text" data-placeholder="<?php esc_attr_e( 'Search for an item…', 'invoicing' ); ?>"></select> |
|
| 249 | + <select class="getpaid-item-search regular-text" data-placeholder="<?php esc_attr_e('Search for an item…', 'invoicing'); ?>"></select> |
|
| 250 | 250 | </td> |
| 251 | 251 | <td class="pr-0 text-right hide-if-amount"> |
| 252 | 252 | <input type="number" class="w100" step="1" min="1" autocomplete="off" value="1" placeholder="1"> |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | </table> |
| 257 | 257 | </div> |
| 258 | 258 | <div class="modal-footer"> |
| 259 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
| 260 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button> |
|
| 259 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
| 260 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button> |
|
| 261 | 261 | </div> |
| 262 | 262 | </div> |
| 263 | 263 | </div> |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 269 | 269 | <div class="modal-content"> |
| 270 | 270 | <div class="modal-header"> |
| 271 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5> |
|
| 272 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
| 271 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5> |
|
| 272 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
| 273 | 273 | <span aria-hidden="true">×</span> |
| 274 | 274 | </button> |
| 275 | 275 | </div> |
@@ -277,27 +277,27 @@ discard block |
||
| 277 | 277 | <div class="getpaid-edit-item-div"> |
| 278 | 278 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
| 279 | 279 | <label class="form-group w-100"> |
| 280 | - <span><?php _e( 'Name', 'invoicing' ); ?></span> |
|
| 281 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
| 280 | + <span><?php _e('Name', 'invoicing'); ?></span> |
|
| 281 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
| 282 | 282 | </label> |
| 283 | 283 | <label class="form-group w-100"> |
| 284 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span> |
|
| 285 | - <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span> |
|
| 286 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
| 284 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span> |
|
| 285 | + <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span> |
|
| 286 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
| 287 | 287 | </label> |
| 288 | 288 | <label class="form-group w-100 hide-if-amount"> |
| 289 | - <span><?php _e( 'Quantity', 'invoicing' ); ?></span> |
|
| 289 | + <span><?php _e('Quantity', 'invoicing'); ?></span> |
|
| 290 | 290 | <input type="number" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
| 291 | 291 | </label> |
| 292 | 292 | <label class="form-group w-100"> |
| 293 | - <span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
|
| 294 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
| 293 | + <span><?php _e('Item Description', 'invoicing'); ?></span> |
|
| 294 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
| 295 | 295 | </label> |
| 296 | 296 | </div> |
| 297 | 297 | </div> |
| 298 | 298 | <div class="modal-footer"> |
| 299 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
| 300 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button> |
|
| 299 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
| 300 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button> |
|
| 301 | 301 | </div> |
| 302 | 302 | </div> |
| 303 | 303 | </div> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -10,55 +10,55 @@ discard block |
||
| 10 | 10 | class GetPaid_Payment_Form extends GetPaid_Data { |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Which data store to load. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 13 | + * Which data store to load. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | 17 | protected $data_store_name = 'payment_form'; |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * This is the name of this object type. |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $object_type = 'payment_form'; |
|
| 20 | + * This is the name of this object type. |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $object_type = 'payment_form'; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Form Data array. This is the core form data exposed in APIs. |
|
| 28 | - * |
|
| 29 | - * @since 1.0.19 |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - protected $data = array( |
|
| 33 | - 'status' => 'draft', |
|
| 34 | - 'version' => '', |
|
| 35 | - 'date_created' => null, |
|
| 27 | + * Form Data array. This is the core form data exposed in APIs. |
|
| 28 | + * |
|
| 29 | + * @since 1.0.19 |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + protected $data = array( |
|
| 33 | + 'status' => 'draft', |
|
| 34 | + 'version' => '', |
|
| 35 | + 'date_created' => null, |
|
| 36 | 36 | 'date_modified' => null, |
| 37 | 37 | 'name' => '', |
| 38 | 38 | 'author' => 1, |
| 39 | 39 | 'elements' => null, |
| 40 | - 'items' => null, |
|
| 41 | - 'earned' => 0, |
|
| 42 | - 'refunded' => 0, |
|
| 43 | - 'cancelled' => 0, |
|
| 44 | - 'failed' => 0, |
|
| 45 | - ); |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Stores meta in cache for future reads. |
|
| 49 | - * |
|
| 50 | - * A group must be set to to enable caching. |
|
| 51 | - * |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - protected $cache_group = 'getpaid_forms'; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Stores a reference to the invoice if the form is for an invoice.. |
|
| 58 | - * |
|
| 59 | - * @var WPInv_Invoice |
|
| 60 | - */ |
|
| 61 | - public $invoice = 0; |
|
| 40 | + 'items' => null, |
|
| 41 | + 'earned' => 0, |
|
| 42 | + 'refunded' => 0, |
|
| 43 | + 'cancelled' => 0, |
|
| 44 | + 'failed' => 0, |
|
| 45 | + ); |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Stores meta in cache for future reads. |
|
| 49 | + * |
|
| 50 | + * A group must be set to to enable caching. |
|
| 51 | + * |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + protected $cache_group = 'getpaid_forms'; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Stores a reference to the invoice if the form is for an invoice.. |
|
| 58 | + * |
|
| 59 | + * @var WPInv_Invoice |
|
| 60 | + */ |
|
| 61 | + public $invoice = 0; |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Stores a reference to the original WP_Post object |
@@ -68,35 +68,35 @@ discard block |
||
| 68 | 68 | protected $post = null; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Get the form if ID is passed, otherwise the form is new and empty. |
|
| 72 | - * |
|
| 73 | - * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
| 74 | - */ |
|
| 75 | - public function __construct( $form = 0 ) { |
|
| 76 | - parent::__construct( $form ); |
|
| 71 | + * Get the form if ID is passed, otherwise the form is new and empty. |
|
| 72 | + * |
|
| 73 | + * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
| 74 | + */ |
|
| 75 | + public function __construct( $form = 0 ) { |
|
| 76 | + parent::__construct( $form ); |
|
| 77 | 77 | |
| 78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
| 79 | - $this->set_id( $form ); |
|
| 80 | - } elseif ( $form instanceof self ) { |
|
| 78 | + if ( is_numeric( $form ) && $form > 0 ) { |
|
| 79 | + $this->set_id( $form ); |
|
| 80 | + } elseif ( $form instanceof self ) { |
|
| 81 | 81 | |
| 82 | - $this->set_id( $form->get_id() ); |
|
| 83 | - $this->invoice = $form->invoice; |
|
| 82 | + $this->set_id( $form->get_id() ); |
|
| 83 | + $this->invoice = $form->invoice; |
|
| 84 | 84 | |
| 85 | - } elseif ( ! empty( $form->ID ) ) { |
|
| 86 | - $this->set_id( $form->ID ); |
|
| 87 | - } else { |
|
| 88 | - $this->set_object_read( true ); |
|
| 89 | - } |
|
| 85 | + } elseif ( ! empty( $form->ID ) ) { |
|
| 86 | + $this->set_id( $form->ID ); |
|
| 87 | + } else { |
|
| 88 | + $this->set_object_read( true ); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | // Load the datastore. |
| 92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 92 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 93 | 93 | |
| 94 | - if ( $this->get_id() > 0 ) { |
|
| 94 | + if ( $this->get_id() > 0 ) { |
|
| 95 | 95 | $this->post = get_post( $this->get_id() ); |
| 96 | - $this->data_store->read( $this ); |
|
| 96 | + $this->data_store->read( $this ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | /* |
| 102 | 102 | |-------------------------------------------------------------------------- |
@@ -114,333 +114,333 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | - * Get plugin version when the form was created. |
|
| 118 | - * |
|
| 119 | - * @since 1.0.19 |
|
| 120 | - * @param string $context View or edit context. |
|
| 121 | - * @return string |
|
| 122 | - */ |
|
| 123 | - public function get_version( $context = 'view' ) { |
|
| 124 | - return $this->get_prop( 'version', $context ); |
|
| 117 | + * Get plugin version when the form was created. |
|
| 118 | + * |
|
| 119 | + * @since 1.0.19 |
|
| 120 | + * @param string $context View or edit context. |
|
| 121 | + * @return string |
|
| 122 | + */ |
|
| 123 | + public function get_version( $context = 'view' ) { |
|
| 124 | + return $this->get_prop( 'version', $context ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * Get date when the form was created. |
|
| 129 | - * |
|
| 130 | - * @since 1.0.19 |
|
| 131 | - * @param string $context View or edit context. |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public function get_date_created( $context = 'view' ) { |
|
| 135 | - return $this->get_prop( 'date_created', $context ); |
|
| 128 | + * Get date when the form was created. |
|
| 129 | + * |
|
| 130 | + * @since 1.0.19 |
|
| 131 | + * @param string $context View or edit context. |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public function get_date_created( $context = 'view' ) { |
|
| 135 | + return $this->get_prop( 'date_created', $context ); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | - * Get GMT date when the form was created. |
|
| 140 | - * |
|
| 141 | - * @since 1.0.19 |
|
| 142 | - * @param string $context View or edit context. |
|
| 143 | - * @return string |
|
| 144 | - */ |
|
| 145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 139 | + * Get GMT date when the form was created. |
|
| 140 | + * |
|
| 141 | + * @since 1.0.19 |
|
| 142 | + * @param string $context View or edit context. |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 145 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 146 | 146 | $date = $this->get_date_created( $context ); |
| 147 | 147 | |
| 148 | 148 | if ( $date ) { |
| 149 | 149 | $date = get_gmt_from_date( $date ); |
| 150 | 150 | } |
| 151 | - return $date; |
|
| 151 | + return $date; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | - * Get date when the form was last modified. |
|
| 156 | - * |
|
| 157 | - * @since 1.0.19 |
|
| 158 | - * @param string $context View or edit context. |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function get_date_modified( $context = 'view' ) { |
|
| 162 | - return $this->get_prop( 'date_modified', $context ); |
|
| 155 | + * Get date when the form was last modified. |
|
| 156 | + * |
|
| 157 | + * @since 1.0.19 |
|
| 158 | + * @param string $context View or edit context. |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function get_date_modified( $context = 'view' ) { |
|
| 162 | + return $this->get_prop( 'date_modified', $context ); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | - * Get GMT date when the form was last modified. |
|
| 167 | - * |
|
| 168 | - * @since 1.0.19 |
|
| 169 | - * @param string $context View or edit context. |
|
| 170 | - * @return string |
|
| 171 | - */ |
|
| 172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 166 | + * Get GMT date when the form was last modified. |
|
| 167 | + * |
|
| 168 | + * @since 1.0.19 |
|
| 169 | + * @param string $context View or edit context. |
|
| 170 | + * @return string |
|
| 171 | + */ |
|
| 172 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 173 | 173 | $date = $this->get_date_modified( $context ); |
| 174 | 174 | |
| 175 | 175 | if ( $date ) { |
| 176 | 176 | $date = get_gmt_from_date( $date ); |
| 177 | 177 | } |
| 178 | - return $date; |
|
| 178 | + return $date; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | - * Get the form name. |
|
| 183 | - * |
|
| 184 | - * @since 1.0.19 |
|
| 185 | - * @param string $context View or edit context. |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 188 | - public function get_name( $context = 'view' ) { |
|
| 189 | - return $this->get_prop( 'name', $context ); |
|
| 182 | + * Get the form name. |
|
| 183 | + * |
|
| 184 | + * @since 1.0.19 |
|
| 185 | + * @param string $context View or edit context. |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | + public function get_name( $context = 'view' ) { |
|
| 189 | + return $this->get_prop( 'name', $context ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | - * Alias of self::get_name(). |
|
| 194 | - * |
|
| 195 | - * @since 1.0.19 |
|
| 196 | - * @param string $context View or edit context. |
|
| 197 | - * @return string |
|
| 198 | - */ |
|
| 199 | - public function get_title( $context = 'view' ) { |
|
| 200 | - return $this->get_name( $context ); |
|
| 201 | - } |
|
| 193 | + * Alias of self::get_name(). |
|
| 194 | + * |
|
| 195 | + * @since 1.0.19 |
|
| 196 | + * @param string $context View or edit context. |
|
| 197 | + * @return string |
|
| 198 | + */ |
|
| 199 | + public function get_title( $context = 'view' ) { |
|
| 200 | + return $this->get_name( $context ); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * Get the owner of the form. |
|
| 205 | - * |
|
| 206 | - * @since 1.0.19 |
|
| 207 | - * @param string $context View or edit context. |
|
| 208 | - * @return int |
|
| 209 | - */ |
|
| 210 | - public function get_author( $context = 'view' ) { |
|
| 211 | - return (int) $this->get_prop( 'author', $context ); |
|
| 204 | + * Get the owner of the form. |
|
| 205 | + * |
|
| 206 | + * @since 1.0.19 |
|
| 207 | + * @param string $context View or edit context. |
|
| 208 | + * @return int |
|
| 209 | + */ |
|
| 210 | + public function get_author( $context = 'view' ) { |
|
| 211 | + return (int) $this->get_prop( 'author', $context ); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * Get the elements that make up the form. |
|
| 216 | - * |
|
| 217 | - * @since 1.0.19 |
|
| 218 | - * @param string $context View or edit context. |
|
| 219 | - * @return array |
|
| 220 | - */ |
|
| 221 | - public function get_elements( $context = 'view' ) { |
|
| 222 | - $elements = $this->get_prop( 'elements', $context ); |
|
| 215 | + * Get the elements that make up the form. |
|
| 216 | + * |
|
| 217 | + * @since 1.0.19 |
|
| 218 | + * @param string $context View or edit context. |
|
| 219 | + * @return array |
|
| 220 | + */ |
|
| 221 | + public function get_elements( $context = 'view' ) { |
|
| 222 | + $elements = $this->get_prop( 'elements', $context ); |
|
| 223 | 223 | |
| 224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
| 224 | + if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
| 225 | 225 | return wpinv_get_data( 'sample-payment-form' ); |
| 226 | - } |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - // Ensure that all required elements exist. |
|
| 229 | - $_elements = array(); |
|
| 230 | - foreach ( $elements as $element ) { |
|
| 228 | + // Ensure that all required elements exist. |
|
| 229 | + $_elements = array(); |
|
| 230 | + foreach ( $elements as $element ) { |
|
| 231 | 231 | |
| 232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
| 232 | + if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
| 233 | 233 | |
| 234 | - $_elements[] = array( |
|
| 235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 236 | - 'id' => 'gtscicd', |
|
| 237 | - 'name' => 'gtscicd', |
|
| 238 | - 'type' => 'gateway_select', |
|
| 239 | - 'premade' => true |
|
| 234 | + $_elements[] = array( |
|
| 235 | + 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 236 | + 'id' => 'gtscicd', |
|
| 237 | + 'name' => 'gtscicd', |
|
| 238 | + 'type' => 'gateway_select', |
|
| 239 | + 'premade' => true |
|
| 240 | 240 | |
| 241 | - ); |
|
| 241 | + ); |
|
| 242 | 242 | |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - $_elements[] = $element; |
|
| 245 | + $_elements[] = $element; |
|
| 246 | 246 | |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | 249 | return $_elements; |
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Get the items sold via the form. |
|
| 254 | - * |
|
| 255 | - * @since 1.0.19 |
|
| 256 | - * @param string $context View or edit context. |
|
| 257 | - * @param string $return objects or arrays. |
|
| 258 | - * @return GetPaid_Form_Item[] |
|
| 259 | - */ |
|
| 260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
| 261 | - $items = $this->get_prop( 'items', $context ); |
|
| 262 | - |
|
| 263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Get the items sold via the form. |
|
| 254 | + * |
|
| 255 | + * @since 1.0.19 |
|
| 256 | + * @param string $context View or edit context. |
|
| 257 | + * @param string $return objects or arrays. |
|
| 258 | + * @return GetPaid_Form_Item[] |
|
| 259 | + */ |
|
| 260 | + public function get_items( $context = 'view', $return = 'objects' ) { |
|
| 261 | + $items = $this->get_prop( 'items', $context ); |
|
| 262 | + |
|
| 263 | + if ( empty( $items ) || ! is_array( $items ) ) { |
|
| 264 | 264 | $items = wpinv_get_data( 'sample-payment-form-items' ); |
| 265 | - } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + // Convert the items. |
|
| 268 | + $prepared = array(); |
|
| 266 | 269 | |
| 267 | - // Convert the items. |
|
| 268 | - $prepared = array(); |
|
| 270 | + foreach ( $items as $key => $value ) { |
|
| 269 | 271 | |
| 270 | - foreach ( $items as $key => $value ) { |
|
| 272 | + if ( $value instanceof GetPaid_Form_Item ) { |
|
| 271 | 273 | |
| 272 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
| 274 | + if ( $value->can_purchase() ) { |
|
| 275 | + $prepared[] = $value; |
|
| 276 | + } |
|
| 273 | 277 | |
| 274 | - if ( $value->can_purchase() ) { |
|
| 275 | - $prepared[] = $value; |
|
| 276 | - } |
|
| 278 | + continue; |
|
| 277 | 279 | |
| 278 | - continue; |
|
| 280 | + } |
|
| 279 | 281 | |
| 280 | - } |
|
| 282 | + // $item_id => $quantity |
|
| 283 | + if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
| 284 | + $item = new GetPaid_Form_Item( $key ); |
|
| 281 | 285 | |
| 282 | - // $item_id => $quantity |
|
| 283 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
| 284 | - $item = new GetPaid_Form_Item( $key ); |
|
| 286 | + if ( $item->can_purchase() ) { |
|
| 287 | + $item->set_quantity( $value ); |
|
| 288 | + $prepared[] = $item; |
|
| 289 | + } |
|
| 285 | 290 | |
| 286 | - if ( $item->can_purchase() ) { |
|
| 287 | - $item->set_quantity( $value ); |
|
| 288 | - $prepared[] = $item; |
|
| 289 | - } |
|
| 291 | + continue; |
|
| 292 | + } |
|
| 290 | 293 | |
| 291 | - continue; |
|
| 292 | - } |
|
| 294 | + if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
| 293 | 295 | |
| 294 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
| 296 | + $item = new GetPaid_Form_Item( $value['id'] ); |
|
| 295 | 297 | |
| 296 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
| 298 | + if ( ! $item->can_purchase() ) { |
|
| 299 | + continue; |
|
| 300 | + } |
|
| 297 | 301 | |
| 298 | - if ( ! $item->can_purchase() ) { |
|
| 299 | - continue; |
|
| 300 | - } |
|
| 302 | + // Sub-total (Cart items). |
|
| 303 | + if ( isset( $value['subtotal'] ) ) { |
|
| 304 | + $item->set_price( $value['subtotal'] ); |
|
| 305 | + } |
|
| 301 | 306 | |
| 302 | - // Sub-total (Cart items). |
|
| 303 | - if ( isset( $value['subtotal'] ) ) { |
|
| 304 | - $item->set_price( $value['subtotal'] ); |
|
| 305 | - } |
|
| 307 | + if ( isset( $value['quantity'] ) ) { |
|
| 308 | + $item->set_quantity( $value['quantity'] ); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + if ( isset( $value['allow_quantities'] ) ) { |
|
| 312 | + $item->set_allow_quantities( $value['allow_quantities'] ); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + if ( isset( $value['required'] ) ) { |
|
| 316 | + $item->set_is_required( $value['required'] ); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + if ( isset( $value['description'] ) ) { |
|
| 320 | + $item->set_custom_description( $value['description'] ); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + $prepared[] = $item; |
|
| 324 | + continue; |
|
| 325 | + |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + if ( 'objects' == $return && 'view' == $context ) { |
|
| 330 | + return $prepared; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + $items = array(); |
|
| 334 | + foreach ( $prepared as $item ) { |
|
| 335 | + $items[] = $item->prepare_data_for_use(); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + return $items; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Get a single item belonging to the form. |
|
| 343 | + * |
|
| 344 | + * @since 1.0.19 |
|
| 345 | + * @param int $item_id The item id to return. |
|
| 346 | + * @return GetPaid_Form_Item|bool |
|
| 347 | + */ |
|
| 348 | + public function get_item( $item_id ) { |
|
| 349 | + |
|
| 350 | + if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
| 351 | + return false; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + foreach( $this->get_items() as $item ) { |
|
| 355 | + if ( $item->get_id() == (int) $item_id ) { |
|
| 356 | + return $item; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + return false; |
|
| 361 | + |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Gets a single element. |
|
| 366 | + * |
|
| 367 | + * @since 1.0.19 |
|
| 368 | + * @param string $element_type The element type to return. |
|
| 369 | + * @return array|bool |
|
| 370 | + */ |
|
| 371 | + public function get_element_type( $element_type ) { |
|
| 372 | + |
|
| 373 | + if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
| 374 | + return false; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
| 378 | + |
|
| 379 | + if ( $element['type'] == $element_type ) { |
|
| 380 | + return $element; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + return false; |
|
| 386 | + |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Get the total amount earned via this form. |
|
| 391 | + * |
|
| 392 | + * @since 1.0.19 |
|
| 393 | + * @param string $context View or edit context. |
|
| 394 | + * @return array |
|
| 395 | + */ |
|
| 396 | + public function get_earned( $context = 'view' ) { |
|
| 397 | + return $this->get_prop( 'earned', $context ); |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * Get the total amount refunded via this form. |
|
| 402 | + * |
|
| 403 | + * @since 1.0.19 |
|
| 404 | + * @param string $context View or edit context. |
|
| 405 | + * @return array |
|
| 406 | + */ |
|
| 407 | + public function get_refunded( $context = 'view' ) { |
|
| 408 | + return $this->get_prop( 'refunded', $context ); |
|
| 409 | + } |
|
| 306 | 410 | |
| 307 | - if ( isset( $value['quantity'] ) ) { |
|
| 308 | - $item->set_quantity( $value['quantity'] ); |
|
| 309 | - } |
|
| 411 | + /** |
|
| 412 | + * Get the total amount cancelled via this form. |
|
| 413 | + * |
|
| 414 | + * @since 1.0.19 |
|
| 415 | + * @param string $context View or edit context. |
|
| 416 | + * @return array |
|
| 417 | + */ |
|
| 418 | + public function get_cancelled( $context = 'view' ) { |
|
| 419 | + return $this->get_prop( 'cancelled', $context ); |
|
| 420 | + } |
|
| 310 | 421 | |
| 311 | - if ( isset( $value['allow_quantities'] ) ) { |
|
| 312 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
| 313 | - } |
|
| 422 | + /** |
|
| 423 | + * Get the total amount failed via this form. |
|
| 424 | + * |
|
| 425 | + * @since 1.0.19 |
|
| 426 | + * @param string $context View or edit context. |
|
| 427 | + * @return array |
|
| 428 | + */ |
|
| 429 | + public function get_failed( $context = 'view' ) { |
|
| 430 | + return $this->get_prop( 'failed', $context ); |
|
| 431 | + } |
|
| 314 | 432 | |
| 315 | - if ( isset( $value['required'] ) ) { |
|
| 316 | - $item->set_is_required( $value['required'] ); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - if ( isset( $value['description'] ) ) { |
|
| 320 | - $item->set_custom_description( $value['description'] ); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - $prepared[] = $item; |
|
| 324 | - continue; |
|
| 325 | - |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - if ( 'objects' == $return && 'view' == $context ) { |
|
| 330 | - return $prepared; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - $items = array(); |
|
| 334 | - foreach ( $prepared as $item ) { |
|
| 335 | - $items[] = $item->prepare_data_for_use(); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - return $items; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Get a single item belonging to the form. |
|
| 343 | - * |
|
| 344 | - * @since 1.0.19 |
|
| 345 | - * @param int $item_id The item id to return. |
|
| 346 | - * @return GetPaid_Form_Item|bool |
|
| 347 | - */ |
|
| 348 | - public function get_item( $item_id ) { |
|
| 349 | - |
|
| 350 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
| 351 | - return false; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - foreach( $this->get_items() as $item ) { |
|
| 355 | - if ( $item->get_id() == (int) $item_id ) { |
|
| 356 | - return $item; |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - return false; |
|
| 361 | - |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Gets a single element. |
|
| 366 | - * |
|
| 367 | - * @since 1.0.19 |
|
| 368 | - * @param string $element_type The element type to return. |
|
| 369 | - * @return array|bool |
|
| 370 | - */ |
|
| 371 | - public function get_element_type( $element_type ) { |
|
| 372 | - |
|
| 373 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
| 374 | - return false; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
| 378 | - |
|
| 379 | - if ( $element['type'] == $element_type ) { |
|
| 380 | - return $element; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - return false; |
|
| 386 | - |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Get the total amount earned via this form. |
|
| 391 | - * |
|
| 392 | - * @since 1.0.19 |
|
| 393 | - * @param string $context View or edit context. |
|
| 394 | - * @return array |
|
| 395 | - */ |
|
| 396 | - public function get_earned( $context = 'view' ) { |
|
| 397 | - return $this->get_prop( 'earned', $context ); |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * Get the total amount refunded via this form. |
|
| 402 | - * |
|
| 403 | - * @since 1.0.19 |
|
| 404 | - * @param string $context View or edit context. |
|
| 405 | - * @return array |
|
| 406 | - */ |
|
| 407 | - public function get_refunded( $context = 'view' ) { |
|
| 408 | - return $this->get_prop( 'refunded', $context ); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Get the total amount cancelled via this form. |
|
| 413 | - * |
|
| 414 | - * @since 1.0.19 |
|
| 415 | - * @param string $context View or edit context. |
|
| 416 | - * @return array |
|
| 417 | - */ |
|
| 418 | - public function get_cancelled( $context = 'view' ) { |
|
| 419 | - return $this->get_prop( 'cancelled', $context ); |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * Get the total amount failed via this form. |
|
| 424 | - * |
|
| 425 | - * @since 1.0.19 |
|
| 426 | - * @param string $context View or edit context. |
|
| 427 | - * @return array |
|
| 428 | - */ |
|
| 429 | - public function get_failed( $context = 'view' ) { |
|
| 430 | - return $this->get_prop( 'failed', $context ); |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * Get the currency. |
|
| 435 | - * |
|
| 436 | - * @since 1.0.19 |
|
| 437 | - * @param string $context View or edit context. |
|
| 438 | - * @return string |
|
| 439 | - */ |
|
| 440 | - public function get_currency() { |
|
| 441 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 442 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
| 443 | - } |
|
| 433 | + /** |
|
| 434 | + * Get the currency. |
|
| 435 | + * |
|
| 436 | + * @since 1.0.19 |
|
| 437 | + * @param string $context View or edit context. |
|
| 438 | + * @return string |
|
| 439 | + */ |
|
| 440 | + public function get_currency() { |
|
| 441 | + $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 442 | + return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | /* |
| 446 | 446 | |-------------------------------------------------------------------------- |
@@ -453,22 +453,22 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | |
| 455 | 455 | /** |
| 456 | - * Set plugin version when the item was created. |
|
| 457 | - * |
|
| 458 | - * @since 1.0.19 |
|
| 459 | - */ |
|
| 460 | - public function set_version( $value ) { |
|
| 461 | - $this->set_prop( 'version', $value ); |
|
| 456 | + * Set plugin version when the item was created. |
|
| 457 | + * |
|
| 458 | + * @since 1.0.19 |
|
| 459 | + */ |
|
| 460 | + public function set_version( $value ) { |
|
| 461 | + $this->set_prop( 'version', $value ); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
| 465 | - * Set date when the item was created. |
|
| 466 | - * |
|
| 467 | - * @since 1.0.19 |
|
| 468 | - * @param string $value Value to set. |
|
| 465 | + * Set date when the item was created. |
|
| 466 | + * |
|
| 467 | + * @since 1.0.19 |
|
| 468 | + * @param string $value Value to set. |
|
| 469 | 469 | * @return bool Whether or not the date was set. |
| 470 | - */ |
|
| 471 | - public function set_date_created( $value ) { |
|
| 470 | + */ |
|
| 471 | + public function set_date_created( $value ) { |
|
| 472 | 472 | $date = strtotime( $value ); |
| 473 | 473 | |
| 474 | 474 | if ( $date ) { |
@@ -481,13 +481,13 @@ discard block |
||
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
| 484 | - * Set date when the item was last modified. |
|
| 485 | - * |
|
| 486 | - * @since 1.0.19 |
|
| 487 | - * @param string $value Value to set. |
|
| 484 | + * Set date when the item was last modified. |
|
| 485 | + * |
|
| 486 | + * @since 1.0.19 |
|
| 487 | + * @param string $value Value to set. |
|
| 488 | 488 | * @return bool Whether or not the date was set. |
| 489 | - */ |
|
| 490 | - public function set_date_modified( $value ) { |
|
| 489 | + */ |
|
| 490 | + public function set_date_modified( $value ) { |
|
| 491 | 491 | $date = strtotime( $value ); |
| 492 | 492 | |
| 493 | 493 | if ( $date ) { |
@@ -500,118 +500,118 @@ discard block |
||
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
| 503 | - * Set the item name. |
|
| 504 | - * |
|
| 505 | - * @since 1.0.19 |
|
| 506 | - * @param string $value New name. |
|
| 507 | - */ |
|
| 508 | - public function set_name( $value ) { |
|
| 509 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * Alias of self::set_name(). |
|
| 514 | - * |
|
| 515 | - * @since 1.0.19 |
|
| 516 | - * @param string $value New name. |
|
| 517 | - */ |
|
| 518 | - public function set_title( $value ) { |
|
| 519 | - $this->set_name( $value ); |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * Set the owner of the item. |
|
| 524 | - * |
|
| 525 | - * @since 1.0.19 |
|
| 526 | - * @param int $value New author. |
|
| 527 | - */ |
|
| 528 | - public function set_author( $value ) { |
|
| 529 | - $this->set_prop( 'author', (int) $value ); |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * Set the form elements. |
|
| 534 | - * |
|
| 535 | - * @since 1.0.19 |
|
| 536 | - * @param array $value Form elements. |
|
| 537 | - */ |
|
| 538 | - public function set_elements( $value ) { |
|
| 539 | - if ( is_array( $value ) ) { |
|
| 540 | - $this->set_prop( 'elements', $value ); |
|
| 541 | - } |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - /** |
|
| 545 | - * Set the form items. |
|
| 546 | - * |
|
| 547 | - * @since 1.0.19 |
|
| 548 | - * @param array $value Form elements. |
|
| 549 | - */ |
|
| 550 | - public function set_items( $value ) { |
|
| 551 | - if ( is_array( $value ) ) { |
|
| 552 | - $this->set_prop( 'items', $value ); |
|
| 553 | - } |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * Set the total amount earned via this form. |
|
| 558 | - * |
|
| 559 | - * @since 1.0.19 |
|
| 560 | - * @param float $value Amount earned. |
|
| 561 | - * @return array |
|
| 562 | - */ |
|
| 563 | - public function set_earned( $value ) { |
|
| 564 | - return $this->set_prop( 'earned', (float) $value ); |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Set the total amount refunded via this form. |
|
| 569 | - * |
|
| 570 | - * @since 1.0.19 |
|
| 571 | - * @param float $value Amount refunded. |
|
| 572 | - * @return array |
|
| 573 | - */ |
|
| 574 | - public function set_refunded( $value ) { |
|
| 575 | - return $this->set_prop( 'refunded', (float) $value ); |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - /** |
|
| 579 | - * Set the total amount cancelled via this form. |
|
| 580 | - * |
|
| 581 | - * @since 1.0.19 |
|
| 582 | - * @param float $value Amount cancelled. |
|
| 583 | - * @return array |
|
| 584 | - */ |
|
| 585 | - public function set_cancelled( $value ) { |
|
| 586 | - return $this->set_prop( 'cancelled', (float) $value ); |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * Set the total amount failed via this form. |
|
| 591 | - * |
|
| 592 | - * @since 1.0.19 |
|
| 593 | - * @param float $value Amount cancelled. |
|
| 594 | - * @return array |
|
| 595 | - */ |
|
| 596 | - public function set_failed( $value ) { |
|
| 597 | - return $this->set_prop( 'failed', (float) $value ); |
|
| 598 | - } |
|
| 503 | + * Set the item name. |
|
| 504 | + * |
|
| 505 | + * @since 1.0.19 |
|
| 506 | + * @param string $value New name. |
|
| 507 | + */ |
|
| 508 | + public function set_name( $value ) { |
|
| 509 | + $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * Alias of self::set_name(). |
|
| 514 | + * |
|
| 515 | + * @since 1.0.19 |
|
| 516 | + * @param string $value New name. |
|
| 517 | + */ |
|
| 518 | + public function set_title( $value ) { |
|
| 519 | + $this->set_name( $value ); |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * Set the owner of the item. |
|
| 524 | + * |
|
| 525 | + * @since 1.0.19 |
|
| 526 | + * @param int $value New author. |
|
| 527 | + */ |
|
| 528 | + public function set_author( $value ) { |
|
| 529 | + $this->set_prop( 'author', (int) $value ); |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * Set the form elements. |
|
| 534 | + * |
|
| 535 | + * @since 1.0.19 |
|
| 536 | + * @param array $value Form elements. |
|
| 537 | + */ |
|
| 538 | + public function set_elements( $value ) { |
|
| 539 | + if ( is_array( $value ) ) { |
|
| 540 | + $this->set_prop( 'elements', $value ); |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + /** |
|
| 545 | + * Set the form items. |
|
| 546 | + * |
|
| 547 | + * @since 1.0.19 |
|
| 548 | + * @param array $value Form elements. |
|
| 549 | + */ |
|
| 550 | + public function set_items( $value ) { |
|
| 551 | + if ( is_array( $value ) ) { |
|
| 552 | + $this->set_prop( 'items', $value ); |
|
| 553 | + } |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * Set the total amount earned via this form. |
|
| 558 | + * |
|
| 559 | + * @since 1.0.19 |
|
| 560 | + * @param float $value Amount earned. |
|
| 561 | + * @return array |
|
| 562 | + */ |
|
| 563 | + public function set_earned( $value ) { |
|
| 564 | + return $this->set_prop( 'earned', (float) $value ); |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * Set the total amount refunded via this form. |
|
| 569 | + * |
|
| 570 | + * @since 1.0.19 |
|
| 571 | + * @param float $value Amount refunded. |
|
| 572 | + * @return array |
|
| 573 | + */ |
|
| 574 | + public function set_refunded( $value ) { |
|
| 575 | + return $this->set_prop( 'refunded', (float) $value ); |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + /** |
|
| 579 | + * Set the total amount cancelled via this form. |
|
| 580 | + * |
|
| 581 | + * @since 1.0.19 |
|
| 582 | + * @param float $value Amount cancelled. |
|
| 583 | + * @return array |
|
| 584 | + */ |
|
| 585 | + public function set_cancelled( $value ) { |
|
| 586 | + return $this->set_prop( 'cancelled', (float) $value ); |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * Set the total amount failed via this form. |
|
| 591 | + * |
|
| 592 | + * @since 1.0.19 |
|
| 593 | + * @param float $value Amount cancelled. |
|
| 594 | + * @return array |
|
| 595 | + */ |
|
| 596 | + public function set_failed( $value ) { |
|
| 597 | + return $this->set_prop( 'failed', (float) $value ); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | /** |
| 601 | 601 | * Create an item. For backwards compatibilty. |
| 602 | 602 | * |
| 603 | 603 | * @deprecated |
| 604 | - * @return int item id |
|
| 604 | + * @return int item id |
|
| 605 | 605 | */ |
| 606 | 606 | public function create( $data = array() ) { |
| 607 | 607 | |
| 608 | - // Set the properties. |
|
| 609 | - if ( is_array( $data ) ) { |
|
| 610 | - $this->set_props( $data ); |
|
| 611 | - } |
|
| 608 | + // Set the properties. |
|
| 609 | + if ( is_array( $data ) ) { |
|
| 610 | + $this->set_props( $data ); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - // Save the item. |
|
| 614 | - return $this->save(); |
|
| 613 | + // Save the item. |
|
| 614 | + return $this->save(); |
|
| 615 | 615 | |
| 616 | 616 | } |
| 617 | 617 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * Updates an item. For backwards compatibilty. |
| 620 | 620 | * |
| 621 | 621 | * @deprecated |
| 622 | - * @return int item id |
|
| 622 | + * @return int item id |
|
| 623 | 623 | */ |
| 624 | 624 | public function update( $data = array() ) { |
| 625 | 625 | return $this->create( $data ); |
@@ -635,22 +635,22 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | |
| 637 | 637 | /** |
| 638 | - * Checks whether this is the default payment form. |
|
| 639 | - * |
|
| 640 | - * @since 1.0.19 |
|
| 641 | - * @return bool |
|
| 642 | - */ |
|
| 638 | + * Checks whether this is the default payment form. |
|
| 639 | + * |
|
| 640 | + * @since 1.0.19 |
|
| 641 | + * @return bool |
|
| 642 | + */ |
|
| 643 | 643 | public function is_default() { |
| 644 | 644 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
| 645 | 645 | return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
| 646 | - } |
|
| 646 | + } |
|
| 647 | 647 | |
| 648 | 648 | /** |
| 649 | - * Checks whether the form is active. |
|
| 650 | - * |
|
| 651 | - * @since 1.0.19 |
|
| 652 | - * @return bool |
|
| 653 | - */ |
|
| 649 | + * Checks whether the form is active. |
|
| 650 | + * |
|
| 651 | + * @since 1.0.19 |
|
| 652 | + * @return bool |
|
| 653 | + */ |
|
| 654 | 654 | public function is_active() { |
| 655 | 655 | $is_active = 0 !== (int) $this->get_id(); |
| 656 | 656 | |
@@ -659,70 +659,70 @@ discard block |
||
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
| 662 | - } |
|
| 663 | - |
|
| 664 | - /** |
|
| 665 | - * Checks whether the form has a given item. |
|
| 666 | - * |
|
| 667 | - * @since 1.0.19 |
|
| 668 | - * @return bool |
|
| 669 | - */ |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + /** |
|
| 665 | + * Checks whether the form has a given item. |
|
| 666 | + * |
|
| 667 | + * @since 1.0.19 |
|
| 668 | + * @return bool |
|
| 669 | + */ |
|
| 670 | 670 | public function has_item( $item_id ) { |
| 671 | 671 | return false !== $this->get_item( $item_id ); |
| 672 | - } |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * Checks whether the form has a given element. |
|
| 676 | - * |
|
| 677 | - * @since 1.0.19 |
|
| 678 | - * @return bool |
|
| 679 | - */ |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * Checks whether the form has a given element. |
|
| 676 | + * |
|
| 677 | + * @since 1.0.19 |
|
| 678 | + * @return bool |
|
| 679 | + */ |
|
| 680 | 680 | public function has_element_type( $element_type ) { |
| 681 | 681 | return false !== $this->get_element_type( $element_type ); |
| 682 | - } |
|
| 683 | - |
|
| 684 | - /** |
|
| 685 | - * Checks whether this form is recurring or not. |
|
| 686 | - * |
|
| 687 | - * @since 1.0.19 |
|
| 688 | - * @return bool |
|
| 689 | - */ |
|
| 682 | + } |
|
| 683 | + |
|
| 684 | + /** |
|
| 685 | + * Checks whether this form is recurring or not. |
|
| 686 | + * |
|
| 687 | + * @since 1.0.19 |
|
| 688 | + * @return bool |
|
| 689 | + */ |
|
| 690 | 690 | public function is_recurring() { |
| 691 | 691 | |
| 692 | - if ( ! empty( $this->invoice ) ) { |
|
| 693 | - return $this->invoice->is_recurring(); |
|
| 694 | - } |
|
| 692 | + if ( ! empty( $this->invoice ) ) { |
|
| 693 | + return $this->invoice->is_recurring(); |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | - foreach ( $this->get_items() as $item ) { |
|
| 696 | + foreach ( $this->get_items() as $item ) { |
|
| 697 | 697 | |
| 698 | - if ( $item->is_recurring() ) { |
|
| 699 | - return true; |
|
| 700 | - } |
|
| 698 | + if ( $item->is_recurring() ) { |
|
| 699 | + return true; |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | - } |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | 704 | return false; |
| 705 | - } |
|
| 705 | + } |
|
| 706 | 706 | |
| 707 | - /** |
|
| 708 | - * Retrieves the form's html. |
|
| 709 | - * |
|
| 710 | - * @since 1.0.19 |
|
| 711 | - */ |
|
| 707 | + /** |
|
| 708 | + * Retrieves the form's html. |
|
| 709 | + * |
|
| 710 | + * @since 1.0.19 |
|
| 711 | + */ |
|
| 712 | 712 | public function get_html() { |
| 713 | 713 | |
| 714 | - // Return the HTML. |
|
| 715 | - return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) ); |
|
| 714 | + // Return the HTML. |
|
| 715 | + return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) ); |
|
| 716 | 716 | |
| 717 | - } |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | - /** |
|
| 720 | - * Displays the payment form. |
|
| 721 | - * |
|
| 722 | - * @since 1.0.19 |
|
| 723 | - */ |
|
| 719 | + /** |
|
| 720 | + * Displays the payment form. |
|
| 721 | + * |
|
| 722 | + * @since 1.0.19 |
|
| 723 | + */ |
|
| 724 | 724 | public function display() { |
| 725 | - echo $this->get_html(); |
|
| 725 | + echo $this->get_html(); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
| 74 | 74 | */ |
| 75 | - public function __construct( $form = 0 ) { |
|
| 76 | - parent::__construct( $form ); |
|
| 75 | + public function __construct($form = 0) { |
|
| 76 | + parent::__construct($form); |
|
| 77 | 77 | |
| 78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
| 79 | - $this->set_id( $form ); |
|
| 80 | - } elseif ( $form instanceof self ) { |
|
| 78 | + if (is_numeric($form) && $form > 0) { |
|
| 79 | + $this->set_id($form); |
|
| 80 | + } elseif ($form instanceof self) { |
|
| 81 | 81 | |
| 82 | - $this->set_id( $form->get_id() ); |
|
| 82 | + $this->set_id($form->get_id()); |
|
| 83 | 83 | $this->invoice = $form->invoice; |
| 84 | 84 | |
| 85 | - } elseif ( ! empty( $form->ID ) ) { |
|
| 86 | - $this->set_id( $form->ID ); |
|
| 85 | + } elseif (!empty($form->ID)) { |
|
| 86 | + $this->set_id($form->ID); |
|
| 87 | 87 | } else { |
| 88 | - $this->set_object_read( true ); |
|
| 88 | + $this->set_object_read(true); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Load the datastore. |
| 92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 93 | 93 | |
| 94 | - if ( $this->get_id() > 0 ) { |
|
| 95 | - $this->post = get_post( $this->get_id() ); |
|
| 96 | - $this->data_store->read( $this ); |
|
| 94 | + if ($this->get_id() > 0) { |
|
| 95 | + $this->post = get_post($this->get_id()); |
|
| 96 | + $this->data_store->read($this); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | * @param string $context View or edit context. |
| 121 | 121 | * @return string |
| 122 | 122 | */ |
| 123 | - public function get_version( $context = 'view' ) { |
|
| 124 | - return $this->get_prop( 'version', $context ); |
|
| 123 | + public function get_version($context = 'view') { |
|
| 124 | + return $this->get_prop('version', $context); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @param string $context View or edit context. |
| 132 | 132 | * @return string |
| 133 | 133 | */ |
| 134 | - public function get_date_created( $context = 'view' ) { |
|
| 135 | - return $this->get_prop( 'date_created', $context ); |
|
| 134 | + public function get_date_created($context = 'view') { |
|
| 135 | + return $this->get_prop('date_created', $context); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | * @param string $context View or edit context. |
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 146 | - $date = $this->get_date_created( $context ); |
|
| 145 | + public function get_date_created_gmt($context = 'view') { |
|
| 146 | + $date = $this->get_date_created($context); |
|
| 147 | 147 | |
| 148 | - if ( $date ) { |
|
| 149 | - $date = get_gmt_from_date( $date ); |
|
| 148 | + if ($date) { |
|
| 149 | + $date = get_gmt_from_date($date); |
|
| 150 | 150 | } |
| 151 | 151 | return $date; |
| 152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @param string $context View or edit context. |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - public function get_date_modified( $context = 'view' ) { |
|
| 162 | - return $this->get_prop( 'date_modified', $context ); |
|
| 161 | + public function get_date_modified($context = 'view') { |
|
| 162 | + return $this->get_prop('date_modified', $context); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | * @param string $context View or edit context. |
| 170 | 170 | * @return string |
| 171 | 171 | */ |
| 172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 173 | - $date = $this->get_date_modified( $context ); |
|
| 172 | + public function get_date_modified_gmt($context = 'view') { |
|
| 173 | + $date = $this->get_date_modified($context); |
|
| 174 | 174 | |
| 175 | - if ( $date ) { |
|
| 176 | - $date = get_gmt_from_date( $date ); |
|
| 175 | + if ($date) { |
|
| 176 | + $date = get_gmt_from_date($date); |
|
| 177 | 177 | } |
| 178 | 178 | return $date; |
| 179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | * @param string $context View or edit context. |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - public function get_name( $context = 'view' ) { |
|
| 189 | - return $this->get_prop( 'name', $context ); |
|
| 188 | + public function get_name($context = 'view') { |
|
| 189 | + return $this->get_prop('name', $context); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | * @param string $context View or edit context. |
| 197 | 197 | * @return string |
| 198 | 198 | */ |
| 199 | - public function get_title( $context = 'view' ) { |
|
| 200 | - return $this->get_name( $context ); |
|
| 199 | + public function get_title($context = 'view') { |
|
| 200 | + return $this->get_name($context); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | * @param string $context View or edit context. |
| 208 | 208 | * @return int |
| 209 | 209 | */ |
| 210 | - public function get_author( $context = 'view' ) { |
|
| 211 | - return (int) $this->get_prop( 'author', $context ); |
|
| 210 | + public function get_author($context = 'view') { |
|
| 211 | + return (int) $this->get_prop('author', $context); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
| 218 | 218 | * @param string $context View or edit context. |
| 219 | 219 | * @return array |
| 220 | 220 | */ |
| 221 | - public function get_elements( $context = 'view' ) { |
|
| 222 | - $elements = $this->get_prop( 'elements', $context ); |
|
| 221 | + public function get_elements($context = 'view') { |
|
| 222 | + $elements = $this->get_prop('elements', $context); |
|
| 223 | 223 | |
| 224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
| 225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
| 224 | + if (empty($elements) || !is_array($elements)) { |
|
| 225 | + return wpinv_get_data('sample-payment-form'); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Ensure that all required elements exist. |
| 229 | 229 | $_elements = array(); |
| 230 | - foreach ( $elements as $element ) { |
|
| 230 | + foreach ($elements as $element) { |
|
| 231 | 231 | |
| 232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
| 232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
| 233 | 233 | |
| 234 | 234 | $_elements[] = array( |
| 235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
| 236 | 236 | 'id' => 'gtscicd', |
| 237 | 237 | 'name' => 'gtscicd', |
| 238 | 238 | 'type' => 'gateway_select', |
@@ -257,21 +257,21 @@ discard block |
||
| 257 | 257 | * @param string $return objects or arrays. |
| 258 | 258 | * @return GetPaid_Form_Item[] |
| 259 | 259 | */ |
| 260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
| 261 | - $items = $this->get_prop( 'items', $context ); |
|
| 260 | + public function get_items($context = 'view', $return = 'objects') { |
|
| 261 | + $items = $this->get_prop('items', $context); |
|
| 262 | 262 | |
| 263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
| 264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
| 263 | + if (empty($items) || !is_array($items)) { |
|
| 264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Convert the items. |
| 268 | 268 | $prepared = array(); |
| 269 | 269 | |
| 270 | - foreach ( $items as $key => $value ) { |
|
| 270 | + foreach ($items as $key => $value) { |
|
| 271 | 271 | |
| 272 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
| 272 | + if ($value instanceof GetPaid_Form_Item) { |
|
| 273 | 273 | |
| 274 | - if ( $value->can_purchase() ) { |
|
| 274 | + if ($value->can_purchase()) { |
|
| 275 | 275 | $prepared[] = $value; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -280,44 +280,44 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // $item_id => $quantity |
| 283 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
| 284 | - $item = new GetPaid_Form_Item( $key ); |
|
| 283 | + if (is_numeric($key) && is_numeric($value)) { |
|
| 284 | + $item = new GetPaid_Form_Item($key); |
|
| 285 | 285 | |
| 286 | - if ( $item->can_purchase() ) { |
|
| 287 | - $item->set_quantity( $value ); |
|
| 286 | + if ($item->can_purchase()) { |
|
| 287 | + $item->set_quantity($value); |
|
| 288 | 288 | $prepared[] = $item; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | continue; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
| 294 | + if (is_array($value) && isset($value['id'])) { |
|
| 295 | 295 | |
| 296 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
| 296 | + $item = new GetPaid_Form_Item($value['id']); |
|
| 297 | 297 | |
| 298 | - if ( ! $item->can_purchase() ) { |
|
| 298 | + if (!$item->can_purchase()) { |
|
| 299 | 299 | continue; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Sub-total (Cart items). |
| 303 | - if ( isset( $value['subtotal'] ) ) { |
|
| 304 | - $item->set_price( $value['subtotal'] ); |
|
| 303 | + if (isset($value['subtotal'])) { |
|
| 304 | + $item->set_price($value['subtotal']); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ( isset( $value['quantity'] ) ) { |
|
| 308 | - $item->set_quantity( $value['quantity'] ); |
|
| 307 | + if (isset($value['quantity'])) { |
|
| 308 | + $item->set_quantity($value['quantity']); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if ( isset( $value['allow_quantities'] ) ) { |
|
| 312 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
| 311 | + if (isset($value['allow_quantities'])) { |
|
| 312 | + $item->set_allow_quantities($value['allow_quantities']); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - if ( isset( $value['required'] ) ) { |
|
| 316 | - $item->set_is_required( $value['required'] ); |
|
| 315 | + if (isset($value['required'])) { |
|
| 316 | + $item->set_is_required($value['required']); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if ( isset( $value['description'] ) ) { |
|
| 320 | - $item->set_custom_description( $value['description'] ); |
|
| 319 | + if (isset($value['description'])) { |
|
| 320 | + $item->set_custom_description($value['description']); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | $prepared[] = $item; |
@@ -326,12 +326,12 @@ discard block |
||
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( 'objects' == $return && 'view' == $context ) { |
|
| 329 | + if ('objects' == $return && 'view' == $context) { |
|
| 330 | 330 | return $prepared; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | $items = array(); |
| 334 | - foreach ( $prepared as $item ) { |
|
| 334 | + foreach ($prepared as $item) { |
|
| 335 | 335 | $items[] = $item->prepare_data_for_use(); |
| 336 | 336 | } |
| 337 | 337 | |
@@ -345,14 +345,14 @@ discard block |
||
| 345 | 345 | * @param int $item_id The item id to return. |
| 346 | 346 | * @return GetPaid_Form_Item|bool |
| 347 | 347 | */ |
| 348 | - public function get_item( $item_id ) { |
|
| 348 | + public function get_item($item_id) { |
|
| 349 | 349 | |
| 350 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
| 350 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
| 351 | 351 | return false; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - foreach( $this->get_items() as $item ) { |
|
| 355 | - if ( $item->get_id() == (int) $item_id ) { |
|
| 354 | + foreach ($this->get_items() as $item) { |
|
| 355 | + if ($item->get_id() == (int) $item_id) { |
|
| 356 | 356 | return $item; |
| 357 | 357 | } |
| 358 | 358 | } |
@@ -368,15 +368,15 @@ discard block |
||
| 368 | 368 | * @param string $element_type The element type to return. |
| 369 | 369 | * @return array|bool |
| 370 | 370 | */ |
| 371 | - public function get_element_type( $element_type ) { |
|
| 371 | + public function get_element_type($element_type) { |
|
| 372 | 372 | |
| 373 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
| 373 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
| 374 | 374 | return false; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
| 377 | + foreach ($this->get_prop('elements') as $element) { |
|
| 378 | 378 | |
| 379 | - if ( $element['type'] == $element_type ) { |
|
| 379 | + if ($element['type'] == $element_type) { |
|
| 380 | 380 | return $element; |
| 381 | 381 | } |
| 382 | 382 | |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | * @param string $context View or edit context. |
| 394 | 394 | * @return array |
| 395 | 395 | */ |
| 396 | - public function get_earned( $context = 'view' ) { |
|
| 397 | - return $this->get_prop( 'earned', $context ); |
|
| 396 | + public function get_earned($context = 'view') { |
|
| 397 | + return $this->get_prop('earned', $context); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * @param string $context View or edit context. |
| 405 | 405 | * @return array |
| 406 | 406 | */ |
| 407 | - public function get_refunded( $context = 'view' ) { |
|
| 408 | - return $this->get_prop( 'refunded', $context ); |
|
| 407 | + public function get_refunded($context = 'view') { |
|
| 408 | + return $this->get_prop('refunded', $context); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | * @param string $context View or edit context. |
| 416 | 416 | * @return array |
| 417 | 417 | */ |
| 418 | - public function get_cancelled( $context = 'view' ) { |
|
| 419 | - return $this->get_prop( 'cancelled', $context ); |
|
| 418 | + public function get_cancelled($context = 'view') { |
|
| 419 | + return $this->get_prop('cancelled', $context); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /** |
@@ -426,8 +426,8 @@ discard block |
||
| 426 | 426 | * @param string $context View or edit context. |
| 427 | 427 | * @return array |
| 428 | 428 | */ |
| 429 | - public function get_failed( $context = 'view' ) { |
|
| 430 | - return $this->get_prop( 'failed', $context ); |
|
| 429 | + public function get_failed($context = 'view') { |
|
| 430 | + return $this->get_prop('failed', $context); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -438,8 +438,8 @@ discard block |
||
| 438 | 438 | * @return string |
| 439 | 439 | */ |
| 440 | 440 | public function get_currency() { |
| 441 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 442 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
| 441 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 442 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /* |
@@ -457,8 +457,8 @@ discard block |
||
| 457 | 457 | * |
| 458 | 458 | * @since 1.0.19 |
| 459 | 459 | */ |
| 460 | - public function set_version( $value ) { |
|
| 461 | - $this->set_prop( 'version', $value ); |
|
| 460 | + public function set_version($value) { |
|
| 461 | + $this->set_prop('version', $value); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -468,11 +468,11 @@ discard block |
||
| 468 | 468 | * @param string $value Value to set. |
| 469 | 469 | * @return bool Whether or not the date was set. |
| 470 | 470 | */ |
| 471 | - public function set_date_created( $value ) { |
|
| 472 | - $date = strtotime( $value ); |
|
| 471 | + public function set_date_created($value) { |
|
| 472 | + $date = strtotime($value); |
|
| 473 | 473 | |
| 474 | - if ( $date ) { |
|
| 475 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 474 | + if ($date) { |
|
| 475 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 476 | 476 | return true; |
| 477 | 477 | } |
| 478 | 478 | |
@@ -487,11 +487,11 @@ discard block |
||
| 487 | 487 | * @param string $value Value to set. |
| 488 | 488 | * @return bool Whether or not the date was set. |
| 489 | 489 | */ |
| 490 | - public function set_date_modified( $value ) { |
|
| 491 | - $date = strtotime( $value ); |
|
| 490 | + public function set_date_modified($value) { |
|
| 491 | + $date = strtotime($value); |
|
| 492 | 492 | |
| 493 | - if ( $date ) { |
|
| 494 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 493 | + if ($date) { |
|
| 494 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 495 | 495 | return true; |
| 496 | 496 | } |
| 497 | 497 | |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | * @since 1.0.19 |
| 506 | 506 | * @param string $value New name. |
| 507 | 507 | */ |
| 508 | - public function set_name( $value ) { |
|
| 509 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
| 508 | + public function set_name($value) { |
|
| 509 | + $this->set_prop('name', sanitize_text_field($value)); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | * @since 1.0.19 |
| 516 | 516 | * @param string $value New name. |
| 517 | 517 | */ |
| 518 | - public function set_title( $value ) { |
|
| 519 | - $this->set_name( $value ); |
|
| 518 | + public function set_title($value) { |
|
| 519 | + $this->set_name($value); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -525,8 +525,8 @@ discard block |
||
| 525 | 525 | * @since 1.0.19 |
| 526 | 526 | * @param int $value New author. |
| 527 | 527 | */ |
| 528 | - public function set_author( $value ) { |
|
| 529 | - $this->set_prop( 'author', (int) $value ); |
|
| 528 | + public function set_author($value) { |
|
| 529 | + $this->set_prop('author', (int) $value); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -535,9 +535,9 @@ discard block |
||
| 535 | 535 | * @since 1.0.19 |
| 536 | 536 | * @param array $value Form elements. |
| 537 | 537 | */ |
| 538 | - public function set_elements( $value ) { |
|
| 539 | - if ( is_array( $value ) ) { |
|
| 540 | - $this->set_prop( 'elements', $value ); |
|
| 538 | + public function set_elements($value) { |
|
| 539 | + if (is_array($value)) { |
|
| 540 | + $this->set_prop('elements', $value); |
|
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | * @since 1.0.19 |
| 548 | 548 | * @param array $value Form elements. |
| 549 | 549 | */ |
| 550 | - public function set_items( $value ) { |
|
| 551 | - if ( is_array( $value ) ) { |
|
| 552 | - $this->set_prop( 'items', $value ); |
|
| 550 | + public function set_items($value) { |
|
| 551 | + if (is_array($value)) { |
|
| 552 | + $this->set_prop('items', $value); |
|
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | * @param float $value Amount earned. |
| 561 | 561 | * @return array |
| 562 | 562 | */ |
| 563 | - public function set_earned( $value ) { |
|
| 564 | - return $this->set_prop( 'earned', (float) $value ); |
|
| 563 | + public function set_earned($value) { |
|
| 564 | + return $this->set_prop('earned', (float) $value); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /** |
@@ -571,8 +571,8 @@ discard block |
||
| 571 | 571 | * @param float $value Amount refunded. |
| 572 | 572 | * @return array |
| 573 | 573 | */ |
| 574 | - public function set_refunded( $value ) { |
|
| 575 | - return $this->set_prop( 'refunded', (float) $value ); |
|
| 574 | + public function set_refunded($value) { |
|
| 575 | + return $this->set_prop('refunded', (float) $value); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -582,8 +582,8 @@ discard block |
||
| 582 | 582 | * @param float $value Amount cancelled. |
| 583 | 583 | * @return array |
| 584 | 584 | */ |
| 585 | - public function set_cancelled( $value ) { |
|
| 586 | - return $this->set_prop( 'cancelled', (float) $value ); |
|
| 585 | + public function set_cancelled($value) { |
|
| 586 | + return $this->set_prop('cancelled', (float) $value); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | * @param float $value Amount cancelled. |
| 594 | 594 | * @return array |
| 595 | 595 | */ |
| 596 | - public function set_failed( $value ) { |
|
| 597 | - return $this->set_prop( 'failed', (float) $value ); |
|
| 596 | + public function set_failed($value) { |
|
| 597 | + return $this->set_prop('failed', (float) $value); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -603,11 +603,11 @@ discard block |
||
| 603 | 603 | * @deprecated |
| 604 | 604 | * @return int item id |
| 605 | 605 | */ |
| 606 | - public function create( $data = array() ) { |
|
| 606 | + public function create($data = array()) { |
|
| 607 | 607 | |
| 608 | 608 | // Set the properties. |
| 609 | - if ( is_array( $data ) ) { |
|
| 610 | - $this->set_props( $data ); |
|
| 609 | + if (is_array($data)) { |
|
| 610 | + $this->set_props($data); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | // Save the item. |
@@ -621,8 +621,8 @@ discard block |
||
| 621 | 621 | * @deprecated |
| 622 | 622 | * @return int item id |
| 623 | 623 | */ |
| 624 | - public function update( $data = array() ) { |
|
| 625 | - return $this->create( $data ); |
|
| 624 | + public function update($data = array()) { |
|
| 625 | + return $this->create($data); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | /* |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | */ |
| 643 | 643 | public function is_default() { |
| 644 | 644 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
| 645 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
| 645 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | /** |
@@ -654,11 +654,11 @@ discard block |
||
| 654 | 654 | public function is_active() { |
| 655 | 655 | $is_active = 0 !== (int) $this->get_id(); |
| 656 | 656 | |
| 657 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
| 657 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
| 658 | 658 | $is_active = false; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
| 661 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | * @since 1.0.19 |
| 668 | 668 | * @return bool |
| 669 | 669 | */ |
| 670 | - public function has_item( $item_id ) { |
|
| 671 | - return false !== $this->get_item( $item_id ); |
|
| 670 | + public function has_item($item_id) { |
|
| 671 | + return false !== $this->get_item($item_id); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -677,8 +677,8 @@ discard block |
||
| 677 | 677 | * @since 1.0.19 |
| 678 | 678 | * @return bool |
| 679 | 679 | */ |
| 680 | - public function has_element_type( $element_type ) { |
|
| 681 | - return false !== $this->get_element_type( $element_type ); |
|
| 680 | + public function has_element_type($element_type) { |
|
| 681 | + return false !== $this->get_element_type($element_type); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | /** |
@@ -689,13 +689,13 @@ discard block |
||
| 689 | 689 | */ |
| 690 | 690 | public function is_recurring() { |
| 691 | 691 | |
| 692 | - if ( ! empty( $this->invoice ) ) { |
|
| 692 | + if (!empty($this->invoice)) { |
|
| 693 | 693 | return $this->invoice->is_recurring(); |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - foreach ( $this->get_items() as $item ) { |
|
| 696 | + foreach ($this->get_items() as $item) { |
|
| 697 | 697 | |
| 698 | - if ( $item->is_recurring() ) { |
|
| 698 | + if ($item->is_recurring()) { |
|
| 699 | 699 | return true; |
| 700 | 700 | } |
| 701 | 701 | |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | public function get_html() { |
| 713 | 713 | |
| 714 | 714 | // Return the HTML. |
| 715 | - return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) ); |
|
| 715 | + return wpinv_get_template_html('payment-forms/form.php', array('form' => $this)); |
|
| 716 | 716 | |
| 717 | 717 | } |
| 718 | 718 | |