@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | /** |
3 | 3 | * Displays a cart item in a payment form |
4 | 4 | * |
@@ -9,46 +9,46 @@ discard block |
||
9 | 9 | * @var GetPaid_Form_Item $item |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | + defined( 'ABSPATH' ) || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
14 | + do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
15 | 15 | |
16 | -$currency = $form->get_currency(); |
|
17 | -$max_qty = wpinv_item_max_buyable_quantity( $item->get_id() ); |
|
16 | + $currency = $form->get_currency(); |
|
17 | + $max_qty = wpinv_item_max_buyable_quantity( $item->get_id() ); |
|
18 | 18 | |
19 | -$has_variable_pricing = $item->has_variable_pricing(); |
|
20 | -$price_id = $has_variable_pricing ? $variable_price_id : $item->get_id(); |
|
19 | + $has_variable_pricing = $item->has_variable_pricing(); |
|
20 | + $price_id = $has_variable_pricing ? $variable_price_id : $item->get_id(); |
|
21 | 21 | |
22 | -// helper item to display subscription text. |
|
23 | -$helper_item = clone $item; |
|
24 | -$helper_item->set_id( 0 ); |
|
22 | + // helper item to display subscription text. |
|
23 | + $helper_item = clone $item; |
|
24 | + $helper_item->set_id( 0 ); |
|
25 | 25 | |
26 | -if ( $has_variable_pricing && (isset( $price['is-recurring'] ) && 'yes' === $price['is-recurring']) ) { |
|
27 | - $helper_item->set_price( $price['amount'] ); |
|
26 | + if ( $has_variable_pricing && (isset( $price['is-recurring'] ) && 'yes' === $price['is-recurring']) ) { |
|
27 | + $helper_item->set_price( $price['amount'] ); |
|
28 | 28 | |
29 | - if ( isset( $price['trial-interval'], $price['trial-period'] ) && $price['trial-interval'] > 0 ) { |
|
30 | - $trial_interval = (int) $price['trial-interval']; |
|
31 | - $trial_period = $price['trial-period']; |
|
29 | + if ( isset( $price['trial-interval'], $price['trial-period'] ) && $price['trial-interval'] > 0 ) { |
|
30 | + $trial_interval = (int) $price['trial-interval']; |
|
31 | + $trial_period = $price['trial-period']; |
|
32 | 32 | |
33 | - $helper_item->set_is_free_trial( 1 ); |
|
34 | - $helper_item->set_trial_interval( $trial_interval ); |
|
35 | - $helper_item->set_trial_period( $trial_period ); |
|
36 | - } |
|
33 | + $helper_item->set_is_free_trial( 1 ); |
|
34 | + $helper_item->set_trial_interval( $trial_interval ); |
|
35 | + $helper_item->set_trial_period( $trial_period ); |
|
36 | + } |
|
37 | 37 | |
38 | - if ( isset( $price['recurring-interval'], $price['recurring-period'] ) && $price['recurring-interval'] > 0 ) { |
|
39 | - $recurring_interval = (int) $price['recurring-interval']; |
|
40 | - $recurring_period = $price['recurring-period']; |
|
41 | - $recurring_limit = isset( $price['recurring-limit'] ) ? (int) $price['recurring-limit'] : 0; |
|
38 | + if ( isset( $price['recurring-interval'], $price['recurring-period'] ) && $price['recurring-interval'] > 0 ) { |
|
39 | + $recurring_interval = (int) $price['recurring-interval']; |
|
40 | + $recurring_period = $price['recurring-period']; |
|
41 | + $recurring_limit = isset( $price['recurring-limit'] ) ? (int) $price['recurring-limit'] : 0; |
|
42 | 42 | |
43 | - $helper_item->set_is_recurring( 1 ); |
|
44 | - $helper_item->set_recurring_interval( $recurring_interval ); |
|
45 | - $helper_item->set_recurring_period( $recurring_period ); |
|
46 | - $helper_item->set_recurring_limit( $recurring_limit ); |
|
47 | - } |
|
43 | + $helper_item->set_is_recurring( 1 ); |
|
44 | + $helper_item->set_recurring_interval( $recurring_interval ); |
|
45 | + $helper_item->set_recurring_period( $recurring_period ); |
|
46 | + $helper_item->set_recurring_limit( $recurring_limit ); |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | |
50 | -?> |
|
51 | -<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo (int) $price_id; ?> border-bottom py-2 px-3'> |
|
50 | + ?> |
|
51 | + <div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo (int) $price_id; ?> border-bottom py-2 px-3'> |
|
52 | 52 | |
53 | 53 | <div class="form-row row align-items-center needs-validation"> |
54 | 54 | |
@@ -58,87 +58,87 @@ discard block |
||
58 | 58 | |
59 | 59 | <?php |
60 | 60 | |
61 | - // Fires before printing a line item column. |
|
62 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
61 | + // Fires before printing a line item column. |
|
62 | + do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
63 | 63 | |
64 | - // Item name. |
|
65 | - if ( 'name' === $key ) { |
|
66 | - ob_start(); |
|
64 | + // Item name. |
|
65 | + if ( 'name' === $key ) { |
|
66 | + ob_start(); |
|
67 | 67 | |
68 | - // Add an optional description. |
|
69 | - $description = $item->get_description(); |
|
68 | + // Add an optional description. |
|
69 | + $description = $item->get_description(); |
|
70 | 70 | |
71 | - if ( ! empty( $description ) ) { |
|
72 | - echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
73 | - } |
|
71 | + if ( ! empty( $description ) ) { |
|
72 | + echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
73 | + } |
|
74 | 74 | |
75 | - // Price help text. |
|
76 | - $description = getpaid_item_recurring_price_help_text( $helper_item, $currency ); |
|
77 | - if ( $description ) { |
|
78 | - echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
79 | - } |
|
75 | + // Price help text. |
|
76 | + $description = getpaid_item_recurring_price_help_text( $helper_item, $currency ); |
|
77 | + if ( $description ) { |
|
78 | + echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
79 | + } |
|
80 | 80 | |
81 | - do_action( 'getpaid_payment_form_cart_item_description', $item, $form ); |
|
81 | + do_action( 'getpaid_payment_form_cart_item_description', $item, $form ); |
|
82 | 82 | |
83 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
83 | + if ( wpinv_current_user_can_manage_invoicing() ) { |
|
84 | 84 | |
85 | - edit_post_link( |
|
86 | - __( 'Edit this item.', 'invoicing' ), |
|
87 | - '<small class="form-text text-muted">', |
|
88 | - '</small>', |
|
89 | - $item->get_id(), |
|
90 | - 'text-danger' |
|
91 | - ); |
|
85 | + edit_post_link( |
|
86 | + __( 'Edit this item.', 'invoicing' ), |
|
87 | + '<small class="form-text text-muted">', |
|
88 | + '</small>', |
|
89 | + $item->get_id(), |
|
90 | + 'text-danger' |
|
91 | + ); |
|
92 | 92 | |
93 | - } |
|
93 | + } |
|
94 | 94 | |
95 | - $description = ob_get_clean(); |
|
95 | + $description = ob_get_clean(); |
|
96 | 96 | |
97 | - // Display the name. |
|
98 | - $tootip = empty( $description ) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
97 | + // Display the name. |
|
98 | + $tootip = empty( $description ) ? '' : ' <i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
99 | 99 | |
100 | - $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
100 | + $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
101 | 101 | |
102 | - if ( $has_featured_image || $has_variable_pricing ) { |
|
103 | - echo '<div class="d-flex align-items-center ' . ($has_featured_image ? 'getpaid-form-item-has-featured-image' : '') . '">'; |
|
102 | + if ( $has_featured_image || $has_variable_pricing ) { |
|
103 | + echo '<div class="d-flex align-items-center ' . ($has_featured_image ? 'getpaid-form-item-has-featured-image' : '') . '">'; |
|
104 | 104 | |
105 | - if ( $has_variable_pricing ) { |
|
106 | - echo '<input type="hidden" value="' . esc_attr( $price_id ) . '" name="getpaid-items[' . (int) $price_id . '][price_id]">'; |
|
107 | - echo '<input type="hidden" value="' . esc_attr( $item->get_id() ) . '" name="getpaid-items[' . (int) $price_id . '][item_id]">'; |
|
108 | - echo '<div class="mr-2">'; |
|
109 | - echo '<label class="form-label d-block w-100">'; |
|
110 | - echo '<input class="getpaid-refresh-on-change" type="' . (true === $item->is_multi_price_mode() ? 'checkbox' : 'radio') . '" value="' . esc_attr( $price_id ) . '" name="getpaid-variable-items[]" ' . ( $item->get_default_price_id() === (int) $price_id ? 'checked' : '') . '>'; |
|
111 | - echo '</label>'; |
|
112 | - echo '</div>'; |
|
113 | - } |
|
114 | - |
|
115 | - if ( $has_featured_image ) { |
|
116 | - echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
117 | - echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
118 | - echo '</div>'; |
|
105 | + if ( $has_variable_pricing ) { |
|
106 | + echo '<input type="hidden" value="' . esc_attr( $price_id ) . '" name="getpaid-items[' . (int) $price_id . '][price_id]">'; |
|
107 | + echo '<input type="hidden" value="' . esc_attr( $item->get_id() ) . '" name="getpaid-items[' . (int) $price_id . '][item_id]">'; |
|
108 | + echo '<div class="mr-2">'; |
|
109 | + echo '<label class="form-label d-block w-100">'; |
|
110 | + echo '<input class="getpaid-refresh-on-change" type="' . (true === $item->is_multi_price_mode() ? 'checkbox' : 'radio') . '" value="' . esc_attr( $price_id ) . '" name="getpaid-variable-items[]" ' . ( $item->get_default_price_id() === (int) $price_id ? 'checked' : '') . '>'; |
|
111 | + echo '</label>'; |
|
112 | + echo '</div>'; |
|
113 | + } |
|
114 | + |
|
115 | + if ( $has_featured_image ) { |
|
116 | + echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
117 | + echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
118 | + echo '</div>'; |
|
119 | + } |
|
120 | + |
|
121 | + echo '<div class="getpaid-form-item-name-container">'; |
|
122 | + } |
|
123 | + |
|
124 | + if ( $item->has_variable_pricing() ) { |
|
125 | + echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() . ' — ' . $price['name'] . ($helper_item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : '') ) . wp_kses_post( $tootip ) . '</div>'; |
|
126 | + } else { |
|
127 | + echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>'; |
|
119 | 128 | } |
120 | 129 | |
121 | - echo '<div class="getpaid-form-item-name-container">'; |
|
122 | - } |
|
123 | - |
|
124 | - if ( $item->has_variable_pricing() ) { |
|
125 | - echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() . ' — ' . $price['name'] . ($helper_item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : '') ) . wp_kses_post( $tootip ) . '</div>'; |
|
126 | - } else { |
|
127 | - echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>'; |
|
128 | - } |
|
129 | - |
|
130 | - if ( ! empty( $description ) ) { |
|
131 | - printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) ); |
|
132 | - } |
|
133 | - |
|
134 | - if ( $item->allows_quantities() ) { |
|
135 | - printf( |
|
136 | - '<small class="d-sm-none text-muted form-text">%s</small>', |
|
137 | - sprintf( |
|
138 | - // translators: %s is the item quantity. |
|
139 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
140 | - sprintf( |
|
141 | - '<input |
|
130 | + if ( ! empty( $description ) ) { |
|
131 | + printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) ); |
|
132 | + } |
|
133 | + |
|
134 | + if ( $item->allows_quantities() ) { |
|
135 | + printf( |
|
136 | + '<small class="d-sm-none text-muted form-text">%s</small>', |
|
137 | + sprintf( |
|
138 | + // translators: %s is the item quantity. |
|
139 | + esc_html__( 'Qty %s', 'invoicing' ), |
|
140 | + sprintf( |
|
141 | + '<input |
|
142 | 142 | type="number" |
143 | 143 | step="0.01" |
144 | 144 | style="width: 48px;" |
@@ -147,145 +147,145 @@ discard block |
||
147 | 147 | min="1" |
148 | 148 | max="%s" |
149 | 149 | >', |
150 | - (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(), |
|
151 | - floatval( null !== $max_qty ? $max_qty : 1000000000000 ) |
|
152 | - ) |
|
153 | - ) |
|
154 | - ); |
|
155 | - } else { |
|
156 | - printf( |
|
157 | - '<small class="d-sm-none text-muted form-text">%s</small>', |
|
158 | - sprintf( |
|
159 | - // translators: %s is the item quantity. |
|
160 | - esc_html__( 'Qty %s', 'invoicing' ), |
|
161 | - (float) $item->get_quantity() |
|
162 | - ) |
|
163 | - ); |
|
164 | - } |
|
165 | - |
|
166 | - if ( $has_featured_image || $has_variable_pricing ) { |
|
167 | - echo '</div>'; |
|
168 | - echo '</div>'; |
|
169 | - } |
|
170 | - } |
|
171 | - |
|
172 | - // Item price. |
|
173 | - if ( 'price' === $key ) { |
|
174 | - |
|
175 | - // Set the currency position. |
|
176 | - $position = wpinv_currency_position(); |
|
177 | - |
|
178 | - if ( 'left_space' === $position ) { |
|
179 | - $position = 'left'; |
|
180 | - } |
|
181 | - |
|
182 | - if ( 'right_space' === $position ) { |
|
183 | - $position = 'right'; |
|
150 | + (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(), |
|
151 | + floatval( null !== $max_qty ? $max_qty : 1000000000000 ) |
|
152 | + ) |
|
153 | + ) |
|
154 | + ); |
|
155 | + } else { |
|
156 | + printf( |
|
157 | + '<small class="d-sm-none text-muted form-text">%s</small>', |
|
158 | + sprintf( |
|
159 | + // translators: %s is the item quantity. |
|
160 | + esc_html__( 'Qty %s', 'invoicing' ), |
|
161 | + (float) $item->get_quantity() |
|
162 | + ) |
|
163 | + ); |
|
164 | + } |
|
165 | + |
|
166 | + if ( $has_featured_image || $has_variable_pricing ) { |
|
167 | + echo '</div>'; |
|
168 | + echo '</div>'; |
|
169 | + } |
|
184 | 170 | } |
185 | 171 | |
186 | - if ( $has_variable_pricing ) { ?> |
|
187 | - <span class="getpaid-items-<?php echo (int) $price_id; ?>-view-price"> |
|
172 | + // Item price. |
|
173 | + if ( 'price' === $key ) { |
|
174 | + |
|
175 | + // Set the currency position. |
|
176 | + $position = wpinv_currency_position(); |
|
177 | + |
|
178 | + if ( 'left_space' === $position ) { |
|
179 | + $position = 'left'; |
|
180 | + } |
|
181 | + |
|
182 | + if ( 'right_space' === $position ) { |
|
183 | + $position = 'right'; |
|
184 | + } |
|
185 | + |
|
186 | + if ( $has_variable_pricing ) { ?> |
|
187 | + <span class="getpaid-items-<?php echo (int) $price_id; ?>-view-price"> |
|
188 | 188 | <?php echo wp_kses_post( wpinv_price( $price['amount'], $currency ) ); ?> |
189 | 189 | </span> |
190 | 190 | <input name='getpaid-items[<?php echo (int) $price_id; ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $price['amount'] ); ?>'> |
191 | 191 | <?php } elseif ( $item->user_can_set_their_price() ) { |
192 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
193 | - $minimum = (float) $item->get_minimum_price(); |
|
194 | - $validate_minimum = ''; |
|
195 | - $class = ''; |
|
196 | - $data_minimum = ''; |
|
197 | - |
|
198 | - if ( $minimum > 0 ) { |
|
199 | - $validate_minimum = sprintf( |
|
200 | - // translators: %s is the minimum price. |
|
201 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
202 | - wp_strip_all_tags( wpinv_price( $minimum, $currency ) ) |
|
203 | - ); |
|
204 | - |
|
205 | - $class = 'getpaid-validate-minimum-amount'; |
|
206 | - |
|
207 | - $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
208 | - } |
|
209 | - |
|
210 | - ?> |
|
211 | - <div class="input-group input-group-sm"> |
|
192 | + $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
193 | + $minimum = (float) $item->get_minimum_price(); |
|
194 | + $validate_minimum = ''; |
|
195 | + $class = ''; |
|
196 | + $data_minimum = ''; |
|
197 | + |
|
198 | + if ( $minimum > 0 ) { |
|
199 | + $validate_minimum = sprintf( |
|
200 | + // translators: %s is the minimum price. |
|
201 | + esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
202 | + wp_strip_all_tags( wpinv_price( $minimum, $currency ) ) |
|
203 | + ); |
|
204 | + |
|
205 | + $class = 'getpaid-validate-minimum-amount'; |
|
206 | + |
|
207 | + $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
208 | + } |
|
209 | + |
|
210 | + ?> |
|
211 | + <div class="input-group input-group-sm"> |
|
212 | 212 | <?php if ( 'left' === $position ) : ?> |
213 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
213 | + <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
214 | 214 | <div class="input-group-prepend "> |
215 | 215 | <span class="input-group-text"> |
216 | 216 | <?php echo wp_kses_post( wpinv_currency_symbol( $currency ) ); ?></span> |
217 | 217 | </span> |
218 | 218 | </div> |
219 | 219 | <?php else : ?> |
220 | - <span class="input-group-text"> |
|
220 | + <span class="input-group-text"> |
|
221 | 221 | <?php echo wp_kses_post( wpinv_currency_symbol( $currency ) ); ?></span> |
222 | 222 | </span> |
223 | 223 | <?php endif; ?> |
224 | - <?php endif; ?> |
|
224 | + <?php endif; ?> |
|
225 | 225 | |
226 | 226 | <input type="number" step="0.01" <?php echo wp_kses_post( $data_minimum ); ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $price ) ); ?>" placeholder="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price() ) ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo esc_attr( $class ); ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
227 | 227 | |
228 | 228 | <?php if ( ! empty( $validate_minimum ) ) : ?> |
229 | - <div class="invalid-tooltip"> |
|
229 | + <div class="invalid-tooltip"> |
|
230 | 230 | <?php echo wp_kses_post( $validate_minimum ); ?> |
231 | - </div> |
|
231 | + </div> |
|
232 | 232 | <?php endif; ?> |
233 | - |
|
233 | + |
|
234 | 234 | <?php if ( 'left' !== $position ) : ?> |
235 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
235 | + <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
236 | 236 | <div class="input-group-append "> |
237 | 237 | <span class="input-group-text"> |
238 | 238 | <?php echo wp_kses_post( wpinv_currency_symbol( $currency ) ); ?></span> |
239 | 239 | </span> |
240 | 240 | </div> |
241 | 241 | <?php else : ?> |
242 | - <span class="input-group-text"> |
|
242 | + <span class="input-group-text"> |
|
243 | 243 | <?php echo wp_kses_post( wpinv_currency_symbol( $currency ) ); ?></span> |
244 | 244 | </span> |
245 | 245 | <?php endif; ?> |
246 | - <?php endif; ?> |
|
247 | - </div> |
|
246 | + <?php endif; ?> |
|
247 | + </div> |
|
248 | 248 | <?php } else { ?> |
249 | - <span class="getpaid-items-<?php echo (int) $item->get_id(); ?>-view-price"> |
|
249 | + <span class="getpaid-items-<?php echo (int) $item->get_id(); ?>-view-price"> |
|
250 | 250 | <?php echo wp_kses_post( wpinv_price( $item->get_price(), $currency ) ); ?> |
251 | 251 | </span> |
252 | 252 | <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() ); ?>'> |
253 | 253 | <?php |
254 | - } |
|
254 | + } |
|
255 | 255 | |
256 | - printf( |
|
257 | - '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>', |
|
258 | - // translators: %s is the item subtotal. |
|
259 | - sprintf( esc_html__( 'Subtotal: %s', 'invoicing' ), wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ) ) |
|
260 | - ); |
|
261 | - } |
|
256 | + printf( |
|
257 | + '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>', |
|
258 | + // translators: %s is the item subtotal. |
|
259 | + sprintf( esc_html__( 'Subtotal: %s', 'invoicing' ), wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ) ) |
|
260 | + ); |
|
261 | + } |
|
262 | 262 | |
263 | - // Item quantity. |
|
264 | - if ( 'quantity' === $key ) { |
|
263 | + // Item quantity. |
|
264 | + if ( 'quantity' === $key ) { |
|
265 | 265 | |
266 | - if ( $item->allows_quantities() ) { |
|
267 | - ?> |
|
268 | - <input name='getpaid-items[<?php echo (int) $price_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> |
|
266 | + if ( $item->allows_quantities() ) { |
|
267 | + ?> |
|
268 | + <input name='getpaid-items[<?php echo (int) $price_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> |
|
269 | 269 | <?php } else { ?> |
270 | - <span class="getpaid-items-<?php echo (int) $price_id; ?>-view-quantity"> |
|
270 | + <span class="getpaid-items-<?php echo (int) $price_id; ?>-view-quantity"> |
|
271 | 271 | <?php echo (float) $item->get_quantity(); ?> |
272 | 272 | </span> |
273 | 273 | <input type='hidden' name='getpaid-items[<?php echo (int) $price_id; ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'> |
274 | 274 | <?php |
275 | + } |
|
275 | 276 | } |
276 | - } |
|
277 | - |
|
278 | - // Item sub total. |
|
279 | - if ( 'subtotal' === $key ) { |
|
280 | - if( $has_variable_pricing ) { |
|
281 | - echo wp_kses_post( wpinv_price( $item->get_sub_total( 'view', $price_id ), $currency ) ); |
|
282 | - } else { |
|
283 | - echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ); |
|
284 | - } |
|
285 | - } |
|
286 | 277 | |
287 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
288 | - ?> |
|
278 | + // Item sub total. |
|
279 | + if ( 'subtotal' === $key ) { |
|
280 | + if( $has_variable_pricing ) { |
|
281 | + echo wp_kses_post( wpinv_price( $item->get_sub_total( 'view', $price_id ), $currency ) ); |
|
282 | + } else { |
|
283 | + echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ); |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
288 | + ?> |
|
289 | 289 | |
290 | 290 | </div> |
291 | 291 | |
@@ -295,4 +295,4 @@ discard block |
||
295 | 295 | |
296 | 296 | </div> |
297 | 297 | <?php |
298 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
298 | + do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | /** |
3 | 3 | * Displays the cart in a payment form |
4 | 4 | * |
@@ -7,33 +7,33 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | + defined( 'ABSPATH' ) || exit; |
|
11 | 11 | |
12 | -// Cart table columns. |
|
13 | -$columns = array( |
|
14 | - 'name' => __( 'Item', 'invoicing' ), |
|
15 | - 'price' => __( 'Price', 'invoicing' ), |
|
16 | - 'quantity' => __( 'Qty', 'invoicing' ), |
|
17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
18 | -); |
|
12 | + // Cart table columns. |
|
13 | + $columns = array( |
|
14 | + 'name' => __( 'Item', 'invoicing' ), |
|
15 | + 'price' => __( 'Price', 'invoicing' ), |
|
16 | + 'quantity' => __( 'Qty', 'invoicing' ), |
|
17 | + 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
18 | + ); |
|
19 | 19 | |
20 | -if ( ! empty( $form->invoice ) ) { |
|
21 | - $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
20 | + if ( ! empty( $form->invoice ) ) { |
|
21 | + $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
22 | 22 | } |
23 | 23 | |
24 | -if ( isset( $columns['tax_rate'] ) ) { |
|
25 | - unset( $columns['tax_rate'] ); |
|
24 | + if ( isset( $columns['tax_rate'] ) ) { |
|
25 | + unset( $columns['tax_rate'] ); |
|
26 | 26 | } |
27 | 27 | |
28 | -$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
28 | + $columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
29 | 29 | |
30 | -?> |
|
30 | + ?> |
|
31 | 31 | <div class="getpaid-payment-form-items-cart border form-group mb-3"> |
32 | 32 | |
33 | 33 | <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3"> |
34 | 34 | <div class="form-row row"> |
35 | 35 | <?php foreach ( $columns as $key => $label ) : ?> |
36 | - <div class="<?php echo 'name' == $key ? 'col-6' : 'col'; ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : ''; ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>"> |
|
36 | + <div class="<?php echo 'name' == $key ? 'col-6' : 'col'; ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : ''; ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>"> |
|
37 | 37 | <span><?php echo esc_html( $label ); ?></span> |
38 | 38 | </div> |
39 | 39 | <?php endforeach; ?> |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | |
43 | 43 | <?php |
44 | 44 | |
45 | - // Display the item totals. |
|
46 | - foreach ( $form->get_items() as $item ) { |
|
47 | - $prices = $item->get_variable_prices(); |
|
45 | + // Display the item totals. |
|
46 | + foreach ( $form->get_items() as $item ) { |
|
47 | + $prices = $item->get_variable_prices(); |
|
48 | 48 | |
49 | - if ( $item->has_variable_pricing() ) { |
|
50 | - foreach ( $prices as $variable_price_id => $price ) { |
|
51 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'variable_price_id', 'price', 'columns' ) ); |
|
49 | + if ( $item->has_variable_pricing() ) { |
|
50 | + foreach ( $prices as $variable_price_id => $price ) { |
|
51 | + wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'variable_price_id', 'price', 'columns' ) ); |
|
52 | + } |
|
53 | + } else { |
|
54 | + wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
52 | 55 | } |
53 | - } else { |
|
54 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
55 | 56 | } |
56 | - } |
|
57 | 57 | |
58 | - // Display the cart totals. |
|
59 | - wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
58 | + // Display the cart totals. |
|
59 | + wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
60 | 60 | |
61 | - ?> |
|
62 | - </div> |
|
61 | + ?> |
|
62 | + </div> |
|
63 | 63 | |
64 | -<?php |
|
64 | + <?php |
|
65 | 65 | |
66 | -do_action( 'getpaid_after_payment_form_cart', $form ); |
|
66 | + do_action( 'getpaid_after_payment_form_cart', $form ); |