Passed
Push — master ( c6d0db...756836 )
by Brian
04:55 queued 28s
created
includes/payments/class-getpaid-payment-form-submission-items.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -12,79 +12,79 @@
 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();
20
-
21 15
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$data         = $submission->get_data();
29
-		$payment_form = $submission->get_payment_form();
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
-		}
36
-
37
-		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
-		}
16
+     * Submission items.
17
+     * @var GetPaid_Form_Item[]
18
+     */
19
+    public $items = array();
42 20
 
43
-		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items );
46
-		}
47
-
48
-	}
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $data         = $submission->get_data();
29
+        $payment_form = $submission->get_payment_form();
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
+        }
36
+
37
+        // For default forms, ensure that an item has been set.
38
+        if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
+            $form_items = wpinv_clean( $data['getpaid-form-items'] );
40
+            $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
+        }
42
+
43
+        // Process each individual item.
44
+        foreach ( $payment_form->get_items() as $item ) {
45
+            $this->process_item( $item, $selected_items );
46
+        }
47
+
48
+    }
49 49
 
50
-	/**
51
-	 * Process a single item.
52
-	 *
53
-	 * @param GetPaid_Form_Item $item
54
-	 * @param array $selected_items
55
-	 */
56
-	public function process_item( $item, $selected_items ) {
50
+    /**
51
+     * Process a single item.
52
+     *
53
+     * @param GetPaid_Form_Item $item
54
+     * @param array $selected_items
55
+     */
56
+    public function process_item( $item, $selected_items ) {
57 57
 
58
-		// Abort if this is an optional item and it has not been selected.
59
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
60
-			return;
61
-		}
58
+        // Abort if this is an optional item and it has not been selected.
59
+        if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
60
+            return;
61
+        }
62 62
 
63
-		// (maybe) let customers change the quantities and prices.
64
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
63
+        // (maybe) let customers change the quantities and prices.
64
+        if ( isset( $selected_items[ $item->get_id() ] ) ) {
65 65
 
66
-			// Maybe change the quantities.
67
-			if ( $item->allows_quantities() ) {
68
-				$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
69
-			}
66
+            // Maybe change the quantities.
67
+            if ( $item->allows_quantities() ) {
68
+                $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
69
+            }
70 70
 
71
-			// Maybe change the price.
72
-			if ( $item->user_can_set_their_price() ) {
73
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
71
+            // Maybe change the price.
72
+            if ( $item->user_can_set_their_price() ) {
73
+                $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
74 74
 
75
-				if ( $item->get_minimum_price() > $price ) {
76
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
77
-				}
75
+                if ( $item->get_minimum_price() > $price ) {
76
+                    throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
77
+                }
78 78
 
79
-				$item->set_price( $price );
79
+                $item->set_price( $price );
80 80
 
81
-			}
81
+            }
82 82
 
83
-		}
83
+        }
84 84
 
85
-		// Save the item.
86
-		$this->items[] = $item;
85
+        // Save the item.
86
+        $this->items[] = $item;
87 87
 
88
-	}
88
+    }
89 89
 
90 90
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 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,26 +23,26 @@  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() && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
38
+		if ($payment_form->is_default() && !$submission->has_invoice() && isset($data['getpaid-form-items'])) {
39
+			$form_items = wpinv_clean($data['getpaid-form-items']);
40
+			$payment_form->set_items(getpaid_convert_items_to_array($form_items));
41 41
 		}
42 42
 
43 43
 		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items );
44
+		foreach ($payment_form->get_items() as $item) {
45
+			$this->process_item($item, $selected_items);
46 46
 		}
47 47
 
48 48
 	}
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
 	 * @param GetPaid_Form_Item $item
54 54
 	 * @param array $selected_items
55 55
 	 */
