@@ -277,26 +277,26 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
| 280 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 280 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 281 | 281 | |
| 282 | 282 | $chosen = false; |
| 283 | 283 | if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
| 284 | 284 | $chosen = $invoice->get_gateway(); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
| 287 | + $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
| 288 | 288 | |
| 289 | - if ( false !== $chosen ) { |
|
| 290 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
| 291 | - } |
|
| 289 | + if ( false !== $chosen ) { |
|
| 290 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - if ( ! empty ( $chosen ) ) { |
|
| 294 | - $enabled_gateway = urldecode( $chosen ); |
|
| 295 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
| 296 | - $enabled_gateway = 'manual'; |
|
| 297 | - } else { |
|
| 298 | - $enabled_gateway = wpinv_get_default_gateway(); |
|
| 299 | - } |
|
| 293 | + if ( ! empty ( $chosen ) ) { |
|
| 294 | + $enabled_gateway = urldecode( $chosen ); |
|
| 295 | + } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
| 296 | + $enabled_gateway = 'manual'; |
|
| 297 | + } else { |
|
| 298 | + $enabled_gateway = wpinv_get_default_gateway(); |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | 301 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
| 302 | 302 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
| 310 | + return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | function wpinv_record_gateway_error( $title = '', $message = '' ) { |
@@ -315,21 +315,21 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
| 318 | - $ret = 0; |
|
| 319 | - $args = array( |
|
| 320 | - 'meta_key' => '_wpinv_gateway', |
|
| 321 | - 'meta_value' => $gateway_id, |
|
| 322 | - 'nopaging' => true, |
|
| 323 | - 'post_type' => 'wpi_invoice', |
|
| 324 | - 'post_status' => $status, |
|
| 325 | - 'fields' => 'ids' |
|
| 326 | - ); |
|
| 327 | - |
|
| 328 | - $payments = new WP_Query( $args ); |
|
| 329 | - |
|
| 330 | - if( $payments ) |
|
| 331 | - $ret = $payments->post_count; |
|
| 332 | - return $ret; |
|
| 318 | + $ret = 0; |
|
| 319 | + $args = array( |
|
| 320 | + 'meta_key' => '_wpinv_gateway', |
|
| 321 | + 'meta_value' => $gateway_id, |
|
| 322 | + 'nopaging' => true, |
|
| 323 | + 'post_type' => 'wpi_invoice', |
|
| 324 | + 'post_status' => $status, |
|
| 325 | + 'fields' => 'ids' |
|
| 326 | + ); |
|
| 327 | + |
|
| 328 | + $payments = new WP_Query( $args ); |
|
| 329 | + |
|
| 330 | + if( $payments ) |
|
| 331 | + $ret = $payments->post_count; |
|
| 332 | + return $ret; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | // PayPal Standard settings |