@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -13,128 +13,128 @@ |
||
| 13 | 13 | class GetPaid_Payment_Forms { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Class constructor |
|
| 17 | - * |
|
| 18 | - */ |
|
| 19 | - public function __construct() { |
|
| 20 | - |
|
| 21 | - // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
| 22 | - add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
| 23 | - add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
| 24 | - |
|
| 25 | - // Sync form amount whenever invoice statuses change. |
|
| 26 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
| 27 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
| 28 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
| 29 | - |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Increments a form's revenue whenever there is a payment. |
|
| 34 | - * |
|
| 35 | - * @param WPInv_Invoice $invoice |
|
| 36 | - */ |
|
| 37 | - public function increment_form_revenue( $invoice ) { |
|
| 38 | - |
|
| 39 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 40 | - if ( $form->get_id() ) { |
|
| 41 | - $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
| 42 | - $form->save(); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Decreases form revenue whenever invoice payment changes. |
|
| 49 | - * |
|
| 50 | - * @param WPInv_Invoice $invoice |
|
| 51 | - */ |
|
| 52 | - public function decrease_form_revenue( $invoice ) { |
|
| 53 | - |
|
| 54 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 55 | - if ( $form->get_id() ) { |
|
| 56 | - $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
| 57 | - $form->save(); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Updates a form's failed amount. |
|
| 64 | - * |
|
| 65 | - * @param WPInv_Invoice $invoice |
|
| 66 | - * @param string $from |
|
| 67 | - * @param string $to |
|
| 68 | - */ |
|
| 69 | - public function update_form_failed_amount( $invoice, $from, $to ) { |
|
| 70 | - |
|
| 71 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 72 | - if ( $form->get_id() ) { |
|
| 73 | - return; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - if ( 'wpi-failed' == $from ) { |
|
| 77 | - $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
| 78 | - $form->save(); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ( 'wpi-failed' == $to ) { |
|
| 82 | - $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
| 83 | - $form->save(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Updates a form's refunded amount. |
|
| 90 | - * |
|
| 91 | - * @param WPInv_Invoice $invoice |
|
| 92 | - * @param string $from |
|
| 93 | - * @param string $to |
|
| 94 | - */ |
|
| 95 | - public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
| 96 | - |
|
| 97 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 98 | - if ( $form->get_id() ) { |
|
| 99 | - return; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - if ( 'wpi-refunded' == $from ) { |
|
| 103 | - $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
| 104 | - $form->save(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ( 'wpi-refunded' == $to ) { |
|
| 108 | - $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
| 109 | - $form->save(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Updates a form's cancelled amount. |
|
| 116 | - * |
|
| 117 | - * @param WPInv_Invoice $invoice |
|
| 118 | - * @param string $from |
|
| 119 | - * @param string $to |
|
| 120 | - */ |
|
| 121 | - public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
| 122 | - |
|
| 123 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 124 | - if ( $form->get_id() ) { |
|
| 125 | - return; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if ( 'wpi-cancelled' == $from ) { |
|
| 129 | - $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
| 130 | - $form->save(); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if ( 'wpi-cancelled' == $to ) { |
|
| 134 | - $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
| 135 | - $form->save(); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - } |
|
| 16 | + * Class constructor |
|
| 17 | + * |
|
| 18 | + */ |
|
| 19 | + public function __construct() { |
|
| 20 | + |
|
| 21 | + // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
| 22 | + add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
| 23 | + add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
| 24 | + |
|
| 25 | + // Sync form amount whenever invoice statuses change. |
|
| 26 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
| 27 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
| 28 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
| 29 | + |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Increments a form's revenue whenever there is a payment. |
|
| 34 | + * |
|
| 35 | + * @param WPInv_Invoice $invoice |
|
| 36 | + */ |
|
| 37 | + public function increment_form_revenue( $invoice ) { |
|
| 38 | + |
|
| 39 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 40 | + if ( $form->get_id() ) { |
|
| 41 | + $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
| 42 | + $form->save(); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Decreases form revenue whenever invoice payment changes. |
|
| 49 | + * |
|
| 50 | + * @param WPInv_Invoice $invoice |
|
| 51 | + */ |
|
| 52 | + public function decrease_form_revenue( $invoice ) { |
|
| 53 | + |
|
| 54 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 55 | + if ( $form->get_id() ) { |
|
| 56 | + $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
| 57 | + $form->save(); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Updates a form's failed amount. |
|
| 64 | + * |
|
| 65 | + * @param WPInv_Invoice $invoice |
|
| 66 | + * @param string $from |
|
| 67 | + * @param string $to |
|
| 68 | + */ |
|
| 69 | + public function update_form_failed_amount( $invoice, $from, $to ) { |
|
| 70 | + |
|
| 71 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 72 | + if ( $form->get_id() ) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + if ( 'wpi-failed' == $from ) { |
|
| 77 | + $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
| 78 | + $form->save(); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ( 'wpi-failed' == $to ) { |
|
| 82 | + $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
| 83 | + $form->save(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Updates a form's refunded amount. |
|
| 90 | + * |
|
| 91 | + * @param WPInv_Invoice $invoice |
|
| 92 | + * @param string $from |
|
| 93 | + * @param string $to |
|
| 94 | + */ |
|
| 95 | + public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
| 96 | + |
|
| 97 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 98 | + if ( $form->get_id() ) { |
|
| 99 | + return; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + if ( 'wpi-refunded' == $from ) { |
|
| 103 | + $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
| 104 | + $form->save(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ( 'wpi-refunded' == $to ) { |
|
| 108 | + $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
| 109 | + $form->save(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Updates a form's cancelled amount. |
|
| 116 | + * |
|
| 117 | + * @param WPInv_Invoice $invoice |
|
| 118 | + * @param string $from |
|
| 119 | + * @param string $to |
|
| 120 | + */ |
|
| 121 | + public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
| 122 | + |
|
| 123 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 124 | + if ( $form->get_id() ) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if ( 'wpi-cancelled' == $from ) { |
|
| 129 | + $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
| 130 | + $form->save(); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if ( 'wpi-cancelled' == $to ) { |
|
| 134 | + $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
| 135 | + $form->save(); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | } |
@@ -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 | * Payment forms controller class |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | public function __construct() { |
| 20 | 20 | |
| 21 | 21 | // Update a payment form's revenue whenever an invoice is paid for or refunded. |
| 22 | - add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
| 23 | - add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
| 22 | + add_action('getpaid_invoice_payment_status_changed', array($this, 'increment_form_revenue')); |
|
| 23 | + add_action('getpaid_invoice_payment_status_reversed', array($this, 'decrease_form_revenue')); |
|
| 24 | 24 | |
| 25 | 25 | // Sync form amount whenever invoice statuses change. |
| 26 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
| 27 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
| 28 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
| 26 | + add_action('getpaid_invoice_status_changed', array($this, 'update_form_failed_amount'), 10, 3); |
|
| 27 | + add_action('getpaid_invoice_status_changed', array($this, 'update_form_refunded_amount'), 10, 3); |
|
| 28 | + add_action('getpaid_invoice_status_changed', array($this, 'update_form_cancelled_amount'), 10, 3); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param WPInv_Invoice $invoice |
| 36 | 36 | */ |
| 37 | - public function increment_form_revenue( $invoice ) { |
|
| 37 | + public function increment_form_revenue($invoice) { |
|
| 38 | 38 | |
| 39 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 40 | - if ( $form->get_id() ) { |
|
| 41 | - $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
| 39 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 40 | + if ($form->get_id()) { |
|
| 41 | + $form->set_earned($form->get_earned() + $invoice->get_total()); |
|
| 42 | 42 | $form->save(); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param WPInv_Invoice $invoice |
| 51 | 51 | */ |
| 52 | - public function decrease_form_revenue( $invoice ) { |
|
| 52 | + public function decrease_form_revenue($invoice) { |
|
| 53 | 53 | |
| 54 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 55 | - if ( $form->get_id() ) { |
|
| 56 | - $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
| 54 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 55 | + if ($form->get_id()) { |
|
| 56 | + $form->set_earned($form->get_earned() - $invoice->get_total()); |
|
| 57 | 57 | $form->save(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -66,20 +66,20 @@ discard block |
||
| 66 | 66 | * @param string $from |
| 67 | 67 | * @param string $to |
| 68 | 68 | */ |
| 69 | - public function update_form_failed_amount( $invoice, $from, $to ) { |
|
| 69 | + public function update_form_failed_amount($invoice, $from, $to) { |
|
| 70 | 70 | |
| 71 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 72 | - if ( $form->get_id() ) { |
|
| 71 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 72 | + if ($form->get_id()) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ( 'wpi-failed' == $from ) { |
|
| 77 | - $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
| 76 | + if ('wpi-failed' == $from) { |
|
| 77 | + $form->set_failed($form->get_failed() - $invoice->get_total()); |
|
| 78 | 78 | $form->save(); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( 'wpi-failed' == $to ) { |
|
| 82 | - $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
| 81 | + if ('wpi-failed' == $to) { |
|
| 82 | + $form->set_failed($form->get_failed() + $invoice->get_total()); |
|
| 83 | 83 | $form->save(); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -92,20 +92,20 @@ discard block |
||
| 92 | 92 | * @param string $from |
| 93 | 93 | * @param string $to |
| 94 | 94 | */ |
| 95 | - public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
| 95 | + public function update_form_refunded_amount($invoice, $from, $to) { |
|
| 96 | 96 | |
| 97 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 98 | - if ( $form->get_id() ) { |
|
| 97 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 98 | + if ($form->get_id()) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( 'wpi-refunded' == $from ) { |
|
| 103 | - $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
| 102 | + if ('wpi-refunded' == $from) { |
|
| 103 | + $form->set_refunded($form->get_refunded() - $invoice->get_total()); |
|
| 104 | 104 | $form->save(); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( 'wpi-refunded' == $to ) { |
|
| 108 | - $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
| 107 | + if ('wpi-refunded' == $to) { |
|
| 108 | + $form->set_refunded($form->get_refunded() + $invoice->get_total()); |
|
| 109 | 109 | $form->save(); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -118,20 +118,20 @@ discard block |
||
| 118 | 118 | * @param string $from |
| 119 | 119 | * @param string $to |
| 120 | 120 | */ |
| 121 | - public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
| 121 | + public function update_form_cancelled_amount($invoice, $from, $to) { |
|
| 122 | 122 | |
| 123 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 124 | - if ( $form->get_id() ) { |
|
| 123 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 124 | + if ($form->get_id()) { |
|
| 125 | 125 | return; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if ( 'wpi-cancelled' == $from ) { |
|
| 129 | - $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
| 128 | + if ('wpi-cancelled' == $from) { |
|
| 129 | + $form->set_cancelled($form->get_cancelled() - $invoice->get_total()); |
|
| 130 | 130 | $form->save(); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if ( 'wpi-cancelled' == $to ) { |
|
| 134 | - $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
| 133 | + if ('wpi-cancelled' == $to) { |
|
| 134 | + $form->set_cancelled($form->get_cancelled() + $invoice->get_total()); |
|
| 135 | 135 | $form->save(); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | - exit; // Exit if accessed directly |
|
| 11 | + exit; // Exit if accessed directly |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | class GetPaid_Meta_Box_Discount_Details { |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * Output the metabox. |
|
| 21 | - * |
|
| 22 | - * @param WP_Post $post |
|
| 23 | - */ |
|
| 20 | + * Output the metabox. |
|
| 21 | + * |
|
| 22 | + * @param WP_Post $post |
|
| 23 | + */ |
|
| 24 | 24 | public static function output( $post ) { |
| 25 | 25 | |
| 26 | 26 | // Prepare the discount. |
@@ -368,34 +368,34 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
| 371 | - * Save meta box data. |
|
| 372 | - * |
|
| 373 | - * @param int $post_id |
|
| 374 | - */ |
|
| 375 | - public static function save( $post_id ) { |
|
| 371 | + * Save meta box data. |
|
| 372 | + * |
|
| 373 | + * @param int $post_id |
|
| 374 | + */ |
|
| 375 | + public static function save( $post_id ) { |
|
| 376 | 376 | |
| 377 | 377 | // Prepare the discount. |
| 378 | 378 | $discount = new WPInv_Discount( $post_id ); |
| 379 | 379 | |
| 380 | 380 | // Load new data. |
| 381 | 381 | $discount->set_props( |
| 382 | - array( |
|
| 383 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null, |
|
| 384 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null, |
|
| 385 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
| 386 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
| 387 | - 'is_single_use' => isset( $_POST['wpinv_discount_single_use'] ), |
|
| 382 | + array( |
|
| 383 | + 'code' => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null, |
|
| 384 | + 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null, |
|
| 385 | + 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
| 386 | + 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
| 387 | + 'is_single_use' => isset( $_POST['wpinv_discount_single_use'] ), |
|
| 388 | 388 | 'type' => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null, |
| 389 | - 'is_recurring' => isset( $_POST['wpinv_discount_recurring'] ), |
|
| 390 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(), |
|
| 391 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(), |
|
| 392 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null, |
|
| 393 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null, |
|
| 394 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null, |
|
| 395 | - ) |
|
| 389 | + 'is_recurring' => isset( $_POST['wpinv_discount_recurring'] ), |
|
| 390 | + 'items' => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(), |
|
| 391 | + 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(), |
|
| 392 | + 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null, |
|
| 393 | + 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null, |
|
| 394 | + 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null, |
|
| 395 | + ) |
|
| 396 | 396 | ); |
| 397 | 397 | |
| 398 | - $discount->save(); |
|
| 399 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
| 400 | - } |
|
| 398 | + $discount->save(); |
|
| 399 | + do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
| 400 | + } |
|
| 401 | 401 | } |
@@ -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,24 +21,24 @@ 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 discount. |
| 27 | - $discount = new WPInv_Discount( $post ); |
|
| 27 | + $discount = new WPInv_Discount($post); |
|
| 28 | 28 | |
| 29 | 29 | // Nonce field. |
| 30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
| 31 | 31 | |
| 32 | - do_action( 'wpinv_discount_form_top', $discount ); |
|
| 32 | + do_action('wpinv_discount_form_top', $discount); |
|
| 33 | 33 | |
| 34 | 34 | // Set the currency position. |
| 35 | 35 | $position = wpinv_currency_position(); |
| 36 | 36 | |
| 37 | - if ( $position == 'left_space' ) { |
|
| 37 | + if ($position == 'left_space') { |
|
| 38 | 38 | $position = 'left'; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if ( $position == 'right_space' ) { |
|
| 41 | + if ($position == 'right_space') { |
|
| 42 | 42 | $position = 'right'; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -52,66 +52,66 @@ discard block |
||
| 52 | 52 | </style> |
| 53 | 53 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
| 54 | 54 | |
| 55 | - <?php do_action( 'wpinv_discount_form_first', $discount ); ?> |
|
| 55 | + <?php do_action('wpinv_discount_form_first', $discount); ?> |
|
| 56 | 56 | |
| 57 | - <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?> |
|
| 57 | + <?php do_action('wpinv_discount_form_before_code', $discount); ?> |
|
| 58 | 58 | <div class="form-group row"> |
| 59 | 59 | <label for="wpinv_discount_code" class="col-sm-3 col-form-label"> |
| 60 | - <?php _e( 'Discount Code', 'invoicing' );?> |
|
| 60 | + <?php _e('Discount Code', 'invoicing'); ?> |
|
| 61 | 61 | </label> |
| 62 | 62 | <div class="col-sm-8"> |
| 63 | 63 | <div class="row"> |
| 64 | 64 | <div class="col-sm-12 form-group"> |
| 65 | - <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
| 65 | + <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
| 66 | 66 | </div> |
| 67 | 67 | <div class="col-sm-12"> |
| 68 | 68 | <?php |
| 69 | - do_action( 'wpinv_discount_form_before_single_use', $discount ); |
|
| 69 | + do_action('wpinv_discount_form_before_single_use', $discount); |
|
| 70 | 70 | |
| 71 | 71 | echo aui()->input( |
| 72 | 72 | array( |
| 73 | 73 | 'id' => 'wpinv_discount_single_use', |
| 74 | 74 | 'name' => 'wpinv_discount_single_use', |
| 75 | 75 | 'type' => 'checkbox', |
| 76 | - 'label' => __( 'Each customer can only use this discount once', 'invoicing' ), |
|
| 76 | + 'label' => __('Each customer can only use this discount once', 'invoicing'), |
|
| 77 | 77 | 'value' => '1', |
| 78 | 78 | 'checked' => $discount->is_single_use(), |
| 79 | 79 | ) |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | - do_action( 'wpinv_discount_form_single_use', $discount ); |
|
| 82 | + do_action('wpinv_discount_form_single_use', $discount); |
|
| 83 | 83 | ?> |
| 84 | 84 | </div> |
| 85 | 85 | <div class="col-sm-12"> |
| 86 | 86 | <?php |
| 87 | - do_action( 'wpinv_discount_form_before_recurring', $discount ); |
|
| 87 | + do_action('wpinv_discount_form_before_recurring', $discount); |
|
| 88 | 88 | |
| 89 | 89 | echo aui()->input( |
| 90 | 90 | array( |
| 91 | 91 | 'id' => 'wpinv_discount_recurring', |
| 92 | 92 | 'name' => 'wpinv_discount_recurring', |
| 93 | 93 | 'type' => 'checkbox', |
| 94 | - 'label' => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ), |
|
| 94 | + 'label' => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'), |
|
| 95 | 95 | 'value' => '1', |
| 96 | 96 | 'checked' => $discount->is_recurring(), |
| 97 | 97 | ) |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - do_action( 'wpinv_discount_form_recurring', $discount ); |
|
| 100 | + do_action('wpinv_discount_form_recurring', $discount); |
|
| 101 | 101 | ?> |
| 102 | 102 | </div> |
| 103 | 103 | </div> |
| 104 | 104 | </div> |
| 105 | 105 | <div class="col-sm-1 pt-2 pl-0"> |
| 106 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span> |
|
| 106 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span> |
|
| 107 | 107 | </div> |
| 108 | 108 | </div> |
| 109 | - <?php do_action( 'wpinv_discount_form_code', $discount ); ?> |
|
| 109 | + <?php do_action('wpinv_discount_form_code', $discount); ?> |
|
| 110 | 110 | |
| 111 | - <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?> |
|
| 111 | + <?php do_action('wpinv_discount_form_before_type', $discount); ?> |
|
| 112 | 112 | <div class="form-group row"> |
| 113 | 113 | <label for="wpinv_discount_type" class="col-sm-3 col-form-label"> |
| 114 | - <?php _e( 'Discount Type', 'invoicing' );?> |
|
| 114 | + <?php _e('Discount Type', 'invoicing'); ?> |
|
| 115 | 115 | </label> |
| 116 | 116 | <div class="col-sm-8"> |
| 117 | 117 | <?php |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | array( |
| 120 | 120 | 'id' => 'wpinv_discount_type', |
| 121 | 121 | 'name' => 'wpinv_discount_type', |
| 122 | - 'label' => __( 'Discount Type', 'invoicing' ), |
|
| 123 | - 'placeholder' => __( 'Select Discount Type', 'invoicing' ), |
|
| 124 | - 'value' => $discount->get_type( 'edit' ), |
|
| 122 | + 'label' => __('Discount Type', 'invoicing'), |
|
| 123 | + 'placeholder' => __('Select Discount Type', 'invoicing'), |
|
| 124 | + 'value' => $discount->get_type('edit'), |
|
| 125 | 125 | 'select2' => true, |
| 126 | 126 | 'data-allow-clear' => 'false', |
| 127 | 127 | 'options' => wpinv_get_discount_types() |
@@ -130,19 +130,19 @@ discard block |
||
| 130 | 130 | ?> |
| 131 | 131 | </div> |
| 132 | 132 | <div class="col-sm-1 pt-2 pl-0"> |
| 133 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span> |
|
| 133 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span> |
|
| 134 | 134 | </div> |
| 135 | 135 | </div> |
| 136 | - <?php do_action( 'wpinv_discount_form_type', $discount ); ?> |
|
| 136 | + <?php do_action('wpinv_discount_form_type', $discount); ?> |
|
| 137 | 137 | |
| 138 | - <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?> |
|
| 139 | - <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap"> |
|
| 138 | + <?php do_action('wpinv_discount_form_before_amount', $discount); ?> |
|
| 139 | + <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap"> |
|
| 140 | 140 | <label for="wpinv_discount_amount" class="col-sm-3 col-form-label"> |
| 141 | - <?php _e( 'Discount Amount', 'invoicing' );?> |
|
| 141 | + <?php _e('Discount Amount', 'invoicing'); ?> |
|
| 142 | 142 | </label> |
| 143 | 143 | <div class="col-sm-8"> |
| 144 | 144 | <div class="input-group input-group-sm"> |
| 145 | - <?php if( 'left' == $position ) : ?> |
|
| 145 | + <?php if ('left' == $position) : ?> |
|
| 146 | 146 | <div class="input-group-prepend left wpinv-if-flat"> |
| 147 | 147 | <span class="input-group-text"> |
| 148 | 148 | <?php echo wpinv_currency_symbol(); ?> |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | </div> |
| 151 | 151 | <?php endif; ?> |
| 152 | 152 | |
| 153 | - <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control"> |
|
| 153 | + <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control"> |
|
| 154 | 154 | |
| 155 | - <?php if( 'right' == $position ) : ?> |
|
| 155 | + <?php if ('right' == $position) : ?> |
|
| 156 | 156 | <div class="input-group-prepend left wpinv-if-flat"> |
| 157 | 157 | <span class="input-group-text"> |
| 158 | 158 | <?php echo wpinv_currency_symbol(); ?> |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | </div> |
| 166 | 166 | </div> |
| 167 | 167 | <div class="col-sm-1 pt-2 pl-0"> |
| 168 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span> |
|
| 168 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span> |
|
| 169 | 169 | </div> |
| 170 | 170 | </div> |
| 171 | - <?php do_action( 'wpinv_discount_form_amount', $discount ); ?> |
|
| 171 | + <?php do_action('wpinv_discount_form_amount', $discount); ?> |
|
| 172 | 172 | |
| 173 | - <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?> |
|
| 173 | + <?php do_action('wpinv_discount_form_before_items', $discount); ?> |
|
| 174 | 174 | <div class="form-group row"> |
| 175 | 175 | <label for="wpinv_discount_items" class="col-sm-3 col-form-label"> |
| 176 | - <?php _e( 'Items', 'invoicing' );?> |
|
| 176 | + <?php _e('Items', 'invoicing'); ?> |
|
| 177 | 177 | </label> |
| 178 | 178 | <div class="col-sm-8"> |
| 179 | 179 | <?php |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | array( |
| 182 | 182 | 'id' => 'wpinv_discount_items', |
| 183 | 183 | 'name' => 'wpinv_discount_items[]', |
| 184 | - 'label' => __( 'Items', 'invoicing' ), |
|
| 185 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
| 186 | - 'value' => $discount->get_items( 'edit' ), |
|
| 184 | + 'label' => __('Items', 'invoicing'), |
|
| 185 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
| 186 | + 'value' => $discount->get_items('edit'), |
|
| 187 | 187 | 'select2' => true, |
| 188 | 188 | 'multiple' => true, |
| 189 | 189 | 'data-allow-clear' => 'false', |
@@ -193,15 +193,15 @@ discard block |
||
| 193 | 193 | ?> |
| 194 | 194 | </div> |
| 195 | 195 | <div class="col-sm-1 pt-2 pl-0"> |
| 196 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span> |
|
| 196 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span> |
|
| 197 | 197 | </div> |
| 198 | 198 | </div> |
| 199 | - <?php do_action( 'wpinv_discount_form_items', $discount ); ?> |
|
| 199 | + <?php do_action('wpinv_discount_form_items', $discount); ?> |
|
| 200 | 200 | |
| 201 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?> |
|
| 201 | + <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?> |
|
| 202 | 202 | <div class="form-group row"> |
| 203 | 203 | <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label"> |
| 204 | - <?php _e( 'Excluded Items', 'invoicing' );?> |
|
| 204 | + <?php _e('Excluded Items', 'invoicing'); ?> |
|
| 205 | 205 | </label> |
| 206 | 206 | <div class="col-sm-8"> |
| 207 | 207 | <?php |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | array( |
| 210 | 210 | 'id' => 'wpinv_discount_excluded_items', |
| 211 | 211 | 'name' => 'wpinv_discount_excluded_items[]', |
| 212 | - 'label' => __( 'Excluded Items', 'invoicing' ), |
|
| 213 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
| 214 | - 'value' => $discount->get_excluded_items( 'edit' ), |
|
| 212 | + 'label' => __('Excluded Items', 'invoicing'), |
|
| 213 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
| 214 | + 'value' => $discount->get_excluded_items('edit'), |
|
| 215 | 215 | 'select2' => true, |
| 216 | 216 | 'multiple' => true, |
| 217 | 217 | 'data-allow-clear' => 'false', |
@@ -221,15 +221,15 @@ discard block |
||
| 221 | 221 | ?> |
| 222 | 222 | </div> |
| 223 | 223 | <div class="col-sm-1 pt-2 pl-0"> |
| 224 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span> |
|
| 224 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span> |
|
| 225 | 225 | </div> |
| 226 | 226 | </div> |
| 227 | - <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?> |
|
| 227 | + <?php do_action('wpinv_discount_form_excluded_items', $discount); ?> |
|
| 228 | 228 | |
| 229 | - <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?> |
|
| 229 | + <?php do_action('wpinv_discount_form_before_start', $discount); ?> |
|
| 230 | 230 | <div class="form-group row"> |
| 231 | 231 | <label for="wpinv_discount_start" class="col-sm-3 col-form-label"> |
| 232 | - <?php _e( 'Start Date', 'invoicing' );?> |
|
| 232 | + <?php _e('Start Date', 'invoicing'); ?> |
|
| 233 | 233 | </label> |
| 234 | 234 | <div class="col-sm-8"> |
| 235 | 235 | <?php |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | 'type' => 'datepicker', |
| 239 | 239 | 'id' => 'wpinv_discount_start', |
| 240 | 240 | 'name' => 'wpinv_discount_start', |
| 241 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 241 | + 'label' => __('Start Date', 'invoicing'), |
|
| 242 | 242 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 243 | 243 | 'class' => 'form-control-sm', |
| 244 | - 'value' => $discount->get_start_date( 'edit' ), |
|
| 244 | + 'value' => $discount->get_start_date('edit'), |
|
| 245 | 245 | 'extra_attributes' => array( |
| 246 | 246 | 'data-enable-time' => 'true', |
| 247 | 247 | 'data-time_24hr' => 'true', |
@@ -252,15 +252,15 @@ discard block |
||
| 252 | 252 | ?> |
| 253 | 253 | </div> |
| 254 | 254 | <div class="col-sm-1 pt-2 pl-0"> |
| 255 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span> |
|
| 255 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span> |
|
| 256 | 256 | </div> |
| 257 | 257 | </div> |
| 258 | - <?php do_action( 'wpinv_discount_form_start', $discount ); ?> |
|
| 258 | + <?php do_action('wpinv_discount_form_start', $discount); ?> |
|
| 259 | 259 | |
| 260 | - <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?> |
|
| 260 | + <?php do_action('wpinv_discount_form_before_expiration', $discount); ?> |
|
| 261 | 261 | <div class="form-group row"> |
| 262 | 262 | <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label"> |
| 263 | - <?php _e( 'Expiration Date', 'invoicing' );?> |
|
| 263 | + <?php _e('Expiration Date', 'invoicing'); ?> |
|
| 264 | 264 | </label> |
| 265 | 265 | <div class="col-sm-8"> |
| 266 | 266 | <?php |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | 'type' => 'datepicker', |
| 270 | 270 | 'id' => 'wpinv_discount_expiration', |
| 271 | 271 | 'name' => 'wpinv_discount_expiration', |
| 272 | - 'label' => __( 'Expiration Date', 'invoicing' ), |
|
| 272 | + 'label' => __('Expiration Date', 'invoicing'), |
|
| 273 | 273 | 'placeholder' => 'YYYY-MM-DD 00:00', |
| 274 | 274 | 'class' => 'form-control-sm', |
| 275 | - 'value' => $discount->get_end_date( 'edit' ), |
|
| 275 | + 'value' => $discount->get_end_date('edit'), |
|
| 276 | 276 | 'extra_attributes' => array( |
| 277 | 277 | 'data-enable-time' => 'true', |
| 278 | 278 | 'data-time_24hr' => 'true', |
@@ -285,27 +285,27 @@ discard block |
||
| 285 | 285 | ?> |
| 286 | 286 | </div> |
| 287 | 287 | <div class="col-sm-1 pt-2 pl-0"> |
| 288 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span> |
|
| 288 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span> |
|
| 289 | 289 | </div> |
| 290 | 290 | </div> |
| 291 | - <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?> |
|
| 291 | + <?php do_action('wpinv_discount_form_expiration', $discount); ?> |
|
| 292 | 292 | |
| 293 | - <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?> |
|
| 293 | + <?php do_action('wpinv_discount_form_before_min_total', $discount); ?> |
|
| 294 | 294 | <div class="form-group row"> |
| 295 | 295 | <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label"> |
| 296 | - <?php _e( 'Minimum Amount', 'invoicing' );?> |
|
| 296 | + <?php _e('Minimum Amount', 'invoicing'); ?> |
|
| 297 | 297 | </label> |
| 298 | 298 | <div class="col-sm-8"> |
| 299 | 299 | <div class="input-group input-group-sm"> |
| 300 | - <?php if( 'left' == $position ) : ?> |
|
| 300 | + <?php if ('left' == $position) : ?> |
|
| 301 | 301 | <div class="input-group-prepend"> |
| 302 | 302 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
| 303 | 303 | </div> |
| 304 | 304 | <?php endif; ?> |
| 305 | 305 | |
| 306 | - <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control"> |
|
| 306 | + <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control"> |
|
| 307 | 307 | |
| 308 | - <?php if( 'left' != $position ) : ?> |
|
| 308 | + <?php if ('left' != $position) : ?> |
|
| 309 | 309 | <div class="input-group-append"> |
| 310 | 310 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
| 311 | 311 | </div> |
@@ -313,27 +313,27 @@ discard block |
||
| 313 | 313 | </div> |
| 314 | 314 | </div> |
| 315 | 315 | <div class="col-sm-1 pt-2 pl-0"> |
| 316 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span> |
|
| 316 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span> |
|
| 317 | 317 | </div> |
| 318 | 318 | </div> |
| 319 | - <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?> |
|
| 319 | + <?php do_action('wpinv_discount_form_min_total', $discount); ?> |
|
| 320 | 320 | |
| 321 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
| 321 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
| 322 | 322 | <div class="form-group row"> |
| 323 | 323 | <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label"> |
| 324 | - <?php _e( 'Maximum Amount', 'invoicing' );?> |
|
| 324 | + <?php _e('Maximum Amount', 'invoicing'); ?> |
|
| 325 | 325 | </label> |
| 326 | 326 | <div class="col-sm-8"> |
| 327 | 327 | <div class="input-group input-group-sm"> |
| 328 | - <?php if( 'left' == $position ) : ?> |
|
| 328 | + <?php if ('left' == $position) : ?> |
|
| 329 | 329 | <div class="input-group-prepend"> |
| 330 | 330 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
| 331 | 331 | </div> |
| 332 | 332 | <?php endif; ?> |
| 333 | 333 | |
| 334 | - <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control"> |
|
| 334 | + <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control"> |
|
| 335 | 335 | |
| 336 | - <?php if( 'left' != $position ) : ?> |
|
| 336 | + <?php if ('left' != $position) : ?> |
|
| 337 | 337 | <div class="input-group-append"> |
| 338 | 338 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
| 339 | 339 | </div> |
@@ -341,30 +341,30 @@ discard block |
||
| 341 | 341 | </div> |
| 342 | 342 | </div> |
| 343 | 343 | <div class="col-sm-1 pt-2 pl-0"> |
| 344 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span> |
|
| 344 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span> |
|
| 345 | 345 | </div> |
| 346 | 346 | </div> |
| 347 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
| 347 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
| 348 | 348 | |
| 349 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?> |
|
| 349 | + <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?> |
|
| 350 | 350 | <div class="form-group row"> |
| 351 | 351 | <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label"> |
| 352 | - <?php _e( 'Maximum Uses', 'invoicing' );?> |
|
| 352 | + <?php _e('Maximum Uses', 'invoicing'); ?> |
|
| 353 | 353 | </label> |
| 354 | 354 | <div class="col-sm-8"> |
| 355 | - <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
| 355 | + <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
| 356 | 356 | </div> |
| 357 | 357 | <div class="col-sm-1 pt-2 pl-0"> |
| 358 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span> |
|
| 358 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span> |
|
| 359 | 359 | </div> |
| 360 | 360 | </div> |
| 361 | - <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?> |
|
| 361 | + <?php do_action('wpinv_discount_form_max_uses', $discount); ?> |
|
| 362 | 362 | |
| 363 | - <?php do_action( 'wpinv_discount_form_last', $discount ); ?> |
|
| 363 | + <?php do_action('wpinv_discount_form_last', $discount); ?> |
|
| 364 | 364 | |
| 365 | 365 | </div> |
| 366 | 366 | <?php |
| 367 | - do_action( 'wpinv_discount_form_bottom', $post ); |
|
| 367 | + do_action('wpinv_discount_form_bottom', $post); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -372,30 +372,30 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @param int $post_id |
| 374 | 374 | */ |
| 375 | - public static function save( $post_id ) { |
|
| 375 | + public static function save($post_id) { |
|
| 376 | 376 | |
| 377 | 377 | // Prepare the discount. |
| 378 | - $discount = new WPInv_Discount( $post_id ); |
|
| 378 | + $discount = new WPInv_Discount($post_id); |
|
| 379 | 379 | |
| 380 | 380 | // Load new data. |
| 381 | 381 | $discount->set_props( |
| 382 | 382 | array( |
| 383 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null, |
|
| 384 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null, |
|
| 385 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
| 386 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
| 387 | - 'is_single_use' => isset( $_POST['wpinv_discount_single_use'] ), |
|
| 388 | - 'type' => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null, |
|
| 389 | - 'is_recurring' => isset( $_POST['wpinv_discount_recurring'] ), |
|
| 390 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(), |
|
| 391 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(), |
|
| 392 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null, |
|
| 393 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null, |
|
| 394 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null, |
|
| 383 | + 'code' => isset($_POST['wpinv_discount_code']) ? $_POST['wpinv_discount_code'] : null, |
|
| 384 | + 'amount' => isset($_POST['wpinv_discount_amount']) ? $_POST['wpinv_discount_amount'] : null, |
|
| 385 | + 'start' => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null, |
|
| 386 | + 'expiration' => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null, |
|
| 387 | + 'is_single_use' => isset($_POST['wpinv_discount_single_use']), |
|
| 388 | + 'type' => isset($_POST['wpinv_discount_type']) ? $_POST['wpinv_discount_type'] : null, |
|
| 389 | + 'is_recurring' => isset($_POST['wpinv_discount_recurring']), |
|
| 390 | + 'items' => isset($_POST['wpinv_discount_items']) ? $_POST['wpinv_discount_items'] : array(), |
|
| 391 | + 'excluded_items' => isset($_POST['wpinv_discount_excluded_items']) ? $_POST['wpinv_discount_excluded_items'] : array(), |
|
| 392 | + 'max_uses' => isset($_POST['wpinv_discount_max_uses']) ? $_POST['wpinv_discount_max_uses'] : null, |
|
| 393 | + 'min_total' => isset($_POST['wpinv_discount_min_total']) ? $_POST['wpinv_discount_min_total'] : null, |
|
| 394 | + 'max_total' => isset($_POST['wpinv_discount_max_total']) ? $_POST['wpinv_discount_max_total'] : null, |
|
| 395 | 395 | ) |
| 396 | 396 | ); |
| 397 | 397 | |
| 398 | 398 | $discount->save(); |
| 399 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
| 399 | + do_action('getpaid_discount_metabox_save', $post_id, $discount); |
|
| 400 | 400 | } |
| 401 | 401 | } |