56
-	public function process_item( $item, $selected_items ) {
56
+	public function process_item($item, $selected_items) {
57 57
 
58 58
 		// Abort if this is an optional item and it has not been selected.
59
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
59
+		if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
60 60
 			return;
61 61
 		}
62 62
 
63 63
 		// (maybe) let customers change the quantities and prices.
64
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
64
+		if (isset($selected_items[$item->get_id()])) {
65 65
 
66 66
 			// Maybe change the quantities.
67
-			if ( $item->allows_quantities() ) {
68
-				$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
67
+			if ($item->allows_quantities()) {
68
+				$item->set_quantity((int) $selected_items[$item->get_id()]['quantity']);
69 69
 			}
70 70
 
71 71
 			// Maybe change the price.
72
-			if ( $item->user_can_set_their_price() ) {
73
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
72
+			if ($item->user_can_set_their_price()) {
73
+				$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
74 74
 
75
-				if ( $item->get_minimum_price() > $price ) {
76
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
75
+				if ($item->get_minimum_price() > $price) {
76
+					throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), wpinv_sanitize_amount($item->get_minimum_price())));
77 77
 				}
78 78
 
79
-				$item->set_price( $price );
79
+				$item->set_price($price);
80 80
 
81 81
 			}
82 82
 
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,80 +7,80 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-do_action( 'getpaid_before_payment_form_cart_item', $form, $item );
12
+do_action('getpaid_before_payment_form_cart_item', $form, $item);
13 13
 
14 14
 $currency = $form->get_currency();
15 15
 
16 16
 ?>
17
-<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required'  : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'>
17
+<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'>
18 18
     <div class="form-row">
19
-        <?php foreach ( $columns as $key => $label ) : ?>
20
-            <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>-<?php echo $item->get_id(); ?>">
19
+        <?php foreach ($columns as $key => $label) : ?>
20
+            <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>-<?php echo $item->get_id(); ?>">
21 21
                 <?php
22 22
 
23 23
                     // Item name.
24
-                    if ( 'name' == $key ) {
25
-                        echo sanitize_text_field( $item->get_name() );
24
+                    if ('name' == $key) {
25
+                        echo sanitize_text_field($item->get_name());
26 26
                         $description = $item->get_description();
27 27
 
28
-                        if ( ! empty( $description ) ) {
29
-                            $description = wp_kses_post( $description );
28
+                        if (!empty($description)) {
29
+                            $description = wp_kses_post($description);
30 30
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
31 31
                         }
32 32
 
33
-                        $description = getpaid_item_recurring_price_help_text( $item, $currency );
33
+                        $description = getpaid_item_recurring_price_help_text($item, $currency);
34 34
 
35
-                        if ( $description ) {
35
+                        if ($description) {
36 36
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
37 37
                         }
38 38
                     }
39 39
 
40 40
                     // Item price.
41
-                    if ( 'price' == $key ) {
41
+                    if ('price' == $key) {
42 42
 
43 43
                         // Set the currency position.
44 44
                         $position = wpinv_currency_position();
45 45
 
46
-                        if ( $position == 'left_space' ) {
46
+                        if ($position == 'left_space') {
47 47
                             $position = 'left';
48 48
                         }
49 49
 
50
-                        if ( $position == 'right_space' ) {
50
+                        if ($position == 'right_space') {
51 51
                             $position = 'right';
52 52
                         }
53 53
 
54
-                        if ( $item->user_can_set_their_price() ) {
55
-                            $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
54
+                        if ($item->user_can_set_their_price()) {
55
+                            $price = max((float) $item->get_price(), (float) $item->get_minimum_price());
56 56
                             ?>
57 57
                                 <div class="input-group input-group-sm">
58
-                                    <?php if( 'left' == $position ) : ?>
58
+                                    <?php if ('left' == $position) : ?>
59 59
                                         <div class="input-group-prepend">
60
-                                            <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
60
+                                            <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
61 61
                                         </div>
62 62
                                     <?php endif; ?>
63
-                                    <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input">
63
+                                    <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input">
64 64
 
65
-                                    <?php if( 'left' != $position ) : ?>
65
+                                    <?php if ('left' != $position) : ?>
66 66
                                         <div class="input-group-append">
67
-                                            <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
67
+                                            <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
68 68
                                         </div>
69 69
                                     <?php endif; ?>
70 70
                                 </div>
71 71
                             <?php
72 72
                         } else {
73
-                            echo wpinv_price( wpinv_format_amount( $item->get_price() ), $currency );
73
+                            echo wpinv_price(wpinv_format_amount($item->get_price()), $currency);
74 74
                             ?>
75
-                                <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
75
+                                <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'>
76 76
                             <?php
77 77
                         }
78 78
                     }
79 79
 
80 80
                     // Item quantity.
81
-                    if ( 'quantity' == $key ) {
81
+                    if ('quantity' == $key) {
82 82
 
83
-                        if ( $item->allows_quantities() ) {
83
+                        if ($item->allows_quantities()) {
84 84
                             ?>
85 85
                                 <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='number' class='getpaid-item-quantity-input pr-1' value='<?php echo (int) $item->get_qantity(); ?>' min='1' required>
86 86
                             <?php
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
                     }
95 95
 
96 96
                     // Item sub total.
97
-                    if ( 'subtotal' == $key ) {
98
-                        echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $currency );
97
+                    if ('subtotal' == $key) {
98
+                        echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $currency);
99 99
                     }
100 100
 
101
-                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
101
+                    do_action("getpaid_payment_form_cart_item_$key", $item, $form);
102 102
                 ?>
103 103
             </div>
104 104
         <?php endforeach; ?>
105 105
     </div>
106 106
 </div>
107 107
 <?php
108
-do_action(  'getpaid_payment_form_cart_item', $form, $item );
108
+do_action('getpaid_payment_form_cart_item', $form, $item);
Please login to merge, or discard this patch.