Passed
Push — master ( 18145d...828cff )
by Brian
05:08
created
includes/payments/class-getpaid-payment-forms.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -13,128 +13,128 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit; // Exit if accessed directly
10
+    exit; // Exit if accessed directly
11 11
 }
12 12
 
13 13
 /**
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 class GetPaid_Meta_Box_Payment_Form {
17 17
 
18 18
     /**
19
-	 * Output the metabox.
20
-	 *
21
-	 * @param WP_Post $post
22
-	 */
19
+     * Output the metabox.
20
+     *
21
+     * @param WP_Post $post
22
+     */
23 23
     public static function output( $post ) {
24 24
         ?>
25 25
         <div id="wpinv-form-builder" class="bsui">
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
     }
87 87
 
88 88
     /**
89
-	 * Save meta box data.
90
-	 *
91
-	 * @param int $post_id
92
-	 */
93
-	public static function save( $post_id ) {
89
+     * Save meta box data.
90
+     *
91
+     * @param int $post_id
92
+     */
93
+    public static function save( $post_id ) {
94 94
 
95 95
         // Prepare the form.
96 96
         $form = new GetPaid_Payment_Form( $post_id );
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
     }
122 122
 
123 123
     /**
124
-	 * Converts an array fo form items to objects.
125
-	 *
126
-	 * @param array $items
127
-	 */
128
-	public static function item_to_objects( $items ) {
124
+     * Converts an array fo form items to objects.
125
+     *
126
+     * @param array $items
127
+     */
128
+    public static function item_to_objects( $items ) {
129 129
 
130 130
         $objects = array();
131 131
 
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-    public static function output( $post ) {
23
+    public static function output($post) {
24 24
         ?>
25 25
         <div id="wpinv-form-builder" class="bsui">
26 26
             <div class="row">
27 27
                 <div class="col-sm-4">
28 28
 
29 29
                     <!-- Builder tabs -->
30
-                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button>
30
+                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button>
31 31
 
32 32
                     <!-- Builder tab content -->
33 33
                     <div class="mt-4">
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                         <!-- Available builder elements -->
36 36
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
37 37
                             <div class="wpinv-form-builder-add-field-types">
38
-                                <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
38
+                                <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
39 39
                                 <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable">
40 40
                                     <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }">
41 41
                                         <button class="button btn">
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
                         <!-- Edit an element -->
51 51
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;">
52 52
                             <div class="wpinv-form-builder-edit-field-wrapper">
53
-                                <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
54
-                                <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?>
53
+                                <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
54
+                                <?php do_action('getpaid_payment_form_edit_element_template', $post); ?>
55 55
                                 <div>
56
-                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button>
56
+                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button>
57 57
                                 </div>
58 58
                             </div>
59 59
                         </div>
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 
63 63
                 </div>
64 64
                 <div class="col-sm-8 border-left">
65
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
66
-                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
65
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
66
+                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
67 67
 
68 68
                     <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;">
69 69
                         <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element &&  active_tab=='edit_item' }, form_element.type]" @click="active_tab = 'edit_item'; active_form_element = form_element">
70 70
                             <div class="wpinv-form-builder-element-preview-inner">
71 71
                                 <div class="wpinv-payment-form-field-preview-overlay"></div>
72
-                                <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
72
+                                <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
73 73
                             </div>
74 74
                         </div>
75 75
                     </draggable>
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         </div>
83 83
         <?php
84 84
 
85
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
85
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
86 86
     }
87 87
 
88 88
     /**
@@ -90,33 +90,33 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @param int $post_id
92 92
 	 */
93
-	public static function save( $post_id ) {
93
+	public static function save($post_id) {
94 94
 
95 95
         // Prepare the form.
96
-        $form = new GetPaid_Payment_Form( $post_id );
96
+        $form = new GetPaid_Payment_Form($post_id);
97 97
 
98 98
         // Fetch form items.
99
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
99
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
100 100
 
101 101
         // Ensure that we have an array...
102
-        if ( empty( $form_items ) ) {
102
+        if (empty($form_items)) {
103 103
             $form_items = array();
104 104
         }
105 105
 
106 106
         // Add it to the form.
107
-        $form->set_items( self::item_to_objects( $form_items ) );
107
+        $form->set_items(self::item_to_objects($form_items));
108 108
 
109 109
         // Save form elements.
110
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
111
-        if ( empty( $form_elements ) ) {
110
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
111
+        if (empty($form_elements)) {
112 112
             $form_elements = array();
113 113
         }
114 114
 
115
-        $form->set_elements( $form_elements );
115
+        $form->set_elements($form_elements);
116 116
 
117 117
         // Persist data to the datastore.
118 118
         $form->save();
119
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
119
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
120 120
 
121 121
     }
122 122
 
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @param array $items
127 127
 	 */
128
-	public static function item_to_objects( $items ) {
128
+	public static function item_to_objects($items) {
129 129
 
130 130
         $objects = array();
131 131
 
132
-        foreach ( $items as $item ) {
133
-            $_item = new GetPaid_Form_Item( $item['id'] );
134
-            $_item->set_allow_quantities( (bool) $item['allow_quantities'] );
135
-            $_item->set_is_required( (bool) $item['required'] );
132
+        foreach ($items as $item) {
133
+            $_item = new GetPaid_Form_Item($item['id']);
134
+            $_item->set_allow_quantities((bool) $item['allow_quantities']);
135
+            $_item->set_is_required((bool) $item['required']);
136 136
             $objects[] = $_item;
137 137
         }
138 138
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-fees.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -12,108 +12,108 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Fees {
14 14
 
15
-	/**
16
-	 * The fee validation error.
17
-	 * @var string
18
-	 */
19
-	public $fee_error;
20
-
21
-	/**
22
-	 * Submission fees.
23
-	 * @var array
24
-	 */
25
-	public $fees = array();
15
+    /**
16
+     * The fee validation error.
17
+     * @var string
18
+     */
19
+    public $fee_error;
20
+
21
+    /**
22
+     * Submission fees.
23
+     * @var array
24
+     */
25
+    public $fees = array();
26
+
27
+    /**
28
+     * Class constructor
29
+     *
30
+     * @param GetPaid_Payment_Form_Submission $submission
31
+     */
32
+    public function __construct( $submission ) {
33
+
34
+        // Process any existing invoice fees.
35
+        if ( $submission->has_invoice() ) {
36
+            $this->fees = $submission->get_invoice()->get_fees();
37
+        }
38
+
39
+        // Process price fields.
40
+        $data         = $submission->get_data();
41
+        $payment_form = $submission->get_payment_form();
42
+
43
+        foreach ( $payment_form->get_elements() as $element ) {
44
+
45
+            if ( 'price_input' == $element['type'] ) {
46
+                $this->process_price_input( $element, $data );
47
+            }
48
+
49
+            if ( 'price_select' == $element['type'] ) {
50
+                $this->process_price_select( $element, $data );
51
+            }
52
+
53
+        }
54
+
55
+    }
56
+
57
+    /**
58
+     * Process a price input field.
59
+     *
60
+     * @param array $element
61
+     * @param array $data
62
+     */
63
+    public function process_price_input( $element, $data ) {
64
+
65
+        // Abort if not passed.
66
+        if ( empty( $data[ $element['id'] ] ) ) {
67
+            return;
68
+        }
69
+
70
+        $amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
71
+        $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
72
+
73
+        if ( $amount < $minimum ) {
74
+            throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) );
75
+        }
76
+
77
+        $this->fees[ $element['label'] ] = array(
78
+            'name'          => $element['label'],
79
+            'initial_fee'   => $amount,
80
+            'recurring_fee' => 0,
81
+        );
82
+
83
+    }
26 84
 
27 85
     /**
28
-	 * Class constructor
29
-	 *
30
-	 * @param GetPaid_Payment_Form_Submission $submission
31
-	 */
32
-	public function __construct( $submission ) {
33
-
34
-		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
36
-			$this->fees = $submission->get_invoice()->get_fees();
37
-		}
38
-
39
-		// Process price fields.
40
-		$data         = $submission->get_data();
41
-		$payment_form = $submission->get_payment_form();
42
-
43
-		foreach ( $payment_form->get_elements() as $element ) {
44
-
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data );
47
-			}
48
-
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
51
-			}
52
-
53
-		}
54
-
55
-	}
56
-
57
-	/**
58
-	 * Process a price input field.
59
-	 *
60
-	 * @param array $element
61
-	 * @param array $data
62
-	 */
63
-	public function process_price_input( $element, $data ) {
64
-
65
-		// Abort if not passed.
66
-		if ( empty( $data[ $element['id'] ] ) ) {
67
-			return;
68
-		}
69
-
70
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
71
-		$minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
72
-
73
-		if ( $amount < $minimum ) {
74
-			throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) );
75
-		}
76
-
77
-		$this->fees[ $element['label'] ] = array(
78
-			'name'          => $element['label'],
79
-			'initial_fee'   => $amount,
80
-			'recurring_fee' => 0,
81
-		);
82
-
83
-	}
84
-
85
-	/**
86
-	 * Process a price select field.
87
-	 *
88
-	 * @param array $element
89
-	 * @param array $data
90
-	 */
91
-	public function process_price_select( $element, $data ) {
92
-
93
-		// Abort if not passed.
94
-		if ( empty( $data[ $element['id'] ] ) ) {
95
-			return;
96
-		}
97
-
98
-		$options  = getpaid_convert_price_string_to_options( $element['options'] );
99
-		$selected = wpinv_parse_list( $data[ $element['id'] ] );
100
-		$total    = 0;
101
-
102
-		foreach ( $selected as $price ) {
103
-
104
-			if ( ! isset( $options[ $price ] ) ) {
105
-				throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
106
-			}
107
-
108
-			$total += (float) wpinv_sanitize_amount( $price );
109
-		}
110
-
111
-		$this->fees[ $element['label'] ] = array(
112
-			'name'          => $element['label'],
113
-			'initial_fee'   => $total,
114
-			'recurring_fee' => 0,
115
-		);
116
-
117
-	}
86
+     * Process a price select field.
87
+     *
88
+     * @param array $element
89
+     * @param array $data
90
+     */
91
+    public function process_price_select( $element, $data ) {
92
+
93
+        // Abort if not passed.
94
+        if ( empty( $data[ $element['id'] ] ) ) {
95
+            return;
96
+        }
97
+
98
+        $options  = getpaid_convert_price_string_to_options( $element['options'] );
99
+        $selected = wpinv_parse_list( $data[ $element['id'] ] );
100
+        $total    = 0;
101
+
102
+        foreach ( $selected as $price ) {
103
+
104
+            if ( ! isset( $options[ $price ] ) ) {
105
+                throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
106
+            }
107
+
108
+            $total += (float) wpinv_sanitize_amount( $price );
109
+        }
110
+
111
+        $this->fees[ $element['label'] ] = array(
112
+            'name'          => $element['label'],
113
+            'initial_fee'   => $total,
114
+            'recurring_fee' => 0,
115
+        );
116
+
117
+    }
118 118
 
119 119
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission fees class
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param GetPaid_Payment_Form_Submission $submission
31 31
 	 */
