@@ -993,8 +993,8 @@ |
||
993 | 993 | aui_flip_color_scheme_on_scroll(); |
994 | 994 | |
995 | 995 | <?php |
996 | - // FSE tweaks. |
|
997 | - if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?> |
|
996 | + // FSE tweaks. |
|
997 | + if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?> |
|
998 | 998 | function aui_fse_set_data_scroll() { |
999 | 999 | console.log('init scroll'); |
1000 | 1000 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -26,71 +26,71 @@ discard block |
||
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | - // Fires before printing a line item column. |
|
30 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
29 | + // Fires before printing a line item column. |
|
30 | + do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
31 | 31 | |
32 | - // Item name. |
|
33 | - if ( 'name' === $key ) { |
|
32 | + // Item name. |
|
33 | + if ( 'name' === $key ) { |
|
34 | 34 | |
35 | 35 | |
36 | - ob_start(); |
|
36 | + ob_start(); |
|
37 | 37 | |
38 | - // Add an optional description. |
|
39 | - $description = $item->get_description(); |
|
38 | + // Add an optional description. |
|
39 | + $description = $item->get_description(); |
|
40 | 40 | |
41 | - if ( ! empty( $description ) ) { |
|
42 | - echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
43 | - } |
|
41 | + if ( ! empty( $description ) ) { |
|
42 | + echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
43 | + } |
|
44 | 44 | |
45 | - // Price help text. |
|
46 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
47 | - if ( $description ) { |
|
48 | - echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
49 | - } |
|
45 | + // Price help text. |
|
46 | + $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
47 | + if ( $description ) { |
|
48 | + echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
49 | + } |
|
50 | 50 | |
51 | - do_action( 'getpaid_payment_form_cart_item_description', $item, $form ); |
|
51 | + do_action( 'getpaid_payment_form_cart_item_description', $item, $form ); |
|
52 | 52 | |
53 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
53 | + if ( wpinv_current_user_can_manage_invoicing() ) { |
|
54 | 54 | |
55 | - edit_post_link( |
|
56 | - __( 'Edit this item.', 'invoicing' ), |
|
57 | - '<small class="form-text text-muted">', |
|
58 | - '</small>', |
|
59 | - $item->get_id(), |
|
60 | - 'text-danger' |
|
61 | - ); |
|
55 | + edit_post_link( |
|
56 | + __( 'Edit this item.', 'invoicing' ), |
|
57 | + '<small class="form-text text-muted">', |
|
58 | + '</small>', |
|
59 | + $item->get_id(), |
|
60 | + 'text-danger' |
|
61 | + ); |
|
62 | 62 | |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - $description = ob_get_clean(); |
|
65 | + $description = ob_get_clean(); |
|
66 | 66 | |
67 | - // Display the name. |
|
68 | - $tootip = empty( $description ) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
67 | + // Display the name. |
|
68 | + $tootip = empty( $description ) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
69 | 69 | |
70 | - $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
70 | + $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
71 | 71 | |
72 | - if ( $has_featured_image ) { |
|
73 | - echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
|
74 | - echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
75 | - echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
76 | - echo '</div>'; |
|
77 | - echo '<div class="getpaid-form-item-name-container">'; |
|
78 | - } |
|
72 | + if ( $has_featured_image ) { |
|
73 | + echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
|
74 | + echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
75 | + echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
76 | + echo '</div>'; |
|
77 | + echo '<div class="getpaid-form-item-name-container">'; |
|
78 | + } |
|
79 | 79 | |
80 | - echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>'; |
|
80 | + echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>'; |
|
81 | 81 | |
82 | - if ( ! empty( $description ) ) { |
|
83 | - printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) ); |
|
84 | - } |
|
82 | + if ( ! empty( $description ) ) { |
|
83 | + printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) ); |
|
84 | + } |
|
85 | 85 | |
86 | - if ( $item->allows_quantities() ) { |
|
87 | - printf( |
|
88 | - '<small class="d-sm-none text-muted form-text">%s</small>', |
|
89 | - sprintf( |
|
90 | - // translators: %s is the item quantity. |
|
91 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
92 | - sprintf( |
|
93 | - '<input |
|
86 | + if ( $item->allows_quantities() ) { |
|
87 | + printf( |
|
88 | + '<small class="d-sm-none text-muted form-text">%s</small>', |
|
89 | + sprintf( |
|
90 | + // translators: %s is the item quantity. |
|
91 | + esc_html__( 'Qty %s', 'invoicing' ), |
|
92 | + sprintf( |
|
93 | + '<input |
|
94 | 94 | type="number" |
95 | 95 | step="0.01" |
96 | 96 | style="width: 48px;" |
@@ -99,62 +99,62 @@ discard block |
||
99 | 99 | min="1" |
100 | 100 | max="%s" |
101 | 101 | >', |
102 | - (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(), |
|
103 | - floatval( null !== $max_qty ? $max_qty : 1000000000000 ) |
|
104 | - ) |
|
105 | - ) |
|
106 | - ); |
|
107 | - } else { |
|
108 | - printf( |
|
109 | - '<small class="d-sm-none text-muted form-text">%s</small>', |
|
110 | - sprintf( |
|
111 | - // translators: %s is the item quantity. |
|
112 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
113 | - (float) $item->get_quantity() |
|
114 | - ) |
|
115 | - ); |
|
116 | - } |
|
117 | - |
|
118 | - if ( $has_featured_image ) { |
|
119 | - echo '</div>'; |
|
120 | - echo '</div>'; |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - // Item price. |
|
125 | - if ( 'price' === $key ) { |
|
126 | - |
|
127 | - // Set the currency position. |
|
128 | - $position = wpinv_currency_position(); |
|
129 | - |
|
130 | - if ( 'left_space' === $position ) { |
|
131 | - $position = 'left'; |
|
132 | - } |
|
133 | - |
|
134 | - if ( 'right_space' === $position ) { |
|
135 | - $position = 'right'; |
|
136 | - } |
|
137 | - |
|
138 | - if ( $item->user_can_set_their_price() ) { |
|
139 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
140 | - $minimum = (float) $item->get_minimum_price(); |
|
141 | - $validate_minimum = ''; |
|
142 | - $class = ''; |
|
143 | - $data_minimum = ''; |
|
144 | - |
|
145 | - if ( $minimum > 0 ) { |
|
146 | - $validate_minimum = sprintf( |
|
147 | - // translators: %s is the minimum price. |
|
148 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
149 | - wp_strip_all_tags( wpinv_price( $minimum, $currency ) ) |
|
150 | - ); |
|
151 | - |
|
152 | - $class = 'getpaid-validate-minimum-amount'; |
|
153 | - |
|
154 | - $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
155 | - } |
|
156 | - |
|
157 | - ?> |
|
102 | + (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(), |
|
103 | + floatval( null !== $max_qty ? $max_qty : 1000000000000 ) |
|
104 | + ) |
|
105 | + ) |
|
106 | + ); |
|
107 | + } else { |
|
108 | + printf( |
|
109 | + '<small class="d-sm-none text-muted form-text">%s</small>', |
|
110 | + sprintf( |
|
111 | + // translators: %s is the item quantity. |
|
112 | + esc_html__( 'Qty %s', 'invoicing' ), |
|
113 | + (float) $item->get_quantity() |
|
114 | + ) |
|
115 | + ); |
|
116 | + } |
|
117 | + |
|
118 | + if ( $has_featured_image ) { |
|
119 | + echo '</div>'; |
|
120 | + echo '</div>'; |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + // Item price. |
|
125 | + if ( 'price' === $key ) { |
|
126 | + |
|
127 | + // Set the currency position. |
|
128 | + $position = wpinv_currency_position(); |
|
129 | + |
|
130 | + if ( 'left_space' === $position ) { |
|
131 | + $position = 'left'; |
|
132 | + } |
|
133 | + |
|
134 | + if ( 'right_space' === $position ) { |
|
135 | + $position = 'right'; |
|
136 | + } |
|
137 | + |
|
138 | + if ( $item->user_can_set_their_price() ) { |
|
139 | + $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
140 | + $minimum = (float) $item->get_minimum_price(); |
|
141 | + $validate_minimum = ''; |
|
142 | + $class = ''; |
|
143 | + $data_minimum = ''; |
|
144 | + |
|
145 | + if ( $minimum > 0 ) { |
|
146 | + $validate_minimum = sprintf( |
|
147 | + // translators: %s is the minimum price. |
|
148 | + esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
149 | + wp_strip_all_tags( wpinv_price( $minimum, $currency ) ) |
|
150 | + ); |
|
151 | + |
|
152 | + $class = 'getpaid-validate-minimum-amount'; |
|
153 | + |
|
154 | + $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
155 | + } |
|
156 | + |
|
157 | + ?> |
|
158 | 158 | <div class="input-group input-group-sm"> |
159 | 159 | <?php if ( 'left' === $position ) : ?> |
160 | 160 | <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
@@ -195,46 +195,46 @@ discard block |
||
195 | 195 | |
196 | 196 | <?php |
197 | 197 | |
198 | - } else { |
|
199 | - ?> |
|
198 | + } else { |
|
199 | + ?> |
|
200 | 200 | <span class="getpaid-items-<?php echo (int) $item->get_id(); ?>-view-price"> |
201 | 201 | <?php echo wp_kses_post( wpinv_price( $item->get_price(), $currency ) ); ?> |
202 | 202 | </span> |
203 | 203 | <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() ); ?>'> |
204 | 204 | <?php |
205 | - } |
|
205 | + } |
|
206 | 206 | |
207 | - printf( |
|
207 | + printf( |
|
208 | 208 | '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>', |
209 | - // translators: %s is the item subtotal. |
|
209 | + // translators: %s is the item subtotal. |
|
210 | 210 | sprintf( esc_html__( 'Subtotal: %s', 'invoicing' ), wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ) ) |
211 | 211 | ); |
212 | - } |
|
212 | + } |
|
213 | 213 | |
214 | - // Item quantity. |
|
215 | - if ( 'quantity' === $key ) { |
|
214 | + // Item quantity. |
|
215 | + if ( 'quantity' === $key ) { |
|
216 | 216 | |
217 | - if ( $item->allows_quantities() ) { |
|
218 | - ?> |
|
217 | + if ( $item->allows_quantities() ) { |
|
218 | + ?> |
|
219 | 219 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type="number" step="any" style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' <?php echo null !== $max_qty ? 'max="' . (float) $max_qty . '"' : ''; ?> required> |
220 | 220 | <?php |
221 | - } else { |
|
222 | - ?> |
|
221 | + } else { |
|
222 | + ?> |
|
223 | 223 | <span class="getpaid-items-<?php echo (int) $item->get_id(); ?>-view-quantity"> |
224 | 224 | <?php echo (float) $item->get_quantity(); ?> |
225 | 225 | </span> |
226 | 226 | <input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'> |
227 | 227 | <?php |
228 | - } |
|
228 | + } |
|
229 | 229 | } |
230 | 230 | |
231 | - // Item sub total. |
|
232 | - if ( 'subtotal' === $key ) { |
|
233 | - echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ); |
|
234 | - } |
|
231 | + // Item sub total. |
|
232 | + if ( 'subtotal' === $key ) { |
|
233 | + echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ); |
|
234 | + } |
|
235 | 235 | |
236 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
237 | - ?> |
|
236 | + do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
237 | + ?> |
|
238 | 238 | |
239 | 239 | </div> |
240 | 240 |
@@ -12,51 +12,51 @@ discard block |
||
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 ) { |
|
27 | - |
|
28 | - $data = $submission->get_data(); |
|
29 | - $payment_form = $submission->get_payment_form(); |
|
30 | - $invoice = $submission->get_invoice(); |
|
31 | - $force_prices = array(); |
|
32 | - |
|
33 | - // Prepare the selected items. |
|
34 | - $selected_items = array(); |
|
35 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
36 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
37 | - |
|
38 | - if ( ! empty( $invoice ) && $submission->is_initial_fetch() ) { |
|
39 | - foreach ( $invoice->get_items() as $invoice_item ) { |
|
40 | - if ( isset( $selected_items[ $invoice_item->get_id() ] ) ) { |
|
41 | - $selected_items[ $invoice_item->get_id() ]['quantity'] = $invoice_item->get_quantity(); |
|
42 | - $selected_items[ $invoice_item->get_id() ]['price'] = $invoice_item->get_price(); |
|
43 | - |
|
44 | - $force_prices[ $invoice_item->get_id() ] = $invoice_item->get_price(); |
|
45 | - } |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
49 | - |
|
50 | - // (Maybe) set form items. |
|
51 | - if ( isset( $data['getpaid-form-items'] ) ) { |
|
52 | - |
|
53 | - // Confirm items key. |
|
54 | - $form_items = wpinv_clean( $data['getpaid-form-items'] ); |
|
55 | - if ( ! isset( $data['getpaid-form-items-key'] ) || md5( NONCE_KEY . AUTH_KEY . $form_items ) !== $data['getpaid-form-items-key'] ) { |
|
56 | - throw new Exception( __( 'We could not validate the form items. Please reload the page and try again.', 'invoicing' ) ); |
|
57 | - } |
|
58 | - |
|
59 | - $items = array(); |
|
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 | + $invoice = $submission->get_invoice(); |
|
31 | + $force_prices = array(); |
|
32 | + |
|
33 | + // Prepare the selected items. |
|
34 | + $selected_items = array(); |
|
35 | + if ( ! empty( $data['getpaid-items'] ) ) { |
|
36 | + $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
37 | + |
|
38 | + if ( ! empty( $invoice ) && $submission->is_initial_fetch() ) { |
|
39 | + foreach ( $invoice->get_items() as $invoice_item ) { |
|
40 | + if ( isset( $selected_items[ $invoice_item->get_id() ] ) ) { |
|
41 | + $selected_items[ $invoice_item->get_id() ]['quantity'] = $invoice_item->get_quantity(); |
|
42 | + $selected_items[ $invoice_item->get_id() ]['price'] = $invoice_item->get_price(); |
|
43 | + |
|
44 | + $force_prices[ $invoice_item->get_id() ] = $invoice_item->get_price(); |
|
45 | + } |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | + |
|
50 | + // (Maybe) set form items. |
|
51 | + if ( isset( $data['getpaid-form-items'] ) ) { |
|
52 | + |
|
53 | + // Confirm items key. |
|
54 | + $form_items = wpinv_clean( $data['getpaid-form-items'] ); |
|
55 | + if ( ! isset( $data['getpaid-form-items-key'] ) || md5( NONCE_KEY . AUTH_KEY . $form_items ) !== $data['getpaid-form-items-key'] ) { |
|
56 | + throw new Exception( __( 'We could not validate the form items. Please reload the page and try again.', 'invoicing' ) ); |
|
57 | + } |
|
58 | + |
|
59 | + $items = array(); |
|
60 | 60 | $item_ids = array(); |
61 | 61 | |
62 | 62 | foreach ( getpaid_convert_items_to_array( $form_items ) as $item_id => $qty ) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | $item->set_is_required( false ); |
70 | 70 | } |
71 | 71 | |
72 | - if ( ! $item->user_can_set_their_price() && isset( $force_prices[ $item_id ] ) ) { |
|
73 | - $item->set_is_dynamic_pricing( true ); |
|
74 | - $item->set_minimum_price( 0 ); |
|
75 | - } |
|
72 | + if ( ! $item->user_can_set_their_price() && isset( $force_prices[ $item_id ] ) ) { |
|
73 | + $item->set_is_dynamic_pricing( true ); |
|
74 | + $item->set_minimum_price( 0 ); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | $item_ids[] = $item->get_id(); |
78 | 78 | $items[] = $item; |
@@ -87,61 +87,61 @@ discard block |
||
87 | 87 | $items[] = $item; |
88 | 88 | } |
89 | 89 | } |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | $payment_form->set_items( $items ); |
93 | 93 | |
94 | - } |
|
95 | - |
|
96 | - // Process each individual item. |
|
97 | - foreach ( $payment_form->get_items() as $item ) { |
|
98 | - $this->process_item( $item, $selected_items, $submission ); |
|
99 | - } |
|
100 | - |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Process a single item. |
|
105 | - * |
|
106 | - * @param GetPaid_Form_Item $item |
|
107 | - * @param array $selected_items |
|
108 | - * @param GetPaid_Payment_Form_Submission $submission |
|
109 | - */ |
|
110 | - public function process_item( $item, $selected_items, $submission ) { |
|
94 | + } |
|
111 | 95 | |
112 | - // Abort if this is an optional item and it has not been selected. |
|
113 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
114 | - return; |
|
115 | - } |
|
96 | + // Process each individual item. |
|
97 | + foreach ( $payment_form->get_items() as $item ) { |
|
98 | + $this->process_item( $item, $selected_items, $submission ); |
|
99 | + } |
|
116 | 100 | |
117 | - // (maybe) let customers change the quantities and prices. |
|
118 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
101 | + } |
|
119 | 102 | |
120 | - // Maybe change the quantities. |
|
121 | - if ( $item->allows_quantities() ) { |
|
122 | - $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] ); |
|
123 | - } |
|
103 | + /** |
|
104 | + * Process a single item. |
|
105 | + * |
|
106 | + * @param GetPaid_Form_Item $item |
|
107 | + * @param array $selected_items |
|
108 | + * @param GetPaid_Payment_Form_Submission $submission |
|
109 | + */ |
|
110 | + public function process_item( $item, $selected_items, $submission ) { |
|
111 | + |
|
112 | + // Abort if this is an optional item and it has not been selected. |
|
113 | + if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
114 | + return; |
|
115 | + } |
|
116 | + |
|
117 | + // (maybe) let customers change the quantities and prices. |
|
118 | + if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
119 | + |
|
120 | + // Maybe change the quantities. |
|
121 | + if ( $item->allows_quantities() ) { |
|
122 | + $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] ); |
|
123 | + } |
|
124 | 124 | |
125 | - // Maybe change the price. |
|
126 | - if ( $item->user_can_set_their_price() ) { |
|
127 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
125 | + // Maybe change the price. |
|
126 | + if ( $item->user_can_set_their_price() ) { |
|
127 | + $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
128 | 128 | |
129 | - if ( $item->get_minimum_price() > $price ) { |
|
130 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) ); |
|
131 | - } |
|
129 | + if ( $item->get_minimum_price() > $price ) { |
|
130 | + throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) ); |
|
131 | + } |
|
132 | 132 | |
133 | - $item->set_price( $price ); |
|
133 | + $item->set_price( $price ); |
|
134 | 134 | |
135 | - } |
|
136 | - } |
|
135 | + } |
|
136 | + } |
|
137 | 137 | |
138 | - if ( 0 == $item->get_quantity() ) { |
|
139 | - return; |
|
140 | - } |
|
138 | + if ( 0 == $item->get_quantity() ) { |
|
139 | + return; |
|
140 | + } |
|
141 | 141 | |
142 | - // Save the item. |
|
143 | - $this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item', $item, $submission ); |
|
142 | + // Save the item. |
|
143 | + $this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item', $item, $submission ); |
|
144 | 144 | |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | 147 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,67 +10,67 @@ discard block |
||
10 | 10 | class GetPaid_Form_Item extends WPInv_Item { |
11 | 11 | |
12 | 12 | /** |
13 | - * Stores a custom description for the item. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $custom_description = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * Stores the item quantity. |
|
21 | - * |
|
22 | - * @var float |
|
23 | - */ |
|
24 | - protected $quantity = 1; |
|
25 | - |
|
26 | - /** |
|
27 | - * Stores the item meta. |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - protected $meta = array(); |
|
32 | - |
|
33 | - /** |
|
34 | - * Is this item required? |
|
35 | - * |
|
36 | - * @var int |
|
37 | - */ |
|
38 | - protected $is_required = true; |
|
39 | - |
|
40 | - /** |
|
41 | - * Are quantities allowed? |
|
42 | - * |
|
43 | - * @var int |
|
44 | - */ |
|
45 | - protected $allow_quantities = false; |
|
46 | - |
|
47 | - /** |
|
48 | - * Associated invoice. |
|
49 | - * |
|
50 | - * @var int |
|
51 | - */ |
|
52 | - public $invoice_id = 0; |
|
53 | - |
|
54 | - /** |
|
55 | - * Item discount. |
|
56 | - * |
|
57 | - * @var float |
|
58 | - */ |
|
59 | - public $item_discount = 0; |
|
60 | - |
|
61 | - /** |
|
62 | - * Recurring item discount. |
|
63 | - * |
|
64 | - * @var float |
|
65 | - */ |
|
66 | - public $recurring_item_discount = 0; |
|
67 | - |
|
68 | - /** |
|
69 | - * Item tax. |
|
70 | - * |
|
71 | - * @var float |
|
72 | - */ |
|
73 | - public $item_tax = 0; |
|
13 | + * Stores a custom description for the item. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $custom_description = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * Stores the item quantity. |
|
21 | + * |
|
22 | + * @var float |
|
23 | + */ |
|
24 | + protected $quantity = 1; |
|
25 | + |
|
26 | + /** |
|
27 | + * Stores the item meta. |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + protected $meta = array(); |
|
32 | + |
|
33 | + /** |
|
34 | + * Is this item required? |
|
35 | + * |
|
36 | + * @var int |
|
37 | + */ |
|
38 | + protected $is_required = true; |
|
39 | + |
|
40 | + /** |
|
41 | + * Are quantities allowed? |
|
42 | + * |
|
43 | + * @var int |
|
44 | + */ |
|
45 | + protected $allow_quantities = false; |
|
46 | + |
|
47 | + /** |
|
48 | + * Associated invoice. |
|
49 | + * |
|
50 | + * @var int |
|
51 | + */ |
|
52 | + public $invoice_id = 0; |
|
53 | + |
|
54 | + /** |
|
55 | + * Item discount. |
|
56 | + * |
|
57 | + * @var float |
|
58 | + */ |
|
59 | + public $item_discount = 0; |
|
60 | + |
|
61 | + /** |
|
62 | + * Recurring item discount. |
|
63 | + * |
|
64 | + * @var float |
|
65 | + */ |
|
66 | + public $recurring_item_discount = 0; |
|
67 | + |
|
68 | + /** |
|
69 | + * Item tax. |
|
70 | + * |
|
71 | + * @var float |
|
72 | + */ |
|
73 | + public $item_tax = 0; |
|
74 | 74 | |
75 | 75 | /* |
76 | 76 | |-------------------------------------------------------------------------- |
@@ -88,230 +88,230 @@ discard block |
||
88 | 88 | */ |
89 | 89 | |
90 | 90 | /** |
91 | - * Get the item name. |
|
92 | - * |
|
93 | - * @since 1.0.19 |
|
94 | - * @param string $context View or edit context. |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function get_name( $context = 'view' ) { |
|
98 | - $name = parent::get_name( $context ); |
|
99 | - return $name . wpinv_get_item_suffix( $this ); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Get the item name without a suffix. |
|
104 | - * |
|
105 | - * @since 1.0.19 |
|
106 | - * @param string $context View or edit context. |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function get_raw_name( $context = 'view' ) { |
|
110 | - return parent::get_name( $context ); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Get the item description. |
|
115 | - * |
|
116 | - * @since 1.0.19 |
|
117 | - * @param string $context View or edit context. |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function get_description( $context = 'view' ) { |
|
121 | - |
|
122 | - if ( isset( $this->custom_description ) ) { |
|
123 | - return $this->custom_description; |
|
124 | - } |
|
125 | - |
|
126 | - return parent::get_description( $context ); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Returns the sub total. |
|
131 | - * |
|
132 | - * @since 1.0.19 |
|
133 | - * @param string $context View or edit context. |
|
134 | - * @return float |
|
135 | - */ |
|
136 | - public function get_sub_total( $context = 'view' ) { |
|
137 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Returns the recurring sub total. |
|
142 | - * |
|
143 | - * @since 1.0.19 |
|
144 | - * @param string $context View or edit context. |
|
145 | - * @return float |
|
146 | - */ |
|
147 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
148 | - |
|
149 | - if ( $this->is_recurring() ) { |
|
150 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
151 | - } |
|
152 | - |
|
153 | - return 0; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @deprecated |
|
158 | - */ |
|
159 | - public function get_qantity( $context = 'view' ) { |
|
160 | - return $this->get_quantity( $context ); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Get the item quantity. |
|
165 | - * |
|
166 | - * @since 1.0.19 |
|
167 | - * @param string $context View or edit context. |
|
168 | - * @return float |
|
169 | - */ |
|
170 | - public function get_quantity( $context = 'view' ) { |
|
171 | - $quantity = (float) $this->quantity; |
|
172 | - |
|
173 | - if ( 'view' === $context ) { |
|
174 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
175 | - } |
|
176 | - |
|
177 | - return $quantity; |
|
178 | - |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Get the item meta data. |
|
183 | - * |
|
184 | - * @since 1.0.19 |
|
185 | - * @param string $context View or edit context. |
|
186 | - * @return meta |
|
187 | - */ |
|
188 | - public function get_item_meta( $context = 'view' ) { |
|
189 | - $meta = $this->meta; |
|
190 | - |
|
191 | - if ( 'view' === $context ) { |
|
192 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
193 | - } |
|
194 | - |
|
195 | - return $meta; |
|
196 | - |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns whether or not customers can update the item quantity. |
|
201 | - * |
|
202 | - * @since 1.0.19 |
|
203 | - * @param string $context View or edit context. |
|
204 | - * @return bool |
|
205 | - */ |
|
206 | - public function get_allow_quantities( $context = 'view' ) { |
|
207 | - $allow_quantities = (bool) $this->allow_quantities; |
|
208 | - |
|
209 | - if ( 'view' === $context ) { |
|
210 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
211 | - } |
|
212 | - |
|
213 | - return $allow_quantities; |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Returns whether or not the item is required. |
|
219 | - * |
|
220 | - * @since 1.0.19 |
|
221 | - * @param string $context View or edit context. |
|
222 | - * @return bool |
|
223 | - */ |
|
224 | - public function get_is_required( $context = 'view' ) { |
|
225 | - $is_required = (bool) $this->is_required; |
|
226 | - |
|
227 | - if ( 'view' === $context ) { |
|
228 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
229 | - } |
|
230 | - |
|
231 | - return $is_required; |
|
232 | - |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Prepares form data for use. |
|
237 | - * |
|
238 | - * @since 1.0.19 |
|
239 | - * @return array |
|
240 | - */ |
|
241 | - public function prepare_data_for_use( $required = null ) { |
|
242 | - |
|
243 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
244 | - return array( |
|
245 | - 'title' => wp_strip_all_tags( $this->get_name() ), |
|
246 | - 'id' => $this->get_id(), |
|
247 | - 'price' => $this->get_price(), |
|
248 | - 'recurring' => $this->is_recurring(), |
|
249 | - 'description' => $this->get_description(), |
|
250 | - 'allow_quantities' => $this->allows_quantities(), |
|
251 | - 'required' => $required, |
|
252 | - ); |
|
253 | - |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Prepares form data for ajax use. |
|
258 | - * |
|
259 | - * @since 1.0.19 |
|
260 | - * @return array |
|
261 | - */ |
|
262 | - public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) { |
|
263 | - |
|
264 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
265 | - |
|
266 | - if ( $description ) { |
|
267 | - $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
268 | - } |
|
269 | - |
|
270 | - $price = ! $is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
271 | - $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
272 | - return array( |
|
273 | - 'id' => $this->get_id(), |
|
274 | - 'texts' => array( |
|
275 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
276 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
277 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
278 | - 'item-price' => wpinv_price( $price, $currency ), |
|
279 | - 'item-total' => wpinv_price( $subtotal, $currency ), |
|
280 | - ), |
|
281 | - 'inputs' => array( |
|
282 | - 'item-id' => $this->get_id(), |
|
283 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
284 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
285 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
286 | - 'item-price' => $price, |
|
287 | - ), |
|
288 | - ); |
|
289 | - |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Prepares form data for saving (cart_details). |
|
294 | - * |
|
295 | - * @since 1.0.19 |
|
296 | - * @return array |
|
297 | - */ |
|
298 | - public function prepare_data_for_saving() { |
|
299 | - |
|
300 | - return array( |
|
301 | - 'post_id' => $this->invoice_id, |
|
302 | - 'item_id' => $this->get_id(), |
|
303 | - 'item_name' => sanitize_text_field( $this->get_raw_name( 'edit' ) ), |
|
304 | - 'item_description' => $this->get_description( 'edit' ), |
|
305 | - 'tax' => $this->item_tax, |
|
306 | - 'item_price' => $this->get_price( 'edit' ), |
|
307 | - 'quantity' => (float) $this->get_quantity( 'edit' ), |
|
308 | - 'discount' => $this->item_discount, |
|
309 | - 'subtotal' => $this->get_sub_total( 'edit' ), |
|
310 | - 'price' => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount, |
|
311 | - 'meta' => $this->get_item_meta( 'edit' ), |
|
312 | - ); |
|
313 | - |
|
314 | - } |
|
91 | + * Get the item name. |
|
92 | + * |
|
93 | + * @since 1.0.19 |
|
94 | + * @param string $context View or edit context. |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function get_name( $context = 'view' ) { |
|
98 | + $name = parent::get_name( $context ); |
|
99 | + return $name . wpinv_get_item_suffix( $this ); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Get the item name without a suffix. |
|
104 | + * |
|
105 | + * @since 1.0.19 |
|
106 | + * @param string $context View or edit context. |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function get_raw_name( $context = 'view' ) { |
|
110 | + return parent::get_name( $context ); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Get the item description. |
|
115 | + * |
|
116 | + * @since 1.0.19 |
|
117 | + * @param string $context View or edit context. |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function get_description( $context = 'view' ) { |
|
121 | + |
|
122 | + if ( isset( $this->custom_description ) ) { |
|
123 | + return $this->custom_description; |
|
124 | + } |
|
125 | + |
|
126 | + return parent::get_description( $context ); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Returns the sub total. |
|
131 | + * |
|
132 | + * @since 1.0.19 |
|
133 | + * @param string $context View or edit context. |
|
134 | + * @return float |
|
135 | + */ |
|
136 | + public function get_sub_total( $context = 'view' ) { |
|
137 | + return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Returns the recurring sub total. |
|
142 | + * |
|
143 | + * @since 1.0.19 |
|
144 | + * @param string $context View or edit context. |
|
145 | + * @return float |
|
146 | + */ |
|
147 | + public function get_recurring_sub_total( $context = 'view' ) { |
|
148 | + |
|
149 | + if ( $this->is_recurring() ) { |
|
150 | + return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
151 | + } |
|
152 | + |
|
153 | + return 0; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * @deprecated |
|
158 | + */ |
|
159 | + public function get_qantity( $context = 'view' ) { |
|
160 | + return $this->get_quantity( $context ); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Get the item quantity. |
|
165 | + * |
|
166 | + * @since 1.0.19 |
|
167 | + * @param string $context View or edit context. |
|
168 | + * @return float |
|
169 | + */ |
|
170 | + public function get_quantity( $context = 'view' ) { |
|
171 | + $quantity = (float) $this->quantity; |
|
172 | + |
|
173 | + if ( 'view' === $context ) { |
|
174 | + return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
175 | + } |
|
176 | + |
|
177 | + return $quantity; |
|
178 | + |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Get the item meta data. |
|
183 | + * |
|
184 | + * @since 1.0.19 |
|
185 | + * @param string $context View or edit context. |
|
186 | + * @return meta |
|
187 | + */ |
|
188 | + public function get_item_meta( $context = 'view' ) { |
|
189 | + $meta = $this->meta; |
|
190 | + |
|
191 | + if ( 'view' === $context ) { |
|
192 | + return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
193 | + } |
|
194 | + |
|
195 | + return $meta; |
|
196 | + |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns whether or not customers can update the item quantity. |
|
201 | + * |
|
202 | + * @since 1.0.19 |
|
203 | + * @param string $context View or edit context. |
|
204 | + * @return bool |
|
205 | + */ |
|
206 | + public function get_allow_quantities( $context = 'view' ) { |
|
207 | + $allow_quantities = (bool) $this->allow_quantities; |
|
208 | + |
|
209 | + if ( 'view' === $context ) { |
|
210 | + return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
211 | + } |
|
212 | + |
|
213 | + return $allow_quantities; |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Returns whether or not the item is required. |
|
219 | + * |
|
220 | + * @since 1.0.19 |
|
221 | + * @param string $context View or edit context. |
|
222 | + * @return bool |
|
223 | + */ |
|
224 | + public function get_is_required( $context = 'view' ) { |
|
225 | + $is_required = (bool) $this->is_required; |
|
226 | + |
|
227 | + if ( 'view' === $context ) { |
|
228 | + return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
229 | + } |
|
230 | + |
|
231 | + return $is_required; |
|
232 | + |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Prepares form data for use. |
|
237 | + * |
|
238 | + * @since 1.0.19 |
|
239 | + * @return array |
|
240 | + */ |
|
241 | + public function prepare_data_for_use( $required = null ) { |
|
242 | + |
|
243 | + $required = is_null( $required ) ? $this->is_required() : $required; |
|
244 | + return array( |
|
245 | + 'title' => wp_strip_all_tags( $this->get_name() ), |
|
246 | + 'id' => $this->get_id(), |
|
247 | + 'price' => $this->get_price(), |
|
248 | + 'recurring' => $this->is_recurring(), |
|
249 | + 'description' => $this->get_description(), |
|
250 | + 'allow_quantities' => $this->allows_quantities(), |
|
251 | + 'required' => $required, |
|
252 | + ); |
|
253 | + |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Prepares form data for ajax use. |
|
258 | + * |
|
259 | + * @since 1.0.19 |
|
260 | + * @return array |
|
261 | + */ |
|
262 | + public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) { |
|
263 | + |
|
264 | + $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
265 | + |
|
266 | + if ( $description ) { |
|
267 | + $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
268 | + } |
|
269 | + |
|
270 | + $price = ! $is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
271 | + $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
272 | + return array( |
|
273 | + 'id' => $this->get_id(), |
|
274 | + 'texts' => array( |
|
275 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
276 | + 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
277 | + 'item-quantity' => floatval( $this->get_quantity() ), |
|
278 | + 'item-price' => wpinv_price( $price, $currency ), |
|
279 | + 'item-total' => wpinv_price( $subtotal, $currency ), |
|
280 | + ), |
|
281 | + 'inputs' => array( |
|
282 | + 'item-id' => $this->get_id(), |
|
283 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
284 | + 'item-description' => wp_kses_post( $this->get_description() ), |
|
285 | + 'item-quantity' => floatval( $this->get_quantity() ), |
|
286 | + 'item-price' => $price, |
|
287 | + ), |
|
288 | + ); |
|
289 | + |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Prepares form data for saving (cart_details). |
|
294 | + * |
|
295 | + * @since 1.0.19 |
|
296 | + * @return array |
|
297 | + */ |
|
298 | + public function prepare_data_for_saving() { |
|
299 | + |
|
300 | + return array( |
|
301 | + 'post_id' => $this->invoice_id, |
|
302 | + 'item_id' => $this->get_id(), |
|
303 | + 'item_name' => sanitize_text_field( $this->get_raw_name( 'edit' ) ), |
|
304 | + 'item_description' => $this->get_description( 'edit' ), |
|
305 | + 'tax' => $this->item_tax, |
|
306 | + 'item_price' => $this->get_price( 'edit' ), |
|
307 | + 'quantity' => (float) $this->get_quantity( 'edit' ), |
|
308 | + 'discount' => $this->item_discount, |
|
309 | + 'subtotal' => $this->get_sub_total( 'edit' ), |
|
310 | + 'price' => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount, |
|
311 | + 'meta' => $this->get_item_meta( 'edit' ), |
|
312 | + ); |
|
313 | + |
|
314 | + } |
|
315 | 315 | |
316 | 316 | /* |
317 | 317 | |-------------------------------------------------------------------------- |
@@ -323,70 +323,70 @@ discard block |
||
323 | 323 | | object. |
324 | 324 | */ |
325 | 325 | |
326 | - /** |
|
327 | - * Set the item qantity. |
|
328 | - * |
|
329 | - * @since 1.0.19 |
|
330 | - * @param float $quantity The item quantity. |
|
331 | - */ |
|
332 | - public function set_quantity( $quantity ) { |
|
333 | - |
|
334 | - if ( ! is_numeric( $quantity ) ) { |
|
335 | - $quantity = 1; |
|
336 | - } |
|
337 | - |
|
338 | - $this->quantity = (float) $quantity; |
|
339 | - |
|
340 | - } |
|
341 | - |
|
342 | - /** |
|
343 | - * Set the item meta data. |
|
344 | - * |
|
345 | - * @since 1.0.19 |
|
346 | - * @param array $meta The item meta data. |
|
347 | - */ |
|
348 | - public function set_item_meta( $meta ) { |
|
349 | - $this->meta = maybe_unserialize( $meta ); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Set whether or not the quantities are allowed. |
|
354 | - * |
|
355 | - * @since 1.0.19 |
|
356 | - * @param bool $allow_quantities |
|
357 | - */ |
|
358 | - public function set_allow_quantities( $allow_quantities ) { |
|
359 | - $this->allow_quantities = (bool) $allow_quantities; |
|
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * Set whether or not the item is required. |
|
364 | - * |
|
365 | - * @since 1.0.19 |
|
366 | - * @param bool $is_required |
|
367 | - */ |
|
368 | - public function set_is_required( $is_required ) { |
|
369 | - $this->is_required = (bool) $is_required; |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * Sets the custom item description. |
|
374 | - * |
|
375 | - * @since 1.0.19 |
|
376 | - * @param string $description |
|
377 | - */ |
|
378 | - public function set_custom_description( $description ) { |
|
379 | - $this->custom_description = $description; |
|
380 | - } |
|
326 | + /** |
|
327 | + * Set the item qantity. |
|
328 | + * |
|
329 | + * @since 1.0.19 |
|
330 | + * @param float $quantity The item quantity. |
|
331 | + */ |
|
332 | + public function set_quantity( $quantity ) { |
|
333 | + |
|
334 | + if ( ! is_numeric( $quantity ) ) { |
|
335 | + $quantity = 1; |
|
336 | + } |
|
337 | + |
|
338 | + $this->quantity = (float) $quantity; |
|
339 | + |
|
340 | + } |
|
341 | + |
|
342 | + /** |
|
343 | + * Set the item meta data. |
|
344 | + * |
|
345 | + * @since 1.0.19 |
|
346 | + * @param array $meta The item meta data. |
|
347 | + */ |
|
348 | + public function set_item_meta( $meta ) { |
|
349 | + $this->meta = maybe_unserialize( $meta ); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Set whether or not the quantities are allowed. |
|
354 | + * |
|
355 | + * @since 1.0.19 |
|
356 | + * @param bool $allow_quantities |
|
357 | + */ |
|
358 | + public function set_allow_quantities( $allow_quantities ) { |
|
359 | + $this->allow_quantities = (bool) $allow_quantities; |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * Set whether or not the item is required. |
|
364 | + * |
|
365 | + * @since 1.0.19 |
|
366 | + * @param bool $is_required |
|
367 | + */ |
|
368 | + public function set_is_required( $is_required ) { |
|
369 | + $this->is_required = (bool) $is_required; |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * Sets the custom item description. |
|
374 | + * |
|
375 | + * @since 1.0.19 |
|
376 | + * @param string $description |
|
377 | + */ |
|
378 | + public function set_custom_description( $description ) { |
|
379 | + $this->custom_description = $description; |
|
380 | + } |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * We do not want to save items to the database. |
384 | 384 | * |
385 | - * @return int item id |
|
385 | + * @return int item id |
|
386 | 386 | */ |
387 | 387 | public function save( $data = array() ) { |
388 | 388 | return $this->get_id(); |
389 | - } |
|
389 | + } |
|
390 | 390 | |
391 | 391 | /* |
392 | 392 | |-------------------------------------------------------------------------- |
@@ -398,23 +398,23 @@ discard block |
||
398 | 398 | */ |
399 | 399 | |
400 | 400 | /** |
401 | - * Checks whether the item has enabled dynamic pricing. |
|
402 | - * |
|
403 | - * @since 1.0.19 |
|
404 | - * @return bool |
|
405 | - */ |
|
406 | - public function is_required() { |
|
401 | + * Checks whether the item has enabled dynamic pricing. |
|
402 | + * |
|
403 | + * @since 1.0.19 |
|
404 | + * @return bool |
|
405 | + */ |
|
406 | + public function is_required() { |
|
407 | 407 | return (bool) $this->get_is_required(); |
408 | - } |
|
409 | - |
|
410 | - /** |
|
411 | - * Checks whether users can edit the quantities. |
|
412 | - * |
|
413 | - * @since 1.0.19 |
|
414 | - * @return bool |
|
415 | - */ |
|
416 | - public function allows_quantities() { |
|
408 | + } |
|
409 | + |
|
410 | + /** |
|
411 | + * Checks whether users can edit the quantities. |
|
412 | + * |
|
413 | + * @since 1.0.19 |
|
414 | + * @return bool |
|
415 | + */ |
|
416 | + public function allows_quantities() { |
|
417 | 417 | return (bool) $this->get_allow_quantities(); |
418 | - } |
|
418 | + } |
|
419 | 419 | |
420 | 420 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | // And the optional invoice id. |
59 | 59 | if ( ! empty( $form->invoice ) ) { |
60 | - getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
60 | + getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // We also want to include the form id. |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | <?php |
77 | 77 | |
78 | 78 | foreach ( $form->get_elements() as $element ) { |
79 | - if ( isset( $element['type'] ) ) { |
|
79 | + if ( isset( $element['type'] ) ) { |
|
80 | 80 | $grid_class = getpaid_get_form_element_grid_class( $element ); |
81 | 81 | do_action( 'getpaid_payment_form_element_before', $element, $form ); |
82 | 82 | do_action( "getpaid_payment_form_element_before_{$element['type']}_template", $element, $form ); |
@@ -11,26 +11,26 @@ discard block |
||
11 | 11 | |
12 | 12 | // Totals rows. |
13 | 13 | $cart_totals = apply_filters( |
14 | - 'getpaid_payment_form_cart_table_totals', |
|
15 | - array( |
|
16 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
17 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
18 | - 'fees' => __( 'Fee', 'invoicing' ), |
|
19 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
20 | - 'total' => __( 'Total', 'invoicing' ), |
|
21 | - ), |
|
22 | - $form |
|
14 | + 'getpaid_payment_form_cart_table_totals', |
|
15 | + array( |
|
16 | + 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
17 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
18 | + 'fees' => __( 'Fee', 'invoicing' ), |
|
19 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
20 | + 'total' => __( 'Total', 'invoicing' ), |
|
21 | + ), |
|
22 | + $form |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $currency = $form->get_currency(); |
26 | 26 | $country = wpinv_get_default_country(); |
27 | 27 | |
28 | 28 | if ( ! empty( $form->invoice ) ) { |
29 | - $country = $form->invoice->get_country(); |
|
29 | + $country = $form->invoice->get_country(); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if ( ! wpinv_use_taxes() && isset( $cart_totals['tax'] ) ) { |
33 | - unset( $cart_totals['tax'] ); |
|
33 | + unset( $cart_totals['tax'] ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | do_action( 'getpaid_before_payment_form_cart_totals', $form, $cart_totals ); |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | |
62 | 62 | <?php |
63 | 63 | |
64 | - // Total tax. |
|
65 | - if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ), true ) ) { |
|
66 | - wpinv_the_price( 0, $currency ); |
|
67 | - } |
|
64 | + // Total tax. |
|
65 | + if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ), true ) ) { |
|
66 | + wpinv_the_price( 0, $currency ); |
|
67 | + } |
|
68 | 68 | |
69 | - do_action( "getpaid_payment_form_cart_totals_$key", $form ); |
|
70 | - ?> |
|
69 | + do_action( "getpaid_payment_form_cart_totals_$key", $form ); |
|
70 | + ?> |
|
71 | 71 | |
72 | 72 | </div> |
73 | 73 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | defined( 'ABSPATH' ) || exit; |
11 | 11 | |
12 | 12 | if ( empty( $fields ) ) { |
13 | - return; |
|
13 | + return; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | |
19 | 19 | // Prepare the user's country. |
20 | 20 | if ( ! empty( $form->invoice ) ) { |
21 | - $country = $form->invoice->get_country(); |
|
21 | + $country = $form->invoice->get_country(); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | if ( empty( $country ) ) { |
25 | - $country = empty( $country ) ? getpaid_get_ip_country() : $country; |
|
26 | - $country = empty( $country ) ? wpinv_get_default_country() : $country; |
|
25 | + $country = empty( $country ) ? getpaid_get_ip_country() : $country; |
|
26 | + $country = empty( $country ) ? wpinv_get_default_country() : $country; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | <!-- Start Billing Address --> |
56 | 56 | <div class="getpaid-billing-address-wrapper"> |
57 | 57 | <?php |
58 | - $field_type = 'billing'; |
|
59 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
60 | - do_action( 'getpaid_after_payment_form_billing_fields', $form ); |
|
61 | - ?> |
|
58 | + $field_type = 'billing'; |
|
59 | + include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
60 | + do_action( 'getpaid_after_payment_form_billing_fields', $form ); |
|
61 | + ?> |
|
62 | 62 | </div> |
63 | 63 | <!-- End Billing Address --> |
64 | 64 | |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | |
71 | 71 | <?php |
72 | 72 | |
73 | - aui()->input( |
|
74 | - array( |
|
75 | - 'type' => 'checkbox', |
|
76 | - 'name' => 'same-shipping-address', |
|
77 | - 'id' => "shipping-toggle$uniqid", |
|
78 | - 'required' => false, |
|
79 | - 'label' => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ), |
|
80 | - 'value' => 1, |
|
81 | - 'checked' => true, |
|
82 | - 'class' => 'w-auto', |
|
83 | - ), |
|
84 | - true |
|
85 | - ); |
|
73 | + aui()->input( |
|
74 | + array( |
|
75 | + 'type' => 'checkbox', |
|
76 | + 'name' => 'same-shipping-address', |
|
77 | + 'id' => "shipping-toggle$uniqid", |
|
78 | + 'required' => false, |
|
79 | + 'label' => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ), |
|
80 | + 'value' => 1, |
|
81 | + 'checked' => true, |
|
82 | + 'class' => 'w-auto', |
|
83 | + ), |
|
84 | + true |
|
85 | + ); |
|
86 | 86 | |
87 | - ?> |
|
87 | + ?> |
|
88 | 88 | |
89 | 89 | |
90 | 90 | <!-- Start Shipping Address Title --> |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | <!-- Start Shipping Address --> |
104 | 104 | <div class="getpaid-shipping-address-wrapper"> |
105 | 105 | <?php |
106 | - $field_type = 'shipping'; |
|
107 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
108 | - do_action( 'getpaid_after_payment_form_shipping_fields', $form ); |
|
109 | - ?> |
|
106 | + $field_type = 'shipping'; |
|
107 | + include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
108 | + do_action( 'getpaid_after_payment_form_shipping_fields', $form ); |
|
109 | + ?> |
|
110 | 110 | </div> |
111 | 111 | <!-- End Shipping Address --> |
112 | 112 |
@@ -15,105 +15,105 @@ |
||
15 | 15 | */ |
16 | 16 | class GetPaid_Meta_Data implements JsonSerializable { |
17 | 17 | |
18 | - /** |
|
19 | - * Current data for metadata |
|
20 | - * |
|
21 | - * @since 1.0.19 |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $current_data; |
|
18 | + /** |
|
19 | + * Current data for metadata |
|
20 | + * |
|
21 | + * @since 1.0.19 |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $current_data; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Metadata data |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data; |
|
26 | + /** |
|
27 | + * Metadata data |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor. |
|
36 | - * |
|
37 | - * @param array $meta Data to wrap behind this function. |
|
38 | - */ |
|
39 | - public function __construct( $meta = array() ) { |
|
40 | - $this->current_data = $meta; |
|
41 | - $this->apply_changes(); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Constructor. |
|
36 | + * |
|
37 | + * @param array $meta Data to wrap behind this function. |
|
38 | + */ |
|
39 | + public function __construct( $meta = array() ) { |
|
40 | + $this->current_data = $meta; |
|
41 | + $this->apply_changes(); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * When converted to JSON. |
|
46 | - * |
|
47 | - * @return object|array |
|
48 | - */ |
|
49 | - #[\ReturnTypeWillChange] |
|
50 | - public function jsonSerialize() { |
|
51 | - return $this->get_data(); |
|
52 | - } |
|
44 | + /** |
|
45 | + * When converted to JSON. |
|
46 | + * |
|
47 | + * @return object|array |
|
48 | + */ |
|
49 | + #[\ReturnTypeWillChange] |
|
50 | + public function jsonSerialize() { |
|
51 | + return $this->get_data(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Merge changes with data and clear. |
|
56 | - */ |
|
57 | - public function apply_changes() { |
|
58 | - $this->data = $this->current_data; |
|
59 | - } |
|
54 | + /** |
|
55 | + * Merge changes with data and clear. |
|
56 | + */ |
|
57 | + public function apply_changes() { |
|
58 | + $this->data = $this->current_data; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Creates or updates a property in the metadata object. |
|
63 | - * |
|
64 | - * @param string $key Key to set. |
|
65 | - * @param mixed $value Value to set. |
|
66 | - */ |
|
67 | - public function __set( $key, $value ) { |
|
68 | - $this->current_data[ $key ] = $value; |
|
69 | - } |
|
61 | + /** |
|
62 | + * Creates or updates a property in the metadata object. |
|
63 | + * |
|
64 | + * @param string $key Key to set. |
|
65 | + * @param mixed $value Value to set. |
|
66 | + */ |
|
67 | + public function __set( $key, $value ) { |
|
68 | + $this->current_data[ $key ] = $value; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Checks if a given key exists in our data. This is called internally |
|
73 | - * by `empty` and `isset`. |
|
74 | - * |
|
75 | - * @param string $key Key to check if set. |
|
76 | - * |
|
77 | - * @return bool |
|
78 | - */ |
|
79 | - public function __isset( $key ) { |
|
80 | - return array_key_exists( $key, $this->current_data ); |
|
81 | - } |
|
71 | + /** |
|
72 | + * Checks if a given key exists in our data. This is called internally |
|
73 | + * by `empty` and `isset`. |
|
74 | + * |
|
75 | + * @param string $key Key to check if set. |
|
76 | + * |
|
77 | + * @return bool |
|
78 | + */ |
|
79 | + public function __isset( $key ) { |
|
80 | + return array_key_exists( $key, $this->current_data ); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Returns the value of any property. |
|
85 | - * |
|
86 | - * @param string $key Key to get. |
|
87 | - * @return mixed Property value or NULL if it does not exists |
|
88 | - */ |
|
89 | - public function __get( $key ) { |
|
90 | - if ( array_key_exists( $key, $this->current_data ) ) { |
|
91 | - return $this->current_data[ $key ]; |
|
92 | - } |
|
93 | - return null; |
|
94 | - } |
|
83 | + /** |
|
84 | + * Returns the value of any property. |
|
85 | + * |
|
86 | + * @param string $key Key to get. |
|
87 | + * @return mixed Property value or NULL if it does not exists |
|
88 | + */ |
|
89 | + public function __get( $key ) { |
|
90 | + if ( array_key_exists( $key, $this->current_data ) ) { |
|
91 | + return $this->current_data[ $key ]; |
|
92 | + } |
|
93 | + return null; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Return data changes only. |
|
98 | - * |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function get_changes() { |
|
102 | - $changes = array(); |
|
103 | - foreach ( $this->current_data as $id => $value ) { |
|
104 | - if ( ! array_key_exists( $id, $this->data ) || $value !== $this->data[ $id ] ) { |
|
105 | - $changes[ $id ] = $value; |
|
106 | - } |
|
107 | - } |
|
108 | - return $changes; |
|
109 | - } |
|
96 | + /** |
|
97 | + * Return data changes only. |
|
98 | + * |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function get_changes() { |
|
102 | + $changes = array(); |
|
103 | + foreach ( $this->current_data as $id => $value ) { |
|
104 | + if ( ! array_key_exists( $id, $this->data ) || $value !== $this->data[ $id ] ) { |
|
105 | + $changes[ $id ] = $value; |
|
106 | + } |
|
107 | + } |
|
108 | + return $changes; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Return all data as an array. |
|
113 | - * |
|
114 | - * @return array |
|
115 | - */ |
|
116 | - public function get_data() { |
|
117 | - return $this->data; |
|
118 | - } |
|
111 | + /** |
|
112 | + * Return all data as an array. |
|
113 | + * |
|
114 | + * @return array |
|
115 | + */ |
|
116 | + public function get_data() { |
|
117 | + return $this->data; |
|
118 | + } |
|
119 | 119 | } |
@@ -160,50 +160,50 @@ |
||
160 | 160 | */ |
161 | 161 | function getpaid_calculate_invoice_discount( $invoice, $discount ) { |
162 | 162 | |
163 | - $initial_discount = 0; |
|
164 | - $recurring_discount = 0; |
|
163 | + $initial_discount = 0; |
|
164 | + $recurring_discount = 0; |
|
165 | 165 | |
166 | - foreach ( $invoice->get_items() as $item ) { |
|
166 | + foreach ( $invoice->get_items() as $item ) { |
|
167 | 167 | |
168 | - // Abort if it is not valid for this item. |
|
169 | - if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
170 | - continue; |
|
171 | - } |
|
168 | + // Abort if it is not valid for this item. |
|
169 | + if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
170 | + continue; |
|
171 | + } |
|
172 | 172 | |
173 | - // Calculate the initial amount... |
|
174 | - $item_discount = $discount->get_discounted_amount( $item->get_sub_total() ); |
|
175 | - $recurring_item_discount = 0; |
|
173 | + // Calculate the initial amount... |
|
174 | + $item_discount = $discount->get_discounted_amount( $item->get_sub_total() ); |
|
175 | + $recurring_item_discount = 0; |
|
176 | 176 | |
177 | - // ... and maybe the recurring amount. |
|
178 | - if ( $item->is_recurring() && $discount->is_recurring() ) { |
|
179 | - $recurring_item_discount = $discount->get_discounted_amount( $item->get_recurring_sub_total() ); |
|
180 | - } |
|
177 | + // ... and maybe the recurring amount. |
|
178 | + if ( $item->is_recurring() && $discount->is_recurring() ) { |
|
179 | + $recurring_item_discount = $discount->get_discounted_amount( $item->get_recurring_sub_total() ); |
|
180 | + } |
|
181 | 181 | |
182 | - // Discount should not exceed discounted amount. |
|
183 | - if ( ! $discount->is_type( 'percent' ) ) { |
|
182 | + // Discount should not exceed discounted amount. |
|
183 | + if ( ! $discount->is_type( 'percent' ) ) { |
|
184 | 184 | |
185 | - if ( ( $initial_discount + $item_discount ) > $discount->get_amount() ) { |
|
186 | - $item_discount = $discount->get_amount() - $initial_discount; |
|
187 | - } |
|
185 | + if ( ( $initial_discount + $item_discount ) > $discount->get_amount() ) { |
|
186 | + $item_discount = $discount->get_amount() - $initial_discount; |
|
187 | + } |
|
188 | 188 | |
189 | - if ( ( $recurring_discount + $recurring_item_discount ) > $discount->get_amount() ) { |
|
190 | - $recurring_item_discount = $discount->get_amount() - $recurring_discount; |
|
191 | - } |
|
189 | + if ( ( $recurring_discount + $recurring_item_discount ) > $discount->get_amount() ) { |
|
190 | + $recurring_item_discount = $discount->get_amount() - $recurring_discount; |
|
191 | + } |
|
192 | 192 | } |
193 | 193 | |
194 | - $initial_discount += $item_discount; |
|
195 | - $recurring_discount += $recurring_item_discount; |
|
196 | - $item->item_discount = $item_discount; |
|
197 | - $item->recurring_item_discount = $recurring_item_discount; |
|
194 | + $initial_discount += $item_discount; |
|
195 | + $recurring_discount += $recurring_item_discount; |
|
196 | + $item->item_discount = $item_discount; |
|
197 | + $item->recurring_item_discount = $recurring_item_discount; |
|
198 | 198 | |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | - return array( |
|
202 | - 'name' => 'discount_code', |
|
203 | - 'discount_code' => $discount->get_code(), |
|
204 | - 'initial_discount' => $initial_discount, |
|
205 | - 'recurring_discount' => $recurring_discount, |
|
206 | - ); |
|
201 | + return array( |
|
202 | + 'name' => 'discount_code', |
|
203 | + 'discount_code' => $discount->get_code(), |
|
204 | + 'initial_discount' => $initial_discount, |
|
205 | + 'recurring_discount' => $recurring_discount, |
|
206 | + ); |
|
207 | 207 | |
208 | 208 | } |
209 | 209 |