32
-	public function __construct( $submission ) {
32
+	public function __construct($submission) {
33 33
 
34 34
 		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
35
+		if ($submission->has_invoice()) {
36 36
 			$this->fees = $submission->get_invoice()->get_fees();
37 37
 		}
38 38
 
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 		$data         = $submission->get_data();
41 41
 		$payment_form = $submission->get_payment_form();
42 42
 
43
-		foreach ( $payment_form->get_elements() as $element ) {
43
+		foreach ($payment_form->get_elements() as $element) {
44 44
 
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data );
45
+			if ('price_input' == $element['type']) {
46
+				$this->process_price_input($element, $data);
47 47
 			}
48 48
 
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
49
+			if ('price_select' == $element['type']) {
50
+				$this->process_price_select($element, $data);
51 51
 			}
52 52
 
53 53
 		}
@@ -60,21 +60,21 @@  discard block
 block discarded – undo
60 60
 	 * @param array $element
61 61
 	 * @param array $data
62 62
 	 */
63
-	public function process_price_input( $element, $data ) {
63
+	public function process_price_input($element, $data) {
64 64
 
65 65
 		// Abort if not passed.
66
-		if ( empty( $data[ $element['id'] ] ) ) {
66
+		if (empty($data[$element['id']])) {
67 67
 			return;
68 68
 		}
69 69
 
70
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
71
-		$minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
70
+		$amount  = (float) wpinv_sanitize_amount($data[$element['id']]);
71
+		$minimum = empty($element['minimum']) ? 0 : (float) wpinv_sanitize_amount($element['minimum']);
72 72
 
73
-		if ( $amount < $minimum ) {
74
-			throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) );
73
+		if ($amount < $minimum) {
74
+			throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), $minimum));
75 75
 		}
76 76
 
77
-		$this->fees[ $element['label'] ] = array(
77
+		$this->fees[$element['label']] = array(
78 78
 			'name'          => $element['label'],
79 79
 			'initial_fee'   => $amount,
80 80
 			'recurring_fee' => 0,
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 * @param array $element
89 89
 	 * @param array $data
90 90
 	 */
91
-	public function process_price_select( $element, $data ) {
91
+	public function process_price_select($element, $data) {
92 92
 
93 93
 		// Abort if not passed.
94
-		if ( empty( $data[ $element['id'] ] ) ) {
94
+		if (empty($data[$element['id']])) {
95 95
 			return;
96 96
 		}
97 97
 
98
-		$options  = getpaid_convert_price_string_to_options( $element['options'] );
99
-		$selected = wpinv_parse_list( $data[ $element['id'] ] );
98
+		$options  = getpaid_convert_price_string_to_options($element['options']);
99
+		$selected = wpinv_parse_list($data[$element['id']]);
100 100
 		$total    = 0;
101 101
 
102
-		foreach ( $selected as $price ) {
102
+		foreach ($selected as $price) {
103 103
 
104
-			if ( ! isset( $options[ $price ] ) ) {
105
-				throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
104
+			if (!isset($options[$price])) {
105
+				throw new Exception(__('You have selected an invalid amount', 'invoicing'));
106 106
 			}
107 107
 
108
-			$total += (float) wpinv_sanitize_amount( $price );
108
+			$total += (float) wpinv_sanitize_amount($price);
109 109
 		}
110 110
 
111
-		$this->fees[ $element['label'] ] = array(
111
+		$this->fees[$element['label']] = array(
112 112
 			'name'          => $element['label'],
113 113
 			'initial_fee'   => $total,
114 114
 			'recurring_fee' => 0,
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-taxes.php 2 patches
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -12,231 +12,231 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Taxes {
14 14
 
15
-	/**
16
-	 * Submission taxes.
17
-	 * @var array
18
-	 */
19
-	public $taxes = array();
20
-
21
-	/**
22
-	 * Initial tax.
23
-	 * @var float
24
-	 */
25
-	protected $initial_tax = 0;
26
-
27
-	/**
28
-	 * Recurring tax.
29
-	 * @var float
30
-	 */
31
-	protected $recurring_tax = 0;
15
+    /**
16
+     * Submission taxes.
17
+     * @var array
18
+     */
19
+    public $taxes = array();
20
+
21
+    /**
22
+     * Initial tax.
23
+     * @var float
24
+     */
25
+    protected $initial_tax = 0;
26
+
27
+    /**
28
+     * Recurring tax.
29
+     * @var float
30
+     */
31
+    protected $recurring_tax = 0;
32
+
33
+    /**
34
+     * Class constructor
35
+     *
36
+     * @param GetPaid_Payment_Form_Submission $submission
37
+     */
38
+    public function __construct( $submission ) {
39
+
40
+        // Validate VAT number.
41
+        $this->validate_vat( $submission );
42
+
43
+        foreach ( $submission->get_items() as $item ) {
44
+            $this->process_item_tax( $item, $submission );
45
+        }
46
+
47
+        // Process any existing invoice taxes.
48
+        if ( $submission->has_invoice() ) {
49
+            $this->taxes = $submission->get_invoice()->get_taxes();
50
+        }
51
+
52
+        // Add VAT.
53
+        $this->taxes['vat'] = array(
54
+            'name'          => 'vat',
55
+            'initial_tax'   => $this->initial_tax,
56
+            'recurring_tax' => $this->recurring_tax,
57
+        );
58
+
59
+    }
60
+
61
+    /**
62
+     * Maybe process tax.
63
+     *
64
+     * @since 1.0.19
65
+     * @param GetPaid_Form_Item $item
66
+     * @param GetPaid_Payment_Form_Submission $submission
67
+     */
68
+    public function process_item_tax( $item, $submission ) {
69
+
70
+        $rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
71
+        $price    = $item->get_sub_total();
72
+        $item_tax = $price * $rate * 0.01;
73
+
74
+        if ( wpinv_prices_include_tax() ) {
75
+            $item_tax = $price - ( $price - $price * $rate * 0.01 );
76
+        }
77
+
78
+        $this->initial_tax += $item_tax;
79
+
80
+        if ( $item->is_recurring() ) {
81
+            $this->recurring_tax += $item_tax;
82
+        }
83
+
84
+    }
85
+
86
+    /**
87
+     * Checks if the submission has a digital item.
88
+     *
89
+     * @param GetPaid_Payment_Form_Submission $submission
90
+     * @since 1.0.19
91
+     * @return bool
92
+     */
93
+    public function has_digital_item( $submission ) {
94
+
95
+        foreach ( $submission->get_items() as $item ) {
96
+
97
+            if ( 'digital' == $item->get_vat_rule() ) {
98
+                return true;
99
+            }
100
+
101
+        }
102
+
103
+        return false;
104
+    }
105
+
106
+    /**
107
+     * Checks if this is an eu store.
108
+     *
109
+     * @since 1.0.19
110
+     * @return bool
111
+     */
112
+    public function is_eu_store() {
113
+        return $this->is_eu_country( wpinv_get_default_country() );
114
+    }
115
+
116
+    /**
117
+     * Checks if this is an eu country.
118
+     *
119
+     * @param string $country
120
+     * @since 1.0.19
121
+     * @return bool
122
+     */
123
+    public function is_eu_country( $country ) {
124
+        return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
125
+    }
126
+
127
+    /**
128
+     * Checks if this is an eu purchase.
129
+     *
130
+     * @param string $customer_country
131
+     * @since 1.0.19
132
+     * @return bool
133
+     */
134
+    public function is_eu_transaction( $customer_country ) {
135
+        return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
136
+    }
137
+
138
+    /**
139
+     * Retrieves the vat number.
140
+     *
141
+     * @param GetPaid_Payment_Form_Submission $submission
142
+     * @since 1.0.19
143
+     * @return string
144
+     */
145
+    public function get_vat_number( $submission ) {
146
+
147
+        // Retrieve from the posted number.
148
+        $vat_number = $submission->get_field( 'wpinv_vat_number' );
149
+        if ( ! empty( $vat_number ) ) {
150
+            return wpinv_clean( $vat_number );
151
+        }
152
+
153
+        // Retrieve from the invoice.
154
+        return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
155
+    }
156
+
157
+    /**
158
+     * Retrieves the company.
159
+     *
160
+     * @param GetPaid_Payment_Form_Submission $submission
161
+     * @since 1.0.19
162
+     * @return string
163
+     */
164
+    public function get_company( $submission ) {
165
+
166
+        // Retrieve from the posted data.
167
+        $company = $submission->get_field( 'wpinv_company' );
168
+        if ( ! empty( $company ) ) {
169
+            return wpinv_clean( $company );
170
+        }
171
+
172
+        // Retrieve from the invoice.
173
+        return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
174
+    }
175
+
176
+    /**
177
+     * Checks if we requires a VAT number.
178
+     *
179
+     * @param bool $ip_in_eu Whether the customer IP is from the EU
180
+     * @param bool $country_in_eu Whether the customer country is from the EU
181
+     * @since 1.0.19
182
+     * @return string
183
+     */
184
+    public function requires_vat( $ip_in_eu, $country_in_eu ) {
185
+
186
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
187
+        $prevent_b2c = ! empty( $prevent_b2c );
188
+        $is_eu       = $ip_in_eu || $country_in_eu;
189
+
190
+        return $prevent_b2c && $is_eu;
191
+    }
32 192
 
33 193
     /**
34
-	 * Class constructor
35
-	 *
36
-	 * @param GetPaid_Payment_Form_Submission $submission
37
-	 */
38
-	public function __construct( $submission ) {
39
-
40
-		// Validate VAT number.
41
-		$this->validate_vat( $submission );
42
-
43
-		foreach ( $submission->get_items() as $item ) {
44
-			$this->process_item_tax( $item, $submission );
45
-		}
46
-
47
-		// Process any existing invoice taxes.
48
-		if ( $submission->has_invoice() ) {
49
-			$this->taxes = $submission->get_invoice()->get_taxes();
50
-		}
51
-
52
-		// Add VAT.
53
-		$this->taxes['vat'] = array(
54
-			'name'          => 'vat',
55
-			'initial_tax'   => $this->initial_tax,
56
-			'recurring_tax' => $this->recurring_tax,
57
-		);
58
-
59
-	}
60
-
61
-	/**
62
-	 * Maybe process tax.
63
-	 *
64
-	 * @since 1.0.19
65
-	 * @param GetPaid_Form_Item $item
66
-	 * @param GetPaid_Payment_Form_Submission $submission
67
-	 */
68
-	public function process_item_tax( $item, $submission ) {
69
-
70
-		$rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
71
-		$price    = $item->get_sub_total();
72
-		$item_tax = $price * $rate * 0.01;
73
-
74
-		if ( wpinv_prices_include_tax() ) {
75
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
76
-		}
77
-
78
-		$this->initial_tax += $item_tax;
79
-
80
-		if ( $item->is_recurring() ) {
81
-			$this->recurring_tax += $item_tax;
82
-		}
83
-
84
-	}
85
-
86
-	/**
87
-	 * Checks if the submission has a digital item.
88
-	 *
89
-	 * @param GetPaid_Payment_Form_Submission $submission
90
-	 * @since 1.0.19
91
-	 * @return bool
92
-	 */
93
-	public function has_digital_item( $submission ) {
94
-
95
-		foreach ( $submission->get_items() as $item ) {
96
-
97
-			if ( 'digital' == $item->get_vat_rule() ) {
98
-				return true;
99
-			}
100
-
101
-		}
102
-
103
-		return false;
104
-	}
105
-
106
-	/**
107
-	 * Checks if this is an eu store.
108
-	 *
109
-	 * @since 1.0.19
110
-	 * @return bool
111
-	 */
112
-	public function is_eu_store() {
113
-		return $this->is_eu_country( wpinv_get_default_country() );
114
-	}
115
-
116
-	/**
117
-	 * Checks if this is an eu country.
118
-	 *
119
-	 * @param string $country
120
-	 * @since 1.0.19
121
-	 * @return bool
122
-	 */
123
-	public function is_eu_country( $country ) {
124
-		return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
125
-	}
126
-
127
-	/**
128
-	 * Checks if this is an eu purchase.
129
-	 *
130
-	 * @param string $customer_country
131
-	 * @since 1.0.19
132
-	 * @return bool
133
-	 */
134
-	public function is_eu_transaction( $customer_country ) {
135
-		return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
136
-	}
137
-
138
-	/**
139
-	 * Retrieves the vat number.
140
-	 *
141
-	 * @param GetPaid_Payment_Form_Submission $submission
142
-	 * @since 1.0.19
143
-	 * @return string
144
-	 */
145
-	public function get_vat_number( $submission ) {
146
-
147
-		// Retrieve from the posted number.
148
-		$vat_number = $submission->get_field( 'wpinv_vat_number' );
149
-		if ( ! empty( $vat_number ) ) {
150
-			return wpinv_clean( $vat_number );
151
-		}
152
-
153
-		// Retrieve from the invoice.
154
-		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
155
-	}
156
-
157
-	/**
158
-	 * Retrieves the company.
159
-	 *
160
-	 * @param GetPaid_Payment_Form_Submission $submission
161
-	 * @since 1.0.19
162
-	 * @return string
163
-	 */
164
-	public function get_company( $submission ) {
165
-
166
-		// Retrieve from the posted data.
167
-		$company = $submission->get_field( 'wpinv_company' );
168
-		if ( ! empty( $company ) ) {
169
-			return wpinv_clean( $company );
170
-		}
171
-
172
-		// Retrieve from the invoice.
173
-		return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
174
-	}
175
-
176
-	/**
177
-	 * Checks if we requires a VAT number.
178
-	 *
179
-	 * @param bool $ip_in_eu Whether the customer IP is from the EU
180
-	 * @param bool $country_in_eu Whether the customer country is from the EU
181
-	 * @since 1.0.19
182
-	 * @return string
183
-	 */
184
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
185
-
186
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
187
-		$prevent_b2c = ! empty( $prevent_b2c );
188
-		$is_eu       = $ip_in_eu || $country_in_eu;
189
-
190
-		return $prevent_b2c && $is_eu;
191
-	}
192
-
193
-	/**
194
-	 * Validate VAT data.
195
-	 *
196
-	 * @param GetPaid_Payment_Form_Submission $submission
197
-	 * @since 1.0.19
198
-	 */
199
-	public function validate_vat( $submission ) {
200
-
201
-		$has_digital = $this->has_digital_item( $submission );
202
-		$in_eu       = $this->is_eu_transaction( $submission->country );
203
-
204
-		// Abort if we are not validating vat numbers.
205
-		if ( ! $has_digital && ! $in_eu ) {
194
+     * Validate VAT data.
195
+     *
196
+     * @param GetPaid_Payment_Form_Submission $submission
197
+     * @since 1.0.19
198
+     */
199
+    public function validate_vat( $submission ) {
200
+
201
+        $has_digital = $this->has_digital_item( $submission );
202
+        $in_eu       = $this->is_eu_transaction( $submission->country );
203
+
204
+        // Abort if we are not validating vat numbers.
205
+        if ( ! $has_digital && ! $in_eu ) {
206 206
             return;
207
-		}
207
+        }
208 208
 
209
-		// Prepare variables.
210
-		$vat_number  = $this->get_vat_number( $submission );
211
-		$company     = $this->get_company( $submission );
212
-		$ip_country  = WPInv_EUVat::get_country_by_ip();
209
+        // Prepare variables.
210
+        $vat_number  = $this->get_vat_number( $submission );
211
+        $company     = $this->get_company( $submission );
212
+        $ip_country  = WPInv_EUVat::get_country_by_ip();
213 213
         $is_eu       = $this->is_eu_country( $submission->country );
214 214
         $is_ip_eu    = $this->is_eu_country( $ip_country );
215 215
 
216
-		// If we're preventing business to consumer purchases, ensure
217
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
216
+        // If we're preventing business to consumer purchases, ensure
217
+        if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
218 218
 
219
-			// Ensure that a vat number has been specified.
220
-			throw new Exception(
221
-				wp_sprintf(
222
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
223
-					getpaid_vat_name()
224
-				)
225
-			);
219
+            // Ensure that a vat number has been specified.
220
+            throw new Exception(
221
+                wp_sprintf(
222
+                    __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
223
+                    getpaid_vat_name()
224
+                )
225
+            );
226 226
 
227
-		}
227
+        }
228 228
 
229
-		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
230
-		if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
229
+        // Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
230
+        if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
231 231
             return;
232
-		}
232
+        }
233 233
 
234
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
234
+        $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
235 235
 
236
-		if ( is_string( $is_valid ) ) {
237
-			throw new Exception( $is_valid );
238
-		}
236
+        if ( is_string( $is_valid ) ) {
237
+            throw new Exception( $is_valid );
238
+        }
239 239
 
240
-	}
240
+    }
241 241
 
242 242
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission taxes class
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param GetPaid_Payment_Form_Submission $submission
37 37
 	 */
38
-	public function __construct( $submission ) {
38
+	public function __construct($submission) {
39 39
 
40 40
 		// Validate VAT number.
41
-		$this->validate_vat( $submission );
41
+		$this->validate_vat($submission);
42 42
 
43
-		foreach ( $submission->get_items() as $item ) {
44
-			$this->process_item_tax( $item, $submission );
43
+		foreach ($submission->get_items() as $item) {
44
+			$this->process_item_tax($item, $submission);
45 45
 		}
46 46
 
47 47
 		// Process any existing invoice taxes.
48
-		if ( $submission->has_invoice() ) {
48
+		if ($submission->has_invoice()) {
49 49
 			$this->taxes = $submission->get_invoice()->get_taxes();
50 50
 		}
51 51
 
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
 	 * @param GetPaid_Form_Item $item
66 66
 	 * @param GetPaid_Payment_Form_Submission $submission
67 67
 	 */
68
-	public function process_item_tax( $item, $submission ) {
68
+	public function process_item_tax($item, $submission) {
69 69
 
70
-		$rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
70
+		$rate     = wpinv_get_tax_rate($submission->country, $submission->state, $item->get_id());
71 71
 		$price    = $item->get_sub_total();
72 72
 		$item_tax = $price * $rate * 0.01;
73 73
 
74
-		if ( wpinv_prices_include_tax() ) {
75
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
74
+		if (wpinv_prices_include_tax()) {
75
+			$item_tax = $price - ($price - $price * $rate * 0.01);
76 76
 		}
77 77
 
78 78
 		$this->initial_tax += $item_tax;
79 79
 
80
-		if ( $item->is_recurring() ) {
80
+		if ($item->is_recurring()) {
81 81
 			$this->recurring_tax += $item_tax;
82 82
 		}
83 83
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	 * @since 1.0.19
91 91
 	 * @return bool
92 92
 	 */
93
-	public function has_digital_item( $submission ) {
93
+	public function has_digital_item($submission) {
94 94
 
95
-		foreach ( $submission->get_items() as $item ) {
95
+		foreach ($submission->get_items() as $item) {
96 96
 
97
-			if ( 'digital' == $item->get_vat_rule() ) {
97
+			if ('digital' == $item->get_vat_rule()) {
98 98
 				return true;
99 99
 			}
100 100
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @return bool
111 111
 	 */
112 112
 	public function is_eu_store() {
113
-		return $this->is_eu_country( wpinv_get_default_country() );
113
+		return $this->is_eu_country(wpinv_get_default_country());
114 114
 	}
115 115
 
116 116
 	/**
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 * @since 1.0.19
121 121
 	 * @return bool
122 122
 	 */
123
-	public function is_eu_country( $country ) {
124
-		return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
123
+	public function is_eu_country($country) {
124
+		return getpaid_is_eu_state($country) || getpaid_is_gst_country($country);
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @since 1.0.19
132 132
 	 * @return bool
133 133
 	 */
134
-	public function is_eu_transaction( $customer_country ) {
135
-		return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
134
+	public function is_eu_transaction($customer_country) {
135
+		return $this->is_eu_country($customer_country) && $this->is_eu_store();
136 136
 	}
137 137
 
138 138
 	/**
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 	 * @since 1.0.19
143 143
 	 * @return string
144 144
 	 */
145
-	public function get_vat_number( $submission ) {
145
+	public function get_vat_number($submission) {
146 146
 
147 147
 		// Retrieve from the posted number.
148
-		$vat_number = $submission->get_field( 'wpinv_vat_number' );
149
-		if ( ! empty( $vat_number ) ) {
150
-			return wpinv_clean( $vat_number );
148
+		$vat_number = $submission->get_field('wpinv_vat_number');
149
+		if (!empty($vat_number)) {
150
+			return wpinv_clean($vat_number);
151 151
 		}
152 152
 
153 153
 		// Retrieve from the invoice.
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 	 * @since 1.0.19
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_company( $submission ) {
164
+	public function get_company($submission) {
165 165
 
166 166
 		// Retrieve from the posted data.
167
-		$company = $submission->get_field( 'wpinv_company' );
168
-		if ( ! empty( $company ) ) {
169
-			return wpinv_clean( $company );
167
+		$company = $submission->get_field('wpinv_company');
168
+		if (!empty($company)) {
169
+			return wpinv_clean($company);
170 170
 		}
171 171
 
172 172
 		// Retrieve from the invoice.
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	 * @since 1.0.19
182 182
 	 * @return string
183 183
 	 */
184
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
184
+	public function requires_vat($ip_in_eu, $country_in_eu) {
185 185
 
186
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
187
-		$prevent_b2c = ! empty( $prevent_b2c );
186
+		$prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase');
187
+		$prevent_b2c = !empty($prevent_b2c);
188 188
 		$is_eu       = $ip_in_eu || $country_in_eu;
189 189
 
190 190
 		return $prevent_b2c && $is_eu;
@@ -196,30 +196,30 @@  discard block
 block discarded – undo
196 196
 	 * @param GetPaid_Payment_Form_Submission $submission
197 197
 	 * @since 1.0.19
198 198
 	 */
199
-	public function validate_vat( $submission ) {
199
+	public function validate_vat($submission) {
200 200
 
201
-		$has_digital = $this->has_digital_item( $submission );
202
-		$in_eu       = $this->is_eu_transaction( $submission->country );
201
+		$has_digital = $this->has_digital_item($submission);
202
+		$in_eu       = $this->is_eu_transaction($submission->country);
203 203
 
204 204
 		// Abort if we are not validating vat numbers.
205
-		if ( ! $has_digital && ! $in_eu ) {
205
+		if (!$has_digital && !$in_eu) {
206 206
             return;
207 207
 		}
208 208
 
209 209
 		// Prepare variables.
210
-		$vat_number  = $this->get_vat_number( $submission );
211
-		$company     = $this->get_company( $submission );
210
+		$vat_number  = $this->get_vat_number($submission);
211
+		$company     = $this->get_company($submission);
212 212
 		$ip_country  = WPInv_EUVat::get_country_by_ip();
213
-        $is_eu       = $this->is_eu_country( $submission->country );
214
-        $is_ip_eu    = $this->is_eu_country( $ip_country );
213
+        $is_eu       = $this->is_eu_country($submission->country);
214
+        $is_ip_eu    = $this->is_eu_country($ip_country);
215 215
 
216 216
 		// If we're preventing business to consumer purchases, ensure
217
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
217
+		if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) {
218 218
 
219 219
 			// Ensure that a vat number has been specified.
220 220
 			throw new Exception(
221 221
 				wp_sprintf(
222
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
222
+					__('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'),
223 223
 					getpaid_vat_name()
224 224
 				)
225 225
 			);
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 		}
228 228
 
229 229
 		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
230
-		if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
230
+		if (!$is_eu || !$in_eu || empty($vat_number)) {
231 231
             return;
232 232
 		}
233 233
 
234
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
234
+		$is_valid = WPInv_EUVat::validate_vat_number($vat_number, $company, $submission->country);
235 235
 
236
-		if ( is_string( $is_valid ) ) {
237
-			throw new Exception( $is_valid );
236
+		if (is_string($is_valid)) {
237
+			throw new Exception($is_valid);
238 238
 		}
239 239
 
240 240
 	}
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-items.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -12,77 +12,77 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Items {
14 14
 
15
-	/**
16
-	 * Submission items.
17
-	 * @var GetPaid_Form_Item[]
18
-	 */
19
-	public $items = array();
15
+    /**
16
+     * Submission items.
17
+     * @var GetPaid_Form_Item[]
18
+     */
19
+    public $items = array();
20 20
 
21 21
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27 27
 
28
-		$data         = $submission->get_data();
29
-		$payment_form = $submission->get_payment_form();
28
+        $data         = $submission->get_data();
29
+        $payment_form = $submission->get_payment_form();
30 30
 
31
-		// Prepare the selected items.
32
-		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
35
-		}
31
+        // Prepare the selected items.
32
+        $selected_items = array();
33
+        if ( ! empty( $data['getpaid-items'] ) ) {
34
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
35
+        }
36 36
 
37
-		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ! $submission->has_invoice() ) {
39
-			$payment_form->set_items( $selected_items );
40
-		}
37
+        // For default forms, ensure that an item has been set.
38
+        if ( $payment_form->is_default() && ! $submission->has_invoice() ) {
39
+            $payment_form->set_items( $selected_items );
40
+        }
41 41
 
42
-		// Process each individual item.
43
-		foreach ( $payment_form->get_items() as $item ) {
44
-			$this->process_item( $item, $selected_items );
45
-		}
42
+        // Process each individual item.
43
+        foreach ( $payment_form->get_items() as $item ) {
44
+            $this->process_item( $item, $selected_items );
45
+        }
46 46
 
47
-	}
47
+    }
48 48
 
49
-	/**
50
-	 * Process a single item.
51
-	 *
52
-	 * @param GetPaid_Form_Item $item
53
-	 * @param array $selected_items
54
-	 */
55
-	public function process_item( $item, $selected_items ) {
49
+    /**
50
+     * Process a single item.
51
+     *
52
+     * @param GetPaid_Form_Item $item
53
+     * @param array $selected_items
54
+     */
55
+    public function process_item( $item, $selected_items ) {
56 56
 
57
-		// Abort if this is an optional item and it has not been selected.
58
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
59
-			return;
60
-		}
57
+        // Abort if this is an optional item and it has not been selected.
58
+        if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
59
+            return;
60
+        }
61 61
 
62
-		// (maybe) let customers change the quantities and prices.
63
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
62
+        // (maybe) let customers change the quantities and prices.
63
+        if ( isset( $selected_items[ $item->get_id() ] ) ) {
64 64
 
65
-			// Maybe change the quantities.
66
-			if ( $item->allows_quantities() ) {
67
-				$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
68
-			}
65
+            // Maybe change the quantities.
66
+            if ( $item->allows_quantities() ) {
67
+                $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
68
+            }
69 69
 
70
-			// Maybe change the price.
71
-			if ( $item->user_can_set_their_price() ) {
72
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
70
+            // Maybe change the price.
71
+            if ( $item->user_can_set_their_price() ) {
72
+                $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
73 73
 
74
-				// But don't get lower than the minimum price.
75
-				$price = max( $price, $item->get_minimum_price() );
74
+                // But don't get lower than the minimum price.
75
+                $price = max( $price, $item->get_minimum_price() );
76 76
 
77
-				$item->set_price( $price );
77
+                $item->set_price( $price );
78 78
 
79
-			}
79
+            }
80 80
 
81
-		}
81
+        }
82 82
 
83
-		// Save the item.
84
-		$this->items[] = $item;
83
+        // Save the item.
84
+        $this->items[] = $item;
85 85
 
86
-	}
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission itemss class
@@ -23,25 +23,25 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$data         = $submission->get_data();
29 29
 		$payment_form = $submission->get_payment_form();
30 30
 
31 31
 		// Prepare the selected items.
32 32
 		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
33
+		if (!empty($data['getpaid-items'])) {
34
+			$selected_items = wpinv_clean($data['getpaid-items']);
35 35
 		}
36 36
 
37 37
 		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ! $submission->has_invoice() ) {
39
-			$payment_form->set_items( $selected_items );
38
+		if ($payment_form->is_default() && !$submission->has_invoice()) {
39
+			$payment_form->set_items($selected_items);
40 40
 		}
41 41
 
42 42
 		// Process each individual item.
43
-		foreach ( $payment_form->get_items() as $item ) {
44
-			$this->process_item( $item, $selected_items );
43
+		foreach ($payment_form->get_items() as $item) {
44
+			$this->process_item($item, $selected_items);
45 45
 		}
46 46
 
47 47
 	}
@@ -52,29 +52,29 @@  discard block
 block discarded – undo
52 52
 	 * @param GetPaid_Form_Item $item
53 53
 	 * @param array $selected_items
54 54
 	 */
55
-	public function process_item( $item, $selected_items ) {
55
+	public function process_item($item, $selected_items) {
56 56
 
57 57
 		// Abort if this is an optional item and it has not been selected.
58
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
58
+		if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
59 59
 			return;
60 60
 		}
61 61
 
62 62
 		// (maybe) let customers change the quantities and prices.
63
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
63
+		if (isset($selected_items[$item->get_id()])) {
64 64
 
65 65
 			// Maybe change the quantities.
66
-			if ( $item->allows_quantities() ) {
67
-				$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
66
+			if ($item->allows_quantities()) {
67
+				$item->set_quantity((int) $selected_items[$item->get_id()]['quantity']);
68 68
 			}
69 69
 
70 70
 			// Maybe change the price.
71
-			if ( $item->user_can_set_their_price() ) {
72
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
71
+			if ($item->user_can_set_their_price()) {
72
+				$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
73 73
 
74 74
 				// But don't get lower than the minimum price.
75
-				$price = max( $price, $item->get_minimum_price() );
75
+				$price = max($price, $item->get_minimum_price());
76 76
 
77
-				$item->set_price( $price );
77
+				$item->set_price($price);
78 78
 
79 79
 			}
80 80
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form.php 2 patches
Indentation   +520 added lines, -520 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,55 +10,55 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,351 +114,351 @@  discard block
 block discarded – undo
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
+            // Form items.
273
+            if ( $value instanceof GetPaid_Form_Item ) {
271 274
 
272
-			// Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
275
+                if ( $value->can_purchase() ) {
276
+                    $prepared[] = $value;
277
+                }
274 278
 
275
-				if ( $value->can_purchase() ) {
276
-					$prepared[] = $value;
277
-				}
279
+                continue;
278 280
 
279
-				continue;
281
+            }
280 282
 
281
-			}
283
+            // $item_id => $quantity (buy buttons)
284
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
+                $item = new GetPaid_Form_Item( $key );
282 286
 
283
-			// $item_id => $quantity (buy buttons)
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
287
+                if ( $item->can_purchase() ) {
288
+                    $item->set_quantity( $value );
289
+                    $prepared[] = $item;
290
+                }
286 291
 
287
-				if ( $item->can_purchase() ) {
288
-					$item->set_quantity( $value );
289
-					$prepared[] = $item;
290
-				}
292
+                continue;
293
+            }
291 294
 
292
-				continue;
293
-			}
295
+            // Items saved via payment forms editor.
296
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
294 297
 
295
-			// Items saved via payment forms editor.
296
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
298
+                $item = new GetPaid_Form_Item( $value['id'] );
297 299
 
298
-				$item = new GetPaid_Form_Item( $value['id'] );
300
+                if ( ! $item->can_purchase() ) {
301
+                    continue;
302
+                }
299 303
 
300
-				if ( ! $item->can_purchase() ) {
301
-					continue;
302
-				}
304
+                // Sub-total (Cart items).
305
+                if ( isset( $value['subtotal'] ) ) {
306
+                    $item->set_price( $value['subtotal'] );
307
+                }
303 308
 
304
-				// Sub-total (Cart items).
305
-				if ( isset( $value['subtotal'] ) ) {
306
-					$item->set_price( $value['subtotal'] );
307
-				}
309
+                if ( isset( $value['quantity'] ) ) {
310
+                    $item->set_quantity( $value['quantity'] );
311
+                }
308 312
 
309
-				if ( isset( $value['quantity'] ) ) {
310
-					$item->set_quantity( $value['quantity'] );
311
-				}
313
+                if ( isset( $value['allow_quantities'] ) ) {
314
+                    $item->set_allow_quantities( $value['allow_quantities'] );
315
+                }
312 316
 
313
-				if ( isset( $value['allow_quantities'] ) ) {
314
-					$item->set_allow_quantities( $value['allow_quantities'] );
315
-				}
317
+                if ( isset( $value['required'] ) ) {
318
+                    $item->set_is_required( $value['required'] );
319
+                }
316 320
 
317
-				if ( isset( $value['required'] ) ) {
318
-					$item->set_is_required( $value['required'] );
319
-				}
321
+                if ( isset( $value['description'] ) ) {
322
+                    $item->set_custom_description( $value['description'] );
323
+                }
320 324
 
321
-				if ( isset( $value['description'] ) ) {
322
-					$item->set_custom_description( $value['description'] );
323
-				}
325
+                $prepared[] = $item;
326
+                continue;
324 327
 
325
-				$prepared[] = $item;
326
-				continue;
328
+            }
329
+
330
+            // $item_id => array( 'price' => 10 ) (item variations)
331
+            if ( is_numeric( $key ) && is_array( $value ) ) {
332
+                $item = new GetPaid_Form_Item( $key );
333
+
334
+                if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
335
+                    $item->set_price( $value['price'] );
336
+                }
337
+
338
+                if ( $item->can_purchase() ) {
339
+                    $prepared[] = $item;
340
+                }
341
+
342
+                continue;
343
+            }
344
+
345
+        }
346
+
347
+        if ( 'objects' == $return && 'view' == $context ) {
348
+            return $prepared;
349
+        }
350
+
351
+        $items = array();
352
+        foreach ( $prepared as $item ) {
353
+            $items[] = $item->prepare_data_for_use();
354
+        }
355
+
356
+        return $items;
357
+    }
358
+
359
+    /**
360
+     * Get a single item belonging to the form.
361
+     *
362
+     * @since 1.0.19
363
+     * @param  int $item_id The item id to return.
364
+     * @return GetPaid_Form_Item|bool
365
+     */
366
+    public function get_item( $item_id ) {
367
+
368
+        if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
369
+            return false;
370
+        }
371
+
372
+        foreach( $this->get_items() as $item ) {
373
+            if ( $item->get_id() == (int) $item_id ) {
374
+                return $item;
375
+            }
376
+        }
377
+
378
+        return false;
379
+
380
+    }
381
+
382
+    /**
383
+     * Gets a single element.
384
+     *
385
+     * @since 1.0.19
386
+     * @param  string $element_type The element type to return.
387
+     * @return array|bool
388
+     */
389
+    public function get_element_type( $element_type ) {
390
+
391
+        if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
392
+            return false;
393
+        }
394
+
395
+        foreach ( $this->get_prop( 'elements' ) as $element ) {
396
+
397
+            if ( $element['type'] == $element_type ) {
398
+                return $element;
399
+            }
400
+
401
+        }
402
+
403
+        return false;
404
+
405
+    }
406
+
407
+    /**
408
+     * Get the total amount earned via this form.
409
+     *
410
+     * @since 1.0.19
411
+     * @param  string $context View or edit context.
412
+     * @return array
413
+     */
414
+    public function get_earned( $context = 'view' ) {
415
+        return $this->get_prop( 'earned', $context );
416
+    }
417
+
418
+    /**
419
+     * Get the total amount refunded via this form.
420
+     *
421
+     * @since 1.0.19
422
+     * @param  string $context View or edit context.
423
+     * @return array
424
+     */
425
+    public function get_refunded( $context = 'view' ) {
426
+        return $this->get_prop( 'refunded', $context );
427
+    }
327 428
 
328
-			}
429
+    /**
430
+     * Get the total amount cancelled via this form.
431
+     *
432
+     * @since 1.0.19
433
+     * @param  string $context View or edit context.
434
+     * @return array
435
+     */
436
+    public function get_cancelled( $context = 'view' ) {
437
+        return $this->get_prop( 'cancelled', $context );
438
+    }
329 439
 
330
-			// $item_id => array( 'price' => 10 ) (item variations)
331
-			if ( is_numeric( $key ) && is_array( $value ) ) {
332
-				$item = new GetPaid_Form_Item( $key );
440
+    /**
441
+     * Get the total amount failed via this form.
442
+     *
443
+     * @since 1.0.19
444
+     * @param  string $context View or edit context.
445
+     * @return array
446
+     */
447
+    public function get_failed( $context = 'view' ) {
448
+        return $this->get_prop( 'failed', $context );
449
+    }
333 450
 
334
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
335
-					$item->set_price( $value['price'] );
336
-				}
337
-
338
-				if ( $item->can_purchase() ) {
339
-					$prepared[] = $item;
340
-				}
341
-
342
-				continue;
343
-			}
344
-
345
-		}
346
-
347
-		if ( 'objects' == $return && 'view' == $context ) {
348
-			return $prepared;
349
-		}
350
-
351
-		$items = array();
352
-		foreach ( $prepared as $item ) {
353
-			$items[] = $item->prepare_data_for_use();
354
-		}
355
-
356
-		return $items;
357
-	}
358
-
359
-	/**
360
-	 * Get a single item belonging to the form.
361
-	 *
362
-	 * @since 1.0.19
363
-	 * @param  int $item_id The item id to return.
364
-	 * @return GetPaid_Form_Item|bool
365
-	 */
366
-	public function get_item( $item_id ) {
367
-
368
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
369
-			return false;
370
-		}
371
-
372
-		foreach( $this->get_items() as $item ) {
373
-			if ( $item->get_id() == (int) $item_id ) {
374
-				return $item;
375
-			}
376
-		}
377
-
378
-		return false;
379
-
380
-	}
381
-
382
-	/**
383
-	 * Gets a single element.
384
-	 *
385
-	 * @since 1.0.19
386
-	 * @param  string $element_type The element type to return.
387
-	 * @return array|bool
388
-	 */
389
-	public function get_element_type( $element_type ) {
390
-
391
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
392
-			return false;
393
-		}
394
-
395
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
396
-
397
-			if ( $element['type'] == $element_type ) {
398
-				return $element;
399
-			}
400
-
401
-		}
402
-
403
-		return false;
404
-
405
-	}
406
-
407
-	/**
408
-	 * Get the total amount earned via this form.
409
-	 *
410
-	 * @since 1.0.19
411
-	 * @param  string $context View or edit context.
412
-	 * @return array
413
-	 */
414
-	public function get_earned( $context = 'view' ) {
415
-		return $this->get_prop( 'earned', $context );
416
-	}
417
-
418
-	/**
419
-	 * Get the total amount refunded via this form.
420
-	 *
421
-	 * @since 1.0.19
422
-	 * @param  string $context View or edit context.
423
-	 * @return array
424
-	 */
425
-	public function get_refunded( $context = 'view' ) {
426
-		return $this->get_prop( 'refunded', $context );
427
-	}
428
-
429
-	/**
430
-	 * Get the total amount cancelled via this form.
431
-	 *
432
-	 * @since 1.0.19
433
-	 * @param  string $context View or edit context.
434
-	 * @return array
435
-	 */
436
-	public function get_cancelled( $context = 'view' ) {
437
-		return $this->get_prop( 'cancelled', $context );
438
-	}
439
-
440
-	/**
441
-	 * Get the total amount failed via this form.
442
-	 *
443
-	 * @since 1.0.19
444
-	 * @param  string $context View or edit context.
445
-	 * @return array
446
-	 */
447
-	public function get_failed( $context = 'view' ) {
448
-		return $this->get_prop( 'failed', $context );
449
-	}
450
-
451
-	/**
452
-	 * Get the currency.
453
-	 *
454
-	 * @since 1.0.19
455
-	 * @param  string $context View or edit context.
456
-	 * @return string
457
-	 */
458
-	public function get_currency() {
459
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
460
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
461
-	}
451
+    /**
452
+     * Get the currency.
453
+     *
454
+     * @since 1.0.19
455
+     * @param  string $context View or edit context.
456
+     * @return string
457
+     */
458
+    public function get_currency() {
459
+        $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
460
+        return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
461
+    }
462 462
 
463 463
     /*
464 464
 	|--------------------------------------------------------------------------
@@ -471,22 +471,22 @@  discard block
 block discarded – undo
471 471
     */
472 472
 
473 473
     /**
474
-	 * Set plugin version when the item was created.
475
-	 *
476
-	 * @since 1.0.19
477
-	 */
478
-	public function set_version( $value ) {
479
-		$this->set_prop( 'version', $value );
474
+     * Set plugin version when the item was created.
475
+     *
476
+     * @since 1.0.19
477
+     */
478
+    public function set_version( $value ) {
479
+        $this->set_prop( 'version', $value );
480 480
     }
481 481
 
482 482
     /**
483
-	 * Set date when the item was created.
484
-	 *
485
-	 * @since 1.0.19
486
-	 * @param string $value Value to set.
483
+     * Set date when the item was created.
484
+     *
485
+     * @since 1.0.19
486
+     * @param string $value Value to set.
487 487
      * @return bool Whether or not the date was set.
488
-	 */
489
-	public function set_date_created( $value ) {
488
+     */
489
+    public function set_date_created( $value ) {
490 490
         $date = strtotime( $value );
491 491
 
492 492
         if ( $date ) {
@@ -499,13 +499,13 @@  discard block
 block discarded – undo
499 499
     }
500 500
 
501 501
     /**
502
-	 * Set date when the item was last modified.
503
-	 *
504
-	 * @since 1.0.19
505
-	 * @param string $value Value to set.
502
+     * Set date when the item was last modified.
503
+     *
504
+     * @since 1.0.19
505
+     * @param string $value Value to set.
506 506
      * @return bool Whether or not the date was set.
507
-	 */
508
-	public function set_date_modified( $value ) {
507
+     */
508
+    public function set_date_modified( $value ) {
509 509
         $date = strtotime( $value );
510 510
 
511 511
         if ( $date ) {
@@ -518,118 +518,118 @@  discard block
 block discarded – undo
518 518
     }
519 519
 
520 520
     /**
521
-	 * Set the item name.
522
-	 *
523
-	 * @since 1.0.19
524
-	 * @param  string $value New name.
525
-	 */
526
-	public function set_name( $value ) {
527
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
528
-    }
529
-
530
-    /**
531
-	 * Alias of self::set_name().
532
-	 *
533
-	 * @since 1.0.19
534
-	 * @param  string $value New name.
535
-	 */
536
-	public function set_title( $value ) {
537
-		$this->set_name( $value );
538
-    }
539
-
540
-    /**
541
-	 * Set the owner of the item.
542
-	 *
543
-	 * @since 1.0.19
544
-	 * @param  int $value New author.
545
-	 */
546
-	public function set_author( $value ) {
547
-		$this->set_prop( 'author', (int) $value );
548
-	}
549
-
550
-	/**
551
-	 * Set the form elements.
552
-	 *
553
-	 * @since 1.0.19
554
-	 * @param  array $value Form elements.
555
-	 */
556
-	public function set_elements( $value ) {
557
-		if ( is_array( $value ) ) {
558
-			$this->set_prop( 'elements', $value );
559
-		}
560
-	}
561
-
562
-	/**
563
-	 * Set the form items.
564
-	 *
565
-	 * @since 1.0.19
566
-	 * @param  array $value Form elements.
567
-	 */
568
-	public function set_items( $value ) {
569
-		if ( is_array( $value ) ) {
570
-			$this->set_prop( 'items', $value );
571
-		}
572
-	}
573
-
574
-	/**
575
-	 * Set the total amount earned via this form.
576
-	 *
577
-	 * @since 1.0.19
578
-	 * @param  float $value Amount earned.
579
-	 */
580
-	public function set_earned( $value ) {
581
-		$value = max( (float) $value, 0 );
582
-		$this->set_prop( 'earned', $value );
583
-	}
584
-
585
-	/**
586
-	 * Set the total amount refunded via this form.
587
-	 *
588
-	 * @since 1.0.19
589
-	 * @param  float $value Amount refunded.
590
-	 */
591
-	public function set_refunded( $value ) {
592
-		$value = max( (float) $value, 0 );
593
-		$this->set_prop( 'refunded', $value );
594
-	}
595
-
596
-	/**
597
-	 * Set the total amount cancelled via this form.
598
-	 *
599
-	 * @since 1.0.19
600
-	 * @param  float $value Amount cancelled.
601
-	 */
602
-	public function set_cancelled( $value ) {
603
-		$value = max( (float) $value, 0 );
604
-		$this->set_prop( 'cancelled', $value );
605
-	}
606
-
607
-	/**
608
-	 * Set the total amount failed via this form.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @param  float $value Amount cancelled.
612
-	 */
613
-	public function set_failed( $value ) {
614
-		$value = max( (float) $value, 0 );
615
-		$this->set_prop( 'failed', $value );
616
-	}
521
+     * Set the item name.
522
+     *
523
+     * @since 1.0.19
524
+     * @param  string $value New name.
525
+     */
526
+    public function set_name( $value ) {
527
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
528
+    }
529
+
530
+    /**
531
+     * Alias of self::set_name().
532
+     *
533
+     * @since 1.0.19
534
+     * @param  string $value New name.
535
+     */
536
+    public function set_title( $value ) {
537
+        $this->set_name( $value );
538
+    }
539
+
540
+    /**
541
+     * Set the owner of the item.
542
+     *
543
+     * @since 1.0.19
544
+     * @param  int $value New author.
545
+     */
546
+    public function set_author( $value ) {
547
+        $this->set_prop( 'author', (int) $value );
548
+    }
549
+
550
+    /**
551
+     * Set the form elements.
552
+     *
553
+     * @since 1.0.19
554
+     * @param  array $value Form elements.
555
+     */
556
+    public function set_elements( $value ) {
557
+        if ( is_array( $value ) ) {
558
+            $this->set_prop( 'elements', $value );
559
+        }
560
+    }
561
+
562
+    /**
563
+     * Set the form items.
564
+     *
565
+     * @since 1.0.19
566
+     * @param  array $value Form elements.
567
+     */
568
+    public function set_items( $value ) {
569
+        if ( is_array( $value ) ) {
570
+            $this->set_prop( 'items', $value );
571
+        }
572
+    }
573
+
574
+    /**
575
+     * Set the total amount earned via this form.
576
+     *
577
+     * @since 1.0.19
578
+     * @param  float $value Amount earned.
579
+     */
580
+    public function set_earned( $value ) {
581
+        $value = max( (float) $value, 0 );
582
+        $this->set_prop( 'earned', $value );
583
+    }
584
+
585
+    /**
586
+     * Set the total amount refunded via this form.
587
+     *
588
+     * @since 1.0.19
589
+     * @param  float $value Amount refunded.
590
+     */
591
+    public function set_refunded( $value ) {
592
+        $value = max( (float) $value, 0 );
593
+        $this->set_prop( 'refunded', $value );
594
+    }
595
+
596
+    /**
597
+     * Set the total amount cancelled via this form.
598
+     *
599
+     * @since 1.0.19
600
+     * @param  float $value Amount cancelled.
601
+     */
602
+    public function set_cancelled( $value ) {
603
+        $value = max( (float) $value, 0 );
604
+        $this->set_prop( 'cancelled', $value );
605
+    }
606
+
607
+    /**
608
+     * Set the total amount failed via this form.
609
+     *
610
+     * @since 1.0.19
611
+     * @param  float $value Amount cancelled.
612
+     */
613
+    public function set_failed( $value ) {
614
+        $value = max( (float) $value, 0 );
615
+        $this->set_prop( 'failed', $value );
616
+    }
617 617
 
618 618
     /**
619 619
      * Create 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 create( $data = array() ) {
625 625
 
626
-		// Set the properties.
627
-		if ( is_array( $data ) ) {
628
-			$this->set_props( $data );
629
-		}
626
+        // Set the properties.
627
+        if ( is_array( $data ) ) {
628
+            $this->set_props( $data );
629
+        }
630 630
 
631
-		// Save the item.
632
-		return $this->save();
631
+        // Save the item.
632
+        return $this->save();
633 633
 
634 634
     }
635 635
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
      * Updates an item. For backwards compatibilty.
638 638
      *
639 639
      * @deprecated
640
-	 * @return int item id
640
+     * @return int item id
641 641
      */
642 642
     public function update( $data = array() ) {
643 643
         return $this->create( $data );
@@ -653,22 +653,22 @@  discard block
 block discarded – undo
653 653
 	*/
654 654
 
655 655
     /**
656
-	 * Checks whether this is the default payment form.
657
-	 *
658
-	 * @since 1.0.19
659
-	 * @return bool
660
-	 */
656
+     * Checks whether this is the default payment form.
657
+     *
658
+     * @since 1.0.19
659
+     * @return bool
660
+     */
661 661
     public function is_default() {
662 662
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
663 663
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
664
-	}
664
+    }
665 665
 
666 666
     /**
667
-	 * Checks whether the form is active.
668
-	 *
669
-	 * @since 1.0.19
670
-	 * @return bool
671
-	 */
667
+     * Checks whether the form is active.
668
+     *
669
+     * @since 1.0.19
670
+     * @return bool
671
+     */
672 672
     public function is_active() {
673 673
         $is_active = 0 !== (int) $this->get_id();
674 674
 
@@ -677,70 +677,70 @@  discard block
 block discarded – undo
677 677
         }
678 678
 
679 679
         return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
680
-	}
681
-
682
-	/**
683
-	 * Checks whether the form has a given item.
684
-	 *
685
-	 * @since 1.0.19
686
-	 * @return bool
687
-	 */
680
+    }
681
+
682
+    /**
683
+     * Checks whether the form has a given item.
684
+     *
685
+     * @since 1.0.19
686
+     * @return bool
687
+     */
688 688
     public function has_item( $item_id ) {
689 689
         return false !== $this->get_item( $item_id );
690
-	}
691
-
692
-	/**
693
-	 * Checks whether the form has a given element.
694
-	 *
695
-	 * @since 1.0.19
696
-	 * @return bool
697
-	 */
690
+    }
691
+
692
+    /**
693
+     * Checks whether the form has a given element.
694
+     *
695
+     * @since 1.0.19
696
+     * @return bool
697
+     */
698 698
     public function has_element_type( $element_type ) {
699 699
         return false !== $this->get_element_type( $element_type );
700
-	}
701
-
702
-	/**
703
-	 * Checks whether this form is recurring or not.
704
-	 *
705
-	 * @since 1.0.19
706
-	 * @return bool
707
-	 */
700
+    }
701
+
702
+    /**
703
+     * Checks whether this form is recurring or not.
704
+     *
705
+     * @since 1.0.19
706
+     * @return bool
707
+     */
708 708
     public function is_recurring() {
709 709
 
710
-		if ( ! empty( $this->invoice ) ) {
711
-			return $this->invoice->is_recurring();
712
-		}
710
+        if ( ! empty( $this->invoice ) ) {
711
+            return $this->invoice->is_recurring();
712
+        }
713 713
 
714
-		foreach ( $this->get_items() as $item ) {
714
+        foreach ( $this->get_items() as $item ) {
715 715
 
716
-			if ( $item->is_recurring() ) {
717
-				return true;
718
-			}
716
+            if ( $item->is_recurring() ) {
717
+                return true;
718
+            }
719 719
 
720
-		}
720
+        }
721 721
 
722 722
         return false;
723
-	}
723
+    }
724 724
 
725
-	/**
726
-	 * Retrieves the form's html.
727
-	 *
728
-	 * @since 1.0.19
729
-	 */
725
+    /**
726
+     * Retrieves the form's html.
727
+     *
728
+     * @since 1.0.19
729
+     */
730 730
     public function get_html() {
731 731
 
732
-		// Return the HTML.
733
-		return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
732
+        // Return the HTML.
733
+        return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
734 734
 
735
-	}
735
+    }
736 736
 
737
-	/**
738
-	 * Displays the payment form.
739
-	 *
740
-	 * @since 1.0.19
741
-	 */
737
+    /**
738
+     * Displays the payment form.
739
+     *
740
+     * @since 1.0.19
741
+     */
742 742
     public function display() {
743
-		echo $this->get_html();
743
+        echo $this->get_html();
744 744
     }
745 745
 
746 746
 }
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -72,28 +72,28 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,22 +257,22 @@  discard block
 block discarded – undo
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 272
 			// Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
273
+			if ($value instanceof GetPaid_Form_Item) {
274 274
 
275
-				if ( $value->can_purchase() ) {
275
+				if ($value->can_purchase()) {
276 276
 					$prepared[] = $value;
277 277
 				}
278 278
 
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			// $item_id => $quantity (buy buttons)
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
284
+			if (is_numeric($key) && is_numeric($value)) {
285
+				$item = new GetPaid_Form_Item($key);
286 286
 
287
-				if ( $item->can_purchase() ) {
288
-					$item->set_quantity( $value );
287
+				if ($item->can_purchase()) {
288
+					$item->set_quantity($value);
289 289
 					$prepared[] = $item;
290 290
 				}
291 291
 
@@ -293,33 +293,33 @@  discard block
 block discarded – undo
293 293
 			}
294 294
 
295 295
 			// Items saved via payment forms editor.
296
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
296
+			if (is_array($value) && isset($value['id'])) {
297 297
 
298
-				$item = new GetPaid_Form_Item( $value['id'] );
298
+				$item = new GetPaid_Form_Item($value['id']);
299 299
 
300
-				if ( ! $item->can_purchase() ) {
300
+				if (!$item->can_purchase()) {
301 301
 					continue;
302 302
 				}
303 303
 
304 304
 				// Sub-total (Cart items).
305
-				if ( isset( $value['subtotal'] ) ) {
306
-					$item->set_price( $value['subtotal'] );
305
+				if (isset($value['subtotal'])) {
306
+					$item->set_price($value['subtotal']);
307 307
 				}
308 308
 
309
-				if ( isset( $value['quantity'] ) ) {
310
-					$item->set_quantity( $value['quantity'] );
309
+				if (isset($value['quantity'])) {
310
+					$item->set_quantity($value['quantity']);
311 311
 				}
312 312
 
313
-				if ( isset( $value['allow_quantities'] ) ) {
314
-					$item->set_allow_quantities( $value['allow_quantities'] );
313
+				if (isset($value['allow_quantities'])) {
314
+					$item->set_allow_quantities($value['allow_quantities']);
315 315
 				}
316 316
 
317
-				if ( isset( $value['required'] ) ) {
318
-					$item->set_is_required( $value['required'] );
317
+				if (isset($value['required'])) {
318
+					$item->set_is_required($value['required']);
319 319
 				}
320 320
 
321
-				if ( isset( $value['description'] ) ) {
322
-					$item->set_custom_description( $value['description'] );
321
+				if (isset($value['description'])) {
322
+					$item->set_custom_description($value['description']);
323 323
 				}
324 324
 
325 325
 				$prepared[] = $item;
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 			}
329 329
 
330 330
 			// $item_id => array( 'price' => 10 ) (item variations)
331
-			if ( is_numeric( $key ) && is_array( $value ) ) {
332
-				$item = new GetPaid_Form_Item( $key );
331
+			if (is_numeric($key) && is_array($value)) {
332
+				$item = new GetPaid_Form_Item($key);
333 333
 
334
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
335
-					$item->set_price( $value['price'] );
334
+				if (isset($value['price']) && $item->user_can_set_their_price()) {
335
+					$item->set_price($value['price']);
336 336
 				}
337 337
 
338
-				if ( $item->can_purchase() ) {
338
+				if ($item->can_purchase()) {
339 339
 					$prepared[] = $item;
340 340
 				}
341 341
 
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
 
345 345
 		}
346 346
 
347
-		if ( 'objects' == $return && 'view' == $context ) {
347
+		if ('objects' == $return && 'view' == $context) {
348 348
 			return $prepared;
349 349
 		}
350 350
 
351 351
 		$items = array();
352
-		foreach ( $prepared as $item ) {
352
+		foreach ($prepared as $item) {
353 353
 			$items[] = $item->prepare_data_for_use();
354 354
 		}
355 355
 
@@ -363,14 +363,14 @@  discard block
 block discarded – undo
363 363
 	 * @param  int $item_id The item id to return.
364 364
 	 * @return GetPaid_Form_Item|bool
365 365
 	 */
366
-	public function get_item( $item_id ) {
366
+	public function get_item($item_id) {
367 367
 
368
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
368
+		if (empty($item_id) || !is_numeric($item_id)) {
369 369
 			return false;
370 370
 		}
371 371
 
372
-		foreach( $this->get_items() as $item ) {
373
-			if ( $item->get_id() == (int) $item_id ) {
372
+		foreach ($this->get_items() as $item) {
373
+			if ($item->get_id() == (int) $item_id) {
374 374
 				return $item;
375 375
 			}
376 376
 		}
@@ -386,15 +386,15 @@  discard block
 block discarded – undo
386 386
 	 * @param  string $element_type The element type to return.
387 387
 	 * @return array|bool
388 388
 	 */
389
-	public function get_element_type( $element_type ) {
389
+	public function get_element_type($element_type) {
390 390
 
391
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
391
+		if (empty($element_type) || !is_scalar($element_type)) {
392 392
 			return false;
393 393
 		}
394 394
 
395
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
395
+		foreach ($this->get_prop('elements') as $element) {
396 396
 
397
-			if ( $element['type'] == $element_type ) {
397
+			if ($element['type'] == $element_type) {
398 398
 				return $element;
399 399
 			}
400 400
 
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 * @param  string $context View or edit context.
412 412
 	 * @return array
413 413
 	 */
414
-	public function get_earned( $context = 'view' ) {
415
-		return $this->get_prop( 'earned', $context );
414
+	public function get_earned($context = 'view') {
415
+		return $this->get_prop('earned', $context);
416 416
 	}
417 417
 
418 418
 	/**
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
 	 * @param  string $context View or edit context.
423 423
 	 * @return array
424 424
 	 */
425
-	public function get_refunded( $context = 'view' ) {
426
-		return $this->get_prop( 'refunded', $context );
425
+	public function get_refunded($context = 'view') {
426
+		return $this->get_prop('refunded', $context);
427 427
 	}
428 428
 
429 429
 	/**
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	 * @param  string $context View or edit context.
434 434
 	 * @return array
435 435
 	 */
436
-	public function get_cancelled( $context = 'view' ) {
437
-		return $this->get_prop( 'cancelled', $context );
436
+	public function get_cancelled($context = 'view') {
437
+		return $this->get_prop('cancelled', $context);
438 438
 	}
439 439
 
440 440
 	/**
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	 * @param  string $context View or edit context.
445 445
 	 * @return array
446 446
 	 */
447
-	public function get_failed( $context = 'view' ) {
448
-		return $this->get_prop( 'failed', $context );
447
+	public function get_failed($context = 'view') {
448
+		return $this->get_prop('failed', $context);
449 449
 	}
450 450
 
451 451
 	/**
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	 * @return string
457 457
 	 */
458 458
 	public function get_currency() {
459
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
460
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
459
+		$currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency();
460
+		return apply_filters('getpaid-payment-form-currency', $currency, $this);
461 461
 	}
462 462
 
463 463
     /*
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 	 *
476 476
 	 * @since 1.0.19
477 477
 	 */
478
-	public function set_version( $value ) {
479
-		$this->set_prop( 'version', $value );
478
+	public function set_version($value) {
479
+		$this->set_prop('version', $value);
480 480
     }
481 481
 
482 482
     /**
@@ -486,11 +486,11 @@  discard block
 block discarded – undo
486 486
 	 * @param string $value Value to set.
487 487
      * @return bool Whether or not the date was set.
488 488
 	 */
489
-	public function set_date_created( $value ) {
490
-        $date = strtotime( $value );
489
+	public function set_date_created($value) {
490
+        $date = strtotime($value);
491 491
 
492
-        if ( $date ) {
493
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
492
+        if ($date) {
493
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
494 494
             return true;
495 495
         }
496 496
 
@@ -505,11 +505,11 @@  discard block
 block discarded – undo
505 505
 	 * @param string $value Value to set.
506 506
      * @return bool Whether or not the date was set.
507 507
 	 */
508
-	public function set_date_modified( $value ) {
509
-        $date = strtotime( $value );
508
+	public function set_date_modified($value) {
509
+        $date = strtotime($value);
510 510
 
511
-        if ( $date ) {
512
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
511
+        if ($date) {
512
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
513 513
             return true;
514 514
         }
515 515
 
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	 * @since 1.0.19
524 524
 	 * @param  string $value New name.
525 525
 	 */
526
-	public function set_name( $value ) {
527
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
526
+	public function set_name($value) {
527
+		$this->set_prop('name', sanitize_text_field($value));
528 528
     }
529 529
 
530 530
     /**
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 	 * @since 1.0.19
534 534
 	 * @param  string $value New name.
535 535
 	 */
536
-	public function set_title( $value ) {
537
-		$this->set_name( $value );
536
+	public function set_title($value) {
537
+		$this->set_name($value);
538 538
     }
539 539
 
540 540
     /**
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
 	 * @since 1.0.19
544 544
 	 * @param  int $value New author.
545 545
 	 */
546
-	public function set_author( $value ) {
547
-		$this->set_prop( 'author', (int) $value );
546
+	public function set_author($value) {
547
+		$this->set_prop('author', (int) $value);
548 548
 	}
549 549
 
550 550
 	/**
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 	 * @since 1.0.19
554 554
 	 * @param  array $value Form elements.
555 555
 	 */
556
-	public function set_elements( $value ) {
557
-		if ( is_array( $value ) ) {
558
-			$this->set_prop( 'elements', $value );
556
+	public function set_elements($value) {
557
+		if (is_array($value)) {
558
+			$this->set_prop('elements', $value);
559 559
 		}
560 560
 	}
561 561
 
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 	 * @since 1.0.19
566 566
 	 * @param  array $value Form elements.
567 567
 	 */
568
-	public function set_items( $value ) {
569
-		if ( is_array( $value ) ) {
570
-			$this->set_prop( 'items', $value );
568
+	public function set_items($value) {
569
+		if (is_array($value)) {
570
+			$this->set_prop('items', $value);
571 571
 		}
572 572
 	}
573 573
 
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 	 * @since 1.0.19
578 578
 	 * @param  float $value Amount earned.
579 579
 	 */
580
-	public function set_earned( $value ) {
581
-		$value = max( (float) $value, 0 );
582
-		$this->set_prop( 'earned', $value );
580
+	public function set_earned($value) {
581
+		$value = max((float) $value, 0);
582
+		$this->set_prop('earned', $value);
583 583
 	}
584 584
 
585 585
 	/**
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
 	 * @since 1.0.19
589 589
 	 * @param  float $value Amount refunded.
590 590
 	 */
591
-	public function set_refunded( $value ) {
592
-		$value = max( (float) $value, 0 );
593
-		$this->set_prop( 'refunded', $value );
591
+	public function set_refunded($value) {
592
+		$value = max((float) $value, 0);
593
+		$this->set_prop('refunded', $value);
594 594
 	}
595 595
 
596 596
 	/**
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
 	 * @since 1.0.19
600 600
 	 * @param  float $value Amount cancelled.
601 601
 	 */
602
-	public function set_cancelled( $value ) {
603
-		$value = max( (float) $value, 0 );
604
-		$this->set_prop( 'cancelled', $value );
602
+	public function set_cancelled($value) {
603
+		$value = max((float) $value, 0);
604
+		$this->set_prop('cancelled', $value);
605 605
 	}
606 606
 
607 607
 	/**
@@ -610,9 +610,9 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param  float $value Amount cancelled.
612 612
 	 */
613
-	public function set_failed( $value ) {
614
-		$value = max( (float) $value, 0 );
615
-		$this->set_prop( 'failed', $value );
613
+	public function set_failed($value) {
614
+		$value = max((float) $value, 0);
615
+		$this->set_prop('failed', $value);
616 616
 	}
617 617
 
618 618
     /**
@@ -621,11 +621,11 @@  discard block
 block discarded – undo
621 621
      * @deprecated
622 622
 	 * @return int item id
623 623
      */
624
-    public function create( $data = array() ) {
624
+    public function create($data = array()) {
625 625
 
626 626
 		// Set the properties.
627
-		if ( is_array( $data ) ) {
628
-			$this->set_props( $data );
627
+		if (is_array($data)) {
628
+			$this->set_props($data);
629 629
 		}
630 630
 
631 631
 		// Save the item.
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
      * @deprecated
640 640
 	 * @return int item id
641 641
      */
642
-    public function update( $data = array() ) {
643
-        return $this->create( $data );
642
+    public function update($data = array()) {
643
+        return $this->create($data);
644 644
     }
645 645
 
646 646
     /*
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	 */
661 661
     public function is_default() {
662 662
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
663
-        return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
663
+        return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this);
664 664
 	}
665 665
 
666 666
     /**
@@ -672,11 +672,11 @@  discard block
 block discarded – undo
672 672
     public function is_active() {
673 673
         $is_active = 0 !== (int) $this->get_id();
674 674
 
675
-        if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) {
675
+        if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') {
676 676
             $is_active = false;
677 677
         }
678 678
 
679
-        return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
679
+        return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this);
680 680
 	}
681 681
 
682 682
 	/**
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
 	 * @since 1.0.19
686 686
 	 * @return bool
687 687
 	 */
688
-    public function has_item( $item_id ) {
689
-        return false !== $this->get_item( $item_id );
688
+    public function has_item($item_id) {
689
+        return false !== $this->get_item($item_id);
690 690
 	}
691 691
 
692 692
 	/**
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
 	 * @since 1.0.19
696 696
 	 * @return bool
697 697
 	 */
698
-    public function has_element_type( $element_type ) {
699
-        return false !== $this->get_element_type( $element_type );
698
+    public function has_element_type($element_type) {
699
+        return false !== $this->get_element_type($element_type);
700 700
 	}
701 701
 
702 702
 	/**
@@ -707,13 +707,13 @@  discard block
 block discarded – undo
707 707
 	 */
708 708
     public function is_recurring() {
709 709
 
710
-		if ( ! empty( $this->invoice ) ) {
710
+		if (!empty($this->invoice)) {
711 711
 			return $this->invoice->is_recurring();
712 712
 		}
713 713
 
714
-		foreach ( $this->get_items() as $item ) {
714
+		foreach ($this->get_items() as $item) {
715 715
 
716
-			if ( $item->is_recurring() ) {
716
+			if ($item->is_recurring()) {
717 717
 				return true;
718 718
 			}
719 719
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
     public function get_html() {
731 731
 
732 732
 		// Return the HTML.
733
-		return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
733
+		return wpinv_get_template_html('payment-forms/form.php', array('form' => $this));
734 734
 
735 735
 	}
736 736
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-discount.php 2 patches
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -12,189 +12,189 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Discount {
14 14
 
15
-	/**
16
-	 * Submission discounts.
17
-	 * @var array
18
-	 */
19
-	public $discounts = array();
15
+    /**
16
+     * Submission discounts.
17
+     * @var array
18
+     */
19
+    public $discounts = array();
20
+
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     * @param float                           $initial_total
26
+     * @param float                           $recurring_total
27
+     */
28
+    public function __construct( $submission, $initial_total, $recurring_total ) {
29
+
30
+        // Process any existing invoice discounts.
31
+        if ( $submission->has_invoice() ) {
32
+            $this->discounts = $submission->get_invoice()->get_discounts();
33
+        }
34
+
35
+        // Do we have a discount?
36
+        $discount = $submission->get_field( 'discount' );
37
+
38
+        if ( empty( $discount ) ) {
39
+
40
+            if ( isset( $this->discounts['discount_code'] ) ) {
41
+                unset( $this->discounts['discount_code'] );
42
+            }
43
+
44
+            return;
45
+        }
46
+
47
+        // Processes the discount code.
48
+        $amount = max( $initial_total, $recurring_total );
49
+        $this->process_discount( $submission, $discount, $amount );
50
+
51
+    }
20 52
 
21 53
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 * @param float                           $initial_total
26
-	 * @param float                           $recurring_total
27
-	 */
28
-	public function __construct( $submission, $initial_total, $recurring_total ) {
29
-
30
-		// Process any existing invoice discounts.
31
-		if ( $submission->has_invoice() ) {
32
-			$this->discounts = $submission->get_invoice()->get_discounts();
33
-		}
34
-
35
-		// Do we have a discount?
36
-		$discount = $submission->get_field( 'discount' );
37
-
38
-		if ( empty( $discount ) ) {
39
-
40
-			if ( isset( $this->discounts['discount_code'] ) ) {
41
-				unset( $this->discounts['discount_code'] );
42
-			}
43
-
44
-			return;
45
-		}
46
-
47
-		// Processes the discount code.
48
-		$amount = max( $initial_total, $recurring_total );
49
-		$this->process_discount( $submission, $discount, $amount );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Processes a submission discount.
55
-	 *
56
-	 * @param GetPaid_Payment_Form_Submission $submission
57
-	 * @param string                          $discount
58
-	 * @param float                           $amount
59
-	 */
60
-	public function process_discount( $submission, $discount, $amount ) {
61
-
62
-		// Fetch the discount.
63
-		$discount = new WPInv_Discount( $discount );
64
-
65
-		// Ensure it is active.
54
+     * Processes a submission discount.
55
+     *
56
+     * @param GetPaid_Payment_Form_Submission $submission
57
+     * @param string                          $discount
58
+     * @param float                           $amount
59
+     */
60
+    public function process_discount( $submission, $discount, $amount ) {
61
+
62
+        // Fetch the discount.
63
+        $discount = new WPInv_Discount( $discount );
64
+
65
+        // Ensure it is active.
66 66
         if ( ! $this->is_discount_active( $discount ) ) {
67
-			throw new Exception( __( 'Invalid or expired discount code', 'invoicing' ) );
68
-		}
69
-
70
-		// Exceeded limit.
71
-		if ( $discount->has_exceeded_limit() ) {
72
-			throw new Exception( __( 'This discount code has been used up', 'invoicing' ) );
73
-		}
74
-
75
-		// Validate usages.
76
-		$this->validate_single_use_discount( $submission, $discount );
77
-
78
-		// Validate amount.
79
-		$this->validate_discount_amount( $submission, $discount, $amount );
80
-
81
-		// Save the discount.
82
-		$this->discounts['discount_code'] = $this->calculate_discount( $submission, $discount );
83
-	}
84
-
85
-	/**
86
-	 * Validates a single use discount.
87
-	 *
88
-	 * @param WPInv_Discount                  $discount
89
-	 * @return bool
90
-	 */
91
-	public function is_discount_active(  $discount ) {
92
-		return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
93
-	}
94
-
95
-	/**
96
-	 * Returns a user's id or email.
97
-	 *
98
-	 * @param string $email
99
-	 * @return int|string|false
100
-	 */
101
-	public function get_user_id_or_email( $email ) {
102
-
103
-		if ( is_user_logged_in() ) {
104
-			return get_current_user_id();
105
-		}
106
-
107
-		return empty( $email ) ? false : sanitize_email( $email );
108
-	}
109
-
110
-	/**
111
-	 * Validates a single use discount.
112
-	 *
113
-	 * @param GetPaid_Payment_Form_Submission $submission
114
-	 * @param WPInv_Discount                  $discount
115
-	 */
116
-	public function validate_single_use_discount( $submission, $discount ) {
117
-
118
-		// Abort if it is not a single use discount.
119
-		if ( ! $discount->is_single_use() ) {
120
-			return;
121
-		}
122
-
123
-		// Ensure there is a valid billing email.
124
-		$user = $this->get_user_id_or_email( $submission->get_billing_email() );
125
-
126
-		if ( empty( $user ) ) {
127
-			throw new Exception( __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
128
-		}
129
-
130
-		// Has the user used this discount code before?
131
-		if ( ! $discount->is_valid_for_user( $user ) ) {
132
-			throw new Exception( __( 'You have already used this discount', 'invoicing' ) );
133
-		}
134
-
135
-	}
136
-
137
-	/**
138
-	 * Validates the discount's amount.
139
-	 *
140
-	 * @param GetPaid_Payment_Form_Submission $submission
141
-	 * @param WPInv_Discount         $discount
142
-	 * @param float                  $amount
143
-	 */
144
-	public function validate_discount_amount( $submission, $discount, $amount ) {
145
-
146
-		// Validate minimum amount.
147
-		if ( ! $discount->is_minimum_amount_met( $amount ) ) {
148
-			$min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
149
-			throw new Exception( sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
150
-		}
151
-
152
-		// Validate the maximum amount.
153
-		if ( ! $discount->is_maximum_amount_met( $amount ) ) {
154
-			$max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
155
-			throw new Exception( sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
156
-		}
157
-
158
-	}
159
-
160
-	/**
161
-	 * Calculates the discount code's amount.
162
-	 *
163
-	 * Ensure that the discount exists and has been validated before calling this method.
164
-	 *
165
-	 * @param GetPaid_Payment_Form_Submission $submission
166
-	 * @param WPInv_Discount                  $discount
167
-	 * @return array
168
-	 */
169
-	public function calculate_discount( $submission, $discount ) {
170
-
171
-		$initial_discount   = 0;
172
-		$recurring_discount = 0;
173
-
174
-		foreach ( $submission->get_items() as $item ) {
175
-
176
-			// Abort if it is not valid for this item.
177
-			if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) {
178
-				continue;
179
-			}
180
-
181
-			// Calculate the initial amount...
182
-			$initial_discount += $discount->get_discounted_amount( $item->get_sub_total() );
183
-
184
-			// ... and maybe the recurring amount.
185
-			if ( $item->is_recurring() && $discount->is_recurring() ) {
186
-				$recurring_discount += $discount->get_discounted_amount( $item->get_recurring_sub_total() );
187
-			}
188
-
189
-		}
190
-
191
-		return array(
192
-			'name'               => 'discount_code',
193
-			'discount_code'      => $discount->get_code(),
194
-			'initial_discount'   => $initial_discount,
195
-			'recurring_discount' => $recurring_discount,
196
-		);
197
-
198
-	}
67
+            throw new Exception( __( 'Invalid or expired discount code', 'invoicing' ) );
68
+        }
69
+
70
+        // Exceeded limit.
71
+        if ( $discount->has_exceeded_limit() ) {
72
+            throw new Exception( __( 'This discount code has been used up', 'invoicing' ) );
73
+        }
74
+
75
+        // Validate usages.
76
+        $this->validate_single_use_discount( $submission, $discount );
77
+
78
+        // Validate amount.
79
+        $this->validate_discount_amount( $submission, $discount, $amount );
80
+
81
+        // Save the discount.
82
+        $this->discounts['discount_code'] = $this->calculate_discount( $submission, $discount );
83
+    }
84
+
85
+    /**
86
+     * Validates a single use discount.
87
+     *
88
+     * @param WPInv_Discount                  $discount
89
+     * @return bool
90
+     */
91
+    public function is_discount_active(  $discount ) {
92
+        return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
93
+    }
94
+
95
+    /**
96
+     * Returns a user's id or email.
97
+     *
98
+     * @param string $email
99
+     * @return int|string|false
100
+     */
101
+    public function get_user_id_or_email( $email ) {
102
+
103
+        if ( is_user_logged_in() ) {
104
+            return get_current_user_id();
105
+        }
106
+
107
+        return empty( $email ) ? false : sanitize_email( $email );
108
+    }
109
+
110
+    /**
111
+     * Validates a single use discount.
112
+     *
113
+     * @param GetPaid_Payment_Form_Submission $submission
114
+     * @param WPInv_Discount                  $discount
115
+     */
116
+    public function validate_single_use_discount( $submission, $discount ) {
117
+
118
+        // Abort if it is not a single use discount.
119
+        if ( ! $discount->is_single_use() ) {
120
+            return;
121
+        }
122
+
123
+        // Ensure there is a valid billing email.
124
+        $user = $this->get_user_id_or_email( $submission->get_billing_email() );
125
+
126
+        if ( empty( $user ) ) {
127
+            throw new Exception( __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
128
+        }
129
+
130
+        // Has the user used this discount code before?
131
+        if ( ! $discount->is_valid_for_user( $user ) ) {
132
+            throw new Exception( __( 'You have already used this discount', 'invoicing' ) );
133
+        }
134
+
135
+    }
136
+
137
+    /**
138
+     * Validates the discount's amount.
139
+     *
140
+     * @param GetPaid_Payment_Form_Submission $submission
141
+     * @param WPInv_Discount         $discount
142
+     * @param float                  $amount
143
+     */
144
+    public function validate_discount_amount( $submission, $discount, $amount ) {
145
+
146
+        // Validate minimum amount.
147
+        if ( ! $discount->is_minimum_amount_met( $amount ) ) {
148
+            $min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
149
+            throw new Exception( sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
150
+        }
151
+
152
+        // Validate the maximum amount.
153
+        if ( ! $discount->is_maximum_amount_met( $amount ) ) {
154
+            $max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
155
+            throw new Exception( sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
156
+        }
157
+
158
+    }
159
+
160
+    /**
161
+     * Calculates the discount code's amount.
162
+     *
163
+     * Ensure that the discount exists and has been validated before calling this method.
164
+     *
165
+     * @param GetPaid_Payment_Form_Submission $submission
166
+     * @param WPInv_Discount                  $discount
167
+     * @return array
168
+     */
169
+    public function calculate_discount( $submission, $discount ) {
170
+
171
+        $initial_discount   = 0;
172
+        $recurring_discount = 0;
173
+
174
+        foreach ( $submission->get_items() as $item ) {
175
+
176
+            // Abort if it is not valid for this item.
177
+            if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) {
178
+                continue;
179
+            }
180
+
181
+            // Calculate the initial amount...
182
+            $initial_discount += $discount->get_discounted_amount( $item->get_sub_total() );
183
+
184
+            // ... and maybe the recurring amount.
185
+            if ( $item->is_recurring() && $discount->is_recurring() ) {
186
+                $recurring_discount += $discount->get_discounted_amount( $item->get_recurring_sub_total() );
187
+            }
188
+
189
+        }
190
+
191
+        return array(
192
+            'name'               => 'discount_code',
193
+            'discount_code'      => $discount->get_code(),
194
+            'initial_discount'   => $initial_discount,
195
+            'recurring_discount' => $recurring_discount,
196
+        );
197
+
198
+    }
199 199
 
200 200
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission discount class
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
 	 * @param float                           $initial_total
26 26
 	 * @param float                           $recurring_total
27 27
 	 */
28
-	public function __construct( $submission, $initial_total, $recurring_total ) {
28
+	public function __construct($submission, $initial_total, $recurring_total) {
29 29
 
30 30
 		// Process any existing invoice discounts.
31
-		if ( $submission->has_invoice() ) {
31
+		if ($submission->has_invoice()) {
32 32
 			$this->discounts = $submission->get_invoice()->get_discounts();
33 33
 		}
34 34
 
35 35
 		// Do we have a discount?
36
-		$discount = $submission->get_field( 'discount' );
36
+		$discount = $submission->get_field('discount');
37 37
 
38
-		if ( empty( $discount ) ) {
38
+		if (empty($discount)) {
39 39
 
40
-			if ( isset( $this->discounts['discount_code'] ) ) {
41
-				unset( $this->discounts['discount_code'] );
40
+			if (isset($this->discounts['discount_code'])) {
41
+				unset($this->discounts['discount_code']);
42 42
 			}
43 43
 
44 44
 			return;
45 45
 		}
46 46
 
47 47
 		// Processes the discount code.
48
-		$amount = max( $initial_total, $recurring_total );
49
-		$this->process_discount( $submission, $discount, $amount );
48
+		$amount = max($initial_total, $recurring_total);
49
+		$this->process_discount($submission, $discount, $amount);
50 50
 
51 51
 	}
52 52
 
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
 	 * @param string                          $discount
58 58
 	 * @param float                           $amount
59 59
 	 */
60
-	public function process_discount( $submission, $discount, $amount ) {
60
+	public function process_discount($submission, $discount, $amount) {
61 61
 
62 62
 		// Fetch the discount.
63
-		$discount = new WPInv_Discount( $discount );
63
+		$discount = new WPInv_Discount($discount);
64 64
 
65 65
 		// Ensure it is active.
66
-        if ( ! $this->is_discount_active( $discount ) ) {
67
-			throw new Exception( __( 'Invalid or expired discount code', 'invoicing' ) );
66
+        if (!$this->is_discount_active($discount)) {
67
+			throw new Exception(__('Invalid or expired discount code', 'invoicing'));
68 68
 		}
69 69
 
70 70
 		// Exceeded limit.
71
-		if ( $discount->has_exceeded_limit() ) {
72
-			throw new Exception( __( 'This discount code has been used up', 'invoicing' ) );
71
+		if ($discount->has_exceeded_limit()) {
72
+			throw new Exception(__('This discount code has been used up', 'invoicing'));
73 73
 		}
74 74
 
75 75
 		// Validate usages.
76
-		$this->validate_single_use_discount( $submission, $discount );
76
+		$this->validate_single_use_discount($submission, $discount);
77 77
 
78 78
 		// Validate amount.
79
-		$this->validate_discount_amount( $submission, $discount, $amount );
79
+		$this->validate_discount_amount($submission, $discount, $amount);
80 80
 
81 81
 		// Save the discount.
82
-		$this->discounts['discount_code'] = $this->calculate_discount( $submission, $discount );
82
+		$this->discounts['discount_code'] = $this->calculate_discount($submission, $discount);
83 83
 	}
84 84
 
85 85
 	/**
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 * @param WPInv_Discount                  $discount
89 89
 	 * @return bool
90 90
 	 */
91
-	public function is_discount_active(  $discount ) {
92
-		return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
91
+	public function is_discount_active($discount) {
92
+		return $discount->exists() && $discount->is_active() && $discount->has_started() && !$discount->is_expired();
93 93
 	}
94 94
 
95 95
 	/**
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 	 * @param string $email
99 99
 	 * @return int|string|false
100 100
 	 */
101
-	public function get_user_id_or_email( $email ) {
101
+	public function get_user_id_or_email($email) {
102 102
 
103
-		if ( is_user_logged_in() ) {
103
+		if (is_user_logged_in()) {
104 104
 			return get_current_user_id();
105 105
 		}
106 106
 
107
-		return empty( $email ) ? false : sanitize_email( $email );
107
+		return empty($email) ? false : sanitize_email($email);
108 108
 	}
109 109
 
110 110
 	/**
@@ -113,23 +113,23 @@  discard block
 block discarded – undo
113 113
 	 * @param GetPaid_Payment_Form_Submission $submission
114 114
 	 * @param WPInv_Discount                  $discount
115 115
 	 */
116
-	public function validate_single_use_discount( $submission, $discount ) {
116
+	public function validate_single_use_discount($submission, $discount) {
117 117
 
118 118
 		// Abort if it is not a single use discount.
119
-		if ( ! $discount->is_single_use() ) {
119
+		if (!$discount->is_single_use()) {
120 120
 			return;
121 121
 		}
122 122
 
123 123
 		// Ensure there is a valid billing email.
124
-		$user = $this->get_user_id_or_email( $submission->get_billing_email() );
124
+		$user = $this->get_user_id_or_email($submission->get_billing_email());
125 125
 
126
-		if ( empty( $user ) ) {
127
-			throw new Exception( __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
126
+		if (empty($user)) {
127
+			throw new Exception(__('You need to either log in or enter your billing email before applying this discount', 'invoicing'));
128 128
 		}
129 129
 
130 130
 		// Has the user used this discount code before?
131
-		if ( ! $discount->is_valid_for_user( $user ) ) {
132
-			throw new Exception( __( 'You have already used this discount', 'invoicing' ) );
131
+		if (!$discount->is_valid_for_user($user)) {
132
+			throw new Exception(__('You have already used this discount', 'invoicing'));
133 133
 		}
134 134
 
135 135
 	}
@@ -141,18 +141,18 @@  discard block
 block discarded – undo
141 141
 	 * @param WPInv_Discount         $discount
142 142
 	 * @param float                  $amount
143 143
 	 */
144
-	public function validate_discount_amount( $submission, $discount, $amount ) {
144
+	public function validate_discount_amount($submission, $discount, $amount) {
145 145
 
146 146
 		// Validate minimum amount.
147
-		if ( ! $discount->is_minimum_amount_met( $amount ) ) {
148
-			$min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
149
-			throw new Exception( sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
147
+		if (!$discount->is_minimum_amount_met($amount)) {
148
+			$min = wpinv_price($discount->get_minimum_total(), $submission->get_currency());
149
+			throw new Exception(sprintf(__('The minimum total for using this discount is %s', 'invoicing'), $min));
150 150
 		}
151 151
 
152 152
 		// Validate the maximum amount.
153
-		if ( ! $discount->is_maximum_amount_met( $amount ) ) {
154
-			$max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
155
-			throw new Exception( sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
153
+		if (!$discount->is_maximum_amount_met($amount)) {
154
+			$max = wpinv_price($discount->get_maximum_total(), $submission->get_currency());
155
+			throw new Exception(sprintf(__('The maximum total for using this discount is %s', 'invoicing'), $max));
156 156
 		}
157 157
 
158 158
 	}
@@ -166,24 +166,24 @@  discard block
 block discarded – undo
166 166
 	 * @param WPInv_Discount                  $discount
167 167
 	 * @return array
168 168
 	 */
169
-	public function calculate_discount( $submission, $discount ) {
169
+	public function calculate_discount($submission, $discount) {
170 170
 
171 171
 		$initial_discount   = 0;
172 172
 		$recurring_discount = 0;
173 173
 
174
-		foreach ( $submission->get_items() as $item ) {
174
+		foreach ($submission->get_items() as $item) {
175 175
 
176 176
 			// Abort if it is not valid for this item.
177
-			if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) {
177
+			if (!$discount->is_valid_for_items(array($item->get_id()))) {
178 178
 				continue;
179 179
 			}
180 180
 
181 181
 			// Calculate the initial amount...
182
-			$initial_discount += $discount->get_discounted_amount( $item->get_sub_total() );
182
+			$initial_discount += $discount->get_discounted_amount($item->get_sub_total());
183 183
 
184 184
 			// ... and maybe the recurring amount.
185
-			if ( $item->is_recurring() && $discount->is_recurring() ) {
186
-				$recurring_discount += $discount->get_discounted_amount( $item->get_recurring_sub_total() );
185
+			if ($item->is_recurring() && $discount->is_recurring()) {
186
+				$recurring_discount += $discount->get_discounted_amount($item->get_recurring_sub_total());
187 187
 			}
188 188
 
189 189
 		}
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/alert.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Alert Text', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Alert Text', 'invoicing'); ?></span>
17 17
         <textarea v-model='active_form_element.text' class='form-control' rows='3'></textarea>
18 18
     </label>
19 19
 </div>
20 20
 
21 21
 <div class='form-group form-check'>
22 22
     <input :id="active_form_element.id + '_edit_dismissible'" v-model='active_form_element.dismissible' type='checkbox' class='form-check-input' />
23
-    <label class='form-check-label' :for="active_form_element.id + '_edit_dismissible'"><?php esc_html_e( 'Is Dismissible?', 'invoicing' ); ?></label>
23
+    <label class='form-check-label' :for="active_form_element.id + '_edit_dismissible'"><?php esc_html_e('Is Dismissible?', 'invoicing'); ?></label>
24 24
 </div>
25 25
 
26 26
 <div class='form-group'>
27
-    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e( 'Alert Type', 'invoicing' ) ?></label>
27
+    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e('Alert Type', 'invoicing') ?></label>
28 28
     <select class='form-control custom-select' :id="active_form_element.id + '_edit_type'" v-model='active_form_element.class'>
29
-        <option value='alert-primary'><?php esc_html_e( 'Primary', 'invoicing' ); ?></option>
30
-        <option value='alert-secondary'><?php esc_html_e( 'Secondary', 'invoicing' ); ?></option>
31
-        <option value='alert-success'><?php esc_html_e( 'Success', 'invoicing' ); ?></option>
32
-        <option value='alert-danger'><?php esc_html_e( 'Danger', 'invoicing' ); ?></option>
33
-        <option value='alert-warning'><?php esc_html_e( 'Warning', 'invoicing' ); ?></option>
34
-        <option value='alert-info'><?php esc_html_e( 'Info', 'invoicing' ); ?></option>
35
-        <option value='alert-light'><?php esc_html_e( 'Light', 'invoicing' ); ?></option>
36
-        <option value='alert-dark'><?php esc_html_e( 'Dark', 'invoicing' ); ?></option>
37
-        <option value='alert-link'><?php esc_html_e( 'Link', 'invoicing' ); ?></option>
29
+        <option value='alert-primary'><?php esc_html_e('Primary', 'invoicing'); ?></option>
30
+        <option value='alert-secondary'><?php esc_html_e('Secondary', 'invoicing'); ?></option>
31
+        <option value='alert-success'><?php esc_html_e('Success', 'invoicing'); ?></option>
32
+        <option value='alert-danger'><?php esc_html_e('Danger', 'invoicing'); ?></option>
33
+        <option value='alert-warning'><?php esc_html_e('Warning', 'invoicing'); ?></option>
34
+        <option value='alert-info'><?php esc_html_e('Info', 'invoicing'); ?></option>
35
+        <option value='alert-light'><?php esc_html_e('Light', 'invoicing'); ?></option>
36
+        <option value='alert-dark'><?php esc_html_e('Dark', 'invoicing'); ?></option>
37
+        <option value='alert-link'><?php esc_html_e('Link', 'invoicing'); ?></option>
38 38
     </select>
39 39
 </div>
Please login to merge, or discard this patch.