| Total Complexity | 149 |
| Total Lines | 2261 |
| Duplicated Lines | 0 % |
| Changes | 19 | ||
| Bugs | 0 | Features | 2 |
Complex classes like WPInv_Payment_Form_Elements often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use WPInv_Payment_Form_Elements, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 7 | class WPInv_Payment_Form_Elements { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @param array payment form elements |
||
| 11 | */ |
||
| 12 | protected $elements; |
||
| 13 | |||
| 14 | public function __construct() { |
||
| 25 | } |
||
| 26 | |||
| 27 | |||
| 28 | } |
||
| 29 | |||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Returns all the elements that can be added to a form. |
||
| 34 | */ |
||
| 35 | public function get_elements() { |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Returns the restrict markup. |
||
| 49 | */ |
||
| 50 | public function get_restrict_markup( $field, $field_type ) { |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Renders the gateway select element template. |
||
| 57 | */ |
||
| 58 | public function render_gateway_select_template( $field ) { |
||
| 59 | $restrict = $this->get_restrict_markup( $field, 'gateway_select' ); |
||
| 60 | $text = __( 'The gateway select box will appear hear', 'invoicing' ); |
||
| 61 | echo " |
||
| 62 | <div $restrict class='alert alert-info' role='alert'> |
||
| 63 | <span>$text</span> |
||
| 64 | </div> |
||
| 65 | "; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Renders the edit gateway select element template. |
||
| 70 | */ |
||
| 71 | public function edit_gateway_select_template( $field ) { |
||
| 72 | $restrict = $this->get_restrict_markup( $field, 'gateway_select' ); |
||
| 73 | $label = __( 'The gateway select text', 'invoicing' ); |
||
| 74 | $id = $field . '.id + "_edit"'; |
||
| 75 | echo " |
||
| 76 | <div $restrict> |
||
| 77 | <div class='form-group'> |
||
| 78 | <label :for='$id'>$label</label> |
||
| 79 | <textarea :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
||
| 80 | </div> |
||
| 81 | </div> |
||
| 82 | "; |
||
| 83 | |||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Renders the total payable element template. |
||
| 88 | */ |
||
| 89 | public function render_total_payable_template( $field ) { |
||
| 90 | $restrict = $this->get_restrict_markup( $field, 'total_payable' ); |
||
| 91 | $text = __( 'The total payable amount will appear here', 'invoicing' ); |
||
| 92 | echo " |
||
| 93 | <div $restrict class='alert alert-info' role='alert'> |
||
| 94 | <span>$text</span> |
||
| 95 | </div> |
||
| 96 | "; |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Renders the edit total payable element template. |
||
| 101 | */ |
||
| 102 | public function edit_total_payable_template( $field ) { |
||
| 103 | $restrict = $this->get_restrict_markup( $field, 'total_payable' ); |
||
| 104 | $label = __( 'The total payable text', 'invoicing' ); |
||
| 105 | $id = $field . '.id + "_edit"'; |
||
| 106 | echo " |
||
| 107 | <div $restrict> |
||
| 108 | <div class='form-group'> |
||
| 109 | <label :for='$id'>$label</label> |
||
| 110 | <textarea :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
||
| 111 | </div> |
||
| 112 | </div> |
||
| 113 | "; |
||
| 114 | |||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Renders the title element template. |
||
| 119 | */ |
||
| 120 | public function render_heading_template( $field ) { |
||
| 121 | $restrict = $this->get_restrict_markup( $field, 'heading' ); |
||
| 122 | echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Renders the edit title element template. |
||
| 127 | */ |
||
| 128 | public function edit_heading_template( $field ) { |
||
| 129 | $restrict = $this->get_restrict_markup( $field, 'heading' ); |
||
| 130 | $label = __( 'Heading', 'invoicing' ); |
||
| 131 | $label2 = __( 'Select Heading Level', 'invoicing' ); |
||
| 132 | $id = $field . '.id + "_edit"'; |
||
| 133 | $id2 = $field . '.id + "_edit2"'; |
||
| 134 | |||
| 135 | echo " |
||
| 136 | <div $restrict> |
||
| 137 | <div class='form-group'> |
||
| 138 | <label :for='$id'>$label</label> |
||
| 139 | <input class='form-control' :id='$id' v-model='$field.text' type='text' /> |
||
| 140 | </div> |
||
| 141 | |||
| 142 | <div class='form-group'> |
||
| 143 | <label :for='$id2'>$label2</label> |
||
| 144 | |||
| 145 | <select class='form-control custom-select' :id='$id2' v-model='$field.level'> |
||
| 146 | <option value='h1'>H1</option> |
||
| 147 | <option value='h2'>H2</option> |
||
| 148 | <option value='h3'>H3</option> |
||
| 149 | <option value='h4'>H4</option> |
||
| 150 | <option value='h5'>H5</option> |
||
| 151 | <option value='h6'>H6</option> |
||
| 152 | <option value='h7'>H7</option> |
||
| 153 | </select> |
||
| 154 | </div> |
||
| 155 | </div> |
||
| 156 | "; |
||
| 157 | |||
| 158 | } |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Renders a paragraph element template. |
||
| 162 | */ |
||
| 163 | public function render_paragraph_template( $field ) { |
||
| 164 | $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
||
| 165 | $label = "$field.text"; |
||
| 166 | echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Renders the edit paragraph element template. |
||
| 171 | */ |
||
| 172 | public function edit_paragraph_template( $field ) { |
||
| 173 | $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
||
| 174 | $label = __( 'Enter your text', 'invoicing' ); |
||
| 175 | $id = $field . '.id + "_edit"'; |
||
| 176 | echo " |
||
| 177 | <div $restrict> |
||
| 178 | <div class='form-group'> |
||
| 179 | <label :for='$id'>$label</label> |
||
| 180 | <textarea :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
||
| 181 | </div> |
||
| 182 | </div> |
||
| 183 | "; |
||
| 184 | |||
| 185 | } |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Renders the text element template. |
||
| 189 | */ |
||
| 190 | public function render_text_template( $field ) { |
||
| 191 | $restrict = $this->get_restrict_markup( $field, 'text' ); |
||
| 192 | $label = "$field.label"; |
||
| 193 | echo " |
||
| 194 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 195 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 196 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 197 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='text'> |
||
| 198 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 199 | </div> |
||
| 200 | "; |
||
| 201 | } |
||
| 202 | |||
| 203 | /** |
||
| 204 | * Renders the edit price select element template. |
||
| 205 | */ |
||
| 206 | public function edit_price_select_template( $field ) { |
||
| 207 | $restrict = $this->get_restrict_markup( $field, 'price_select' ); |
||
| 208 | |||
| 209 | $label3 = __( 'Help text', 'invoicing' ); |
||
|
|
|||
| 210 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 211 | $id3 = $field . '.id + "_edit3"'; |
||
| 212 | $label6 = __( 'Options', 'invoicing' ); |
||
| 213 | $id6 = $field . '.id + "_edit5"'; |
||
| 214 | ?> |
||
| 215 | <div <?php echo $restrict; ?>> |
||
| 216 | <small class='form-text text-muted mb-2'><?php _e( 'This amount will be added to the total amount for this form', 'invoicing' ); ?></small> |
||
| 217 | <div class='form-group'> |
||
| 218 | <label class="d-block"> |
||
| 219 | <span><?php _e( 'Field Label', 'invoicing' ); ?></span> |
||
| 220 | <input v-model='<?php echo $field; ?>.label' class='form-control' /> |
||
| 221 | </label> |
||
| 222 | </div> |
||
| 223 | |||
| 224 | <div class='form-group' v-if="<?php echo $field; ?>.select_type=='select'"> |
||
| 225 | <label class="d-block"> |
||
| 226 | <span><?php _e( 'Placeholder text', 'invoicing' ); ?></span> |
||
| 227 | <input v-model='<?php echo $field; ?>.placeholder' class='form-control' /> |
||
| 228 | </label> |
||
| 229 | </div> |
||
| 230 | |||
| 231 | <div class='form-group'> |
||
| 232 | <label class="d-block"> |
||
| 233 | <span><?php _e( 'Select Type', 'invoicing' ); ?></span> |
||
| 234 | <select class='form-control custom-select' v-model='<?php echo $field; ?>.select_type'> |
||
| 235 | <option value='select'><?php _e( 'Dropdown', 'invoicing' ) ?></option> |
||
| 236 | <option value='checkboxes'><?php _e( 'Checkboxes', 'invoicing' ) ?></option> |
||
| 237 | <option value='radios'><?php _e( 'Radio Buttons', 'invoicing' ) ?></option> |
||
| 238 | <option value='buttons'><?php _e( 'Buttons', 'invoicing' ) ?></option> |
||
| 239 | <option value='circles'><?php _e( 'Circles', 'invoicing' ) ?></option> |
||
| 240 | </select> |
||
| 241 | </label> |
||
| 242 | </div> |
||
| 243 | |||
| 244 | <div class='form-group'> |
||
| 245 | <label class="d-block"> |
||
| 246 | <span><?php _e( 'Options', 'invoicing' ); ?></span> |
||
| 247 | <textarea placeholder='Basic|10,Pro|99,Business|199' v-model='<?php echo $field; ?>.options' class='form-control' rows='3'></textarea> |
||
| 248 | <small class='form-text text-muted mb-2'><?php _e( 'Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing' ); ?></small> |
||
| 249 | </label> |
||
| 250 | </div> |
||
| 251 | |||
| 252 | <div class='form-group'> |
||
| 253 | <label class="d-block"> |
||
| 254 | <span><?php _e( 'Help Text', 'invoicing' ); ?></span> |
||
| 255 | <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea> |
||
| 256 | </label> |
||
| 257 | </div> |
||
| 258 | </div> |
||
| 259 | <?php |
||
| 260 | |||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * Renders the price select element template. |
||
| 265 | */ |
||
| 266 | public function render_price_select_template( $field ) { |
||
| 267 | $restrict = $this->get_restrict_markup( $field, 'price_select' ); |
||
| 268 | ?> |
||
| 269 | <div <?php echo $restrict; ?> class='wpinv-payment-form-field-preview'> |
||
| 270 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 271 | |||
| 272 | <label>{{<?php echo $field; ?>.label}}</label> |
||
| 273 | |||
| 274 | <!-- Buttons --> |
||
| 275 | <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="buttons"' class="getpaid-price-buttons"> |
||
| 276 | <span v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
||
| 277 | <input type="radio" :id="<?php echo esc_attr( $field ); ?>.id + index" :checked="index==0" /> |
||
| 278 | <label :for="<?php echo esc_attr( $field ); ?>.id + index" class="rounded">{{option | optionize}}</label> |
||
| 279 | </span> |
||
| 280 | </div> |
||
| 281 | |||
| 282 | <!-- Circles --> |
||
| 283 | <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="circles"' class="getpaid-price-buttons getpaid-price-circles"> |
||
| 284 | <span v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
||
| 285 | <input type="radio" :id="<?php echo esc_attr( $field ); ?>.id + index" :checked="index==0" /> |
||
| 286 | <label :for="<?php echo esc_attr( $field ); ?>.id + index"><span>{{option | optionize}}</span></label> |
||
| 287 | </span> |
||
| 288 | </div> |
||
| 289 | |||
| 290 | <!-- Radios --> |
||
| 291 | <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="radios"'> |
||
| 292 | <div v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
||
| 293 | <label> |
||
| 294 | <input type="radio" :checked="index==0" /> |
||
| 295 | <span>{{option | optionize}}</span> |
||
| 296 | </label> |
||
| 297 | </div> |
||
| 298 | </div> |
||
| 299 | |||
| 300 | <!-- Checkboxes --> |
||
| 301 | <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="checkboxes"'> |
||
| 302 | <div v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
||
| 303 | <label> |
||
| 304 | <input type="checkbox" :checked="index==0" /> |
||
| 305 | <span>{{option | optionize}}</span> |
||
| 306 | </label> |
||
| 307 | </div> |
||
| 308 | </div> |
||
| 309 | |||
| 310 | <!-- Select --> |
||
| 311 | <select v-if='<?php echo esc_attr( $field ); ?>.select_type=="select"' class='form-control custom-select'> |
||
| 312 | <option v-if="<?php echo esc_attr( $field ); ?>.placeholder" selected="selected"> |
||
| 313 | {{<?php echo esc_attr( $field ); ?>.placeholder}} |
||
| 314 | </option> |
||
| 315 | <option v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
||
| 316 | {{option | optionize}} |
||
| 317 | </option> |
||
| 318 | </select> |
||
| 319 | <small v-if='<?php echo esc_attr( $field ); ?>.description' class='form-text text-muted' v-html='<?php echo esc_attr( $field ); ?>.description'></small> |
||
| 320 | </div> |
||
| 321 | |||
| 322 | <?php |
||
| 323 | } |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Renders the edit price input element template. |
||
| 327 | */ |
||
| 328 | public function edit_price_input_template( $field ) { |
||
| 329 | $restrict = $this->get_restrict_markup( $field, 'price_input' ); |
||
| 330 | $label = __( 'Field Label', 'invoicing' ); |
||
| 331 | $id = $field . '.id + "_edit"'; |
||
| 332 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 333 | $id2 = $field . '.id + "_edit2"'; |
||
| 334 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 335 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 336 | $id3 = $field . '.id + "_edit3"'; |
||
| 337 | $label5 = __( 'The amount that users add to this field will be added to the total amount', 'invoicing' ); |
||
| 338 | $label6 = __( 'Default Amount', 'invoicing' ); |
||
| 339 | $id6 = $field . '.id + "_edit5"'; |
||
| 340 | echo " |
||
| 341 | <div $restrict> |
||
| 342 | <small class='form-text text-muted mb-2'>$label5</small> |
||
| 343 | <div class='form-group'> |
||
| 344 | <label :for='$id'>$label</label> |
||
| 345 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 346 | </div> |
||
| 347 | <div class='form-group'> |
||
| 348 | <label :for='$id6'>$label6</label> |
||
| 349 | <input :id='$id6' v-model='$field.value' class='form-control' /> |
||
| 350 | </div> |
||
| 351 | <div class='form-group'> |
||
| 352 | <label :for='$id2'>$label2</label> |
||
| 353 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 354 | </div> |
||
| 355 | <div class='form-group'> |
||
| 356 | <label :for='$id3'>$label3</label> |
||
| 357 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 358 | </div> |
||
| 359 | </div> |
||
| 360 | "; |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Renders the edit text element template. |
||
| 365 | */ |
||
| 366 | public function edit_text_template( $field ) { |
||
| 367 | $restrict = $this->get_restrict_markup( $field, 'text' ); |
||
| 368 | $label = __( 'Field Label', 'invoicing' ); |
||
| 369 | $id = $field . '.id + "_edit"'; |
||
| 370 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 371 | $id2 = $field . '.id + "_edit2"'; |
||
| 372 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 373 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 374 | $id3 = $field . '.id + "_edit3"'; |
||
| 375 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 376 | $id4 = $field . '.id + "_edit4"'; |
||
| 377 | echo " |
||
| 378 | <div $restrict> |
||
| 379 | <div class='form-group'> |
||
| 380 | <label :for='$id'>$label</label> |
||
| 381 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 382 | </div> |
||
| 383 | <div class='form-group'> |
||
| 384 | <label :for='$id2'>$label2</label> |
||
| 385 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 386 | </div> |
||
| 387 | <div class='form-group'> |
||
| 388 | <label :for='$id3'>$label3</label> |
||
| 389 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 390 | </div> |
||
| 391 | <div class='form-group form-check'> |
||
| 392 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 393 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 394 | </div> |
||
| 395 | </div> |
||
| 396 | "; |
||
| 397 | |||
| 398 | } |
||
| 399 | |||
| 400 | /** |
||
| 401 | * Renders the textarea element template. |
||
| 402 | */ |
||
| 403 | public function render_textarea_template( $field ) { |
||
| 404 | $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
||
| 405 | $label = "$field.label"; |
||
| 406 | echo " |
||
| 407 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 408 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 409 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 410 | <textarea :placeholder='$field.placeholder' :id='$field.id' class='form-control' rows='3'></textarea> |
||
| 411 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 412 | </div> |
||
| 413 | "; |
||
| 414 | } |
||
| 415 | |||
| 416 | /** |
||
| 417 | * Renders the edit textarea element template. |
||
| 418 | */ |
||
| 419 | public function edit_textarea_template( $field ) { |
||
| 420 | $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
||
| 421 | $label = __( 'Field Label', 'invoicing' ); |
||
| 422 | $id = $field . '.id + "_edit"'; |
||
| 423 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 424 | $id2 = $field . '.id + "_edit2"'; |
||
| 425 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 426 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 427 | $id3 = $field . '.id + "_edit3"'; |
||
| 428 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 429 | $id4 = $field . '.id + "_edit4"'; |
||
| 430 | echo " |
||
| 431 | <div $restrict> |
||
| 432 | <div class='form-group'> |
||
| 433 | <label :for='$id'>$label</label> |
||
| 434 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 435 | </div> |
||
| 436 | <div class='form-group'> |
||
| 437 | <label :for='$id2'>$label2</label> |
||
| 438 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 439 | </div> |
||
| 440 | <div class='form-group'> |
||
| 441 | <label :for='$id3'>$label3</label> |
||
| 442 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 443 | </div> |
||
| 444 | <div class='form-group form-check'> |
||
| 445 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 446 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 447 | </div> |
||
| 448 | </div> |
||
| 449 | "; |
||
| 450 | |||
| 451 | } |
||
| 452 | |||
| 453 | /** |
||
| 454 | * Renders the select element template. |
||
| 455 | */ |
||
| 456 | public function render_select_template( $field ) { |
||
| 457 | $restrict = $this->get_restrict_markup( $field, 'select' ); |
||
| 458 | $label = "$field.label"; |
||
| 459 | $placeholder = "$field.placeholder"; |
||
| 460 | $id = $field . '.id'; |
||
| 461 | echo " |
||
| 462 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 463 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 464 | <label :for='$id'>{{" . $label . "}}</label> |
||
| 465 | <select id='$id' class='form-control custom-select' v-model='$field.value'> |
||
| 466 | <option v-if='$placeholder' value='' disabled>{{" . $placeholder . "}}</option> |
||
| 467 | <option v-for='option in $field.options' value='option'>{{option}}</option> |
||
| 468 | </select> |
||
| 469 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 470 | </div> |
||
| 471 | "; |
||
| 472 | } |
||
| 473 | |||
| 474 | /** |
||
| 475 | * Renders the edit select element template. |
||
| 476 | */ |
||
| 477 | public function edit_select_template( $field ) { |
||
| 478 | $restrict = $this->get_restrict_markup( $field, 'select' ); |
||
| 479 | $label = __( 'Field Label', 'invoicing' ); |
||
| 480 | $id = $field . '.id + "_edit"'; |
||
| 481 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 482 | $id2 = $field . '.id + "_edit2"'; |
||
| 483 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 484 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 485 | $id3 = $field . '.id + "_edit3"'; |
||
| 486 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 487 | $id4 = $field . '.id + "_edit4"'; |
||
| 488 | $label6 = __( 'Available Options', 'invoicing' ); |
||
| 489 | echo " |
||
| 490 | <div $restrict> |
||
| 491 | <div class='form-group'> |
||
| 492 | <label :for='$id'>$label</label> |
||
| 493 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 494 | </div> |
||
| 495 | <div class='form-group'> |
||
| 496 | <label :for='$id2'>$label2</label> |
||
| 497 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 498 | </div> |
||
| 499 | <div class='form-group'> |
||
| 500 | <label :for='$id3'>$label3</label> |
||
| 501 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 502 | </div> |
||
| 503 | <div class='form-group form-check'> |
||
| 504 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 505 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 506 | </div> |
||
| 507 | <hr class='featurette-divider mt-4'> |
||
| 508 | <h5>$label6</h5> |
||
| 509 | <div class='form-group input-group' v-for='(option, index) in $field.options'> |
||
| 510 | <input type='text' class='form-control' v-model='$field.options[index]'> |
||
| 511 | <div class='input-group-append'> |
||
| 512 | <button class='button button-secondary border' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
||
| 513 | </div> |
||
| 514 | </div> |
||
| 515 | <div class='form-group'> |
||
| 516 | <button class='button button-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
||
| 517 | </div> |
||
| 518 | </div> |
||
| 519 | "; |
||
| 520 | |||
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * Renders the checkbox element template. |
||
| 525 | */ |
||
| 526 | public function render_checkbox_template( $field ) { |
||
| 527 | $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
||
| 528 | echo " |
||
| 529 | <div class='form-check' $restrict> |
||
| 530 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 531 | <input :id='$field.id' class='form-check-input' type='checkbox' /> |
||
| 532 | <label class='form-check-label' :for='$field.id' v-html='$field.label'></label> |
||
| 533 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 534 | </div> |
||
| 535 | "; |
||
| 536 | } |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Renders the edit checkbox element template. |
||
| 540 | */ |
||
| 541 | public function edit_checkbox_template( $field ) { |
||
| 542 | $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
||
| 543 | $label = __( 'Field Label', 'invoicing' ); |
||
| 544 | $id = $field . '.id + "_edit"'; |
||
| 545 | $label2 = __( 'Help text', 'invoicing' ); |
||
| 546 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 547 | $id2 = $field . '.id + "_edit2"'; |
||
| 548 | $label4 = __( 'Is this field required?', 'invoicing' ); |
||
| 549 | $id3 = $field . '.id + "_edit3"'; |
||
| 550 | echo " |
||
| 551 | <div $restrict> |
||
| 552 | <div class='form-group'> |
||
| 553 | <label :for='$id'>$label</label> |
||
| 554 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 555 | </div> |
||
| 556 | <div class='form-group'> |
||
| 557 | <label :for='$id2'>$label2</label> |
||
| 558 | <textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 559 | </div> |
||
| 560 | <div class='form-group form-check'> |
||
| 561 | <input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 562 | <label class='form-check-label' :for='$id3'>$label4</label> |
||
| 563 | </div> |
||
| 564 | </div> |
||
| 565 | "; |
||
| 566 | |||
| 567 | } |
||
| 568 | |||
| 569 | /** |
||
| 570 | * Renders the radio element template. |
||
| 571 | */ |
||
| 572 | public function render_radio_template( $field ) { |
||
| 573 | $restrict = $this->get_restrict_markup( $field, 'radio' ); |
||
| 574 | $label = "$field.label"; |
||
| 575 | $id = $field . '.id'; |
||
| 576 | echo " |
||
| 577 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 578 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 579 | <legend class='col-form-label' v-if='$label'>{{" . $label . "}}</legend> |
||
| 580 | <div class='form-check' v-for='(option, index) in $field.options'> |
||
| 581 | <input class='form-check-input' type='radio' :id='$id + index'> |
||
| 582 | <label class='form-check-label' :for='$id + index'>{{option}}</label> |
||
| 583 | </div> |
||
| 584 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 585 | </div> |
||
| 586 | "; |
||
| 587 | } |
||
| 588 | |||
| 589 | /** |
||
| 590 | * Renders the edit radio element template. |
||
| 591 | */ |
||
| 592 | public function edit_radio_template( $field ) { |
||
| 593 | $restrict = $this->get_restrict_markup( $field, 'radio' ); |
||
| 594 | $label = __( 'Field Label', 'invoicing' ); |
||
| 595 | $id = $field . '.id + "_edit"'; |
||
| 596 | $label2 = __( 'Help text', 'invoicing' ); |
||
| 597 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 598 | $id2 = $field . '.id + "_edit3"'; |
||
| 599 | $label4 = __( 'Is this field required?', 'invoicing' ); |
||
| 600 | $id3 = $field . '.id + "_edit4"'; |
||
| 601 | $label5 = __( 'Available Options', 'invoicing' ); |
||
| 602 | echo " |
||
| 603 | <div $restrict> |
||
| 604 | <div class='form-group'> |
||
| 605 | <label :for='$id'>$label</label> |
||
| 606 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 607 | </div> |
||
| 608 | <div class='form-group'> |
||
| 609 | <label :for='$id2'>$label2</label> |
||
| 610 | <textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 611 | </div> |
||
| 612 | <div class='form-group form-check'> |
||
| 613 | <input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 614 | <label class='form-check-label' :for='$id3'>$label4</label> |
||
| 615 | </div> |
||
| 616 | <hr class='featurette-divider mt-4'> |
||
| 617 | <h5>$label5</h5> |
||
| 618 | <div class='form-group input-group' v-for='(option, index) in $field.options'> |
||
| 619 | <input type='text' class='form-control' v-model='$field.options[index]'> |
||
| 620 | <div class='input-group-append'> |
||
| 621 | <button class='button button-secondary border' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
||
| 622 | </div> |
||
| 623 | </div> |
||
| 624 | <div class='form-group'> |
||
| 625 | <button class='button button-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
||
| 626 | </div> |
||
| 627 | </div> |
||
| 628 | "; |
||
| 629 | |||
| 630 | } |
||
| 631 | |||
| 632 | /** |
||
| 633 | * Renders the address element template. |
||
| 634 | */ |
||
| 635 | public function render_address_template( $field ) { |
||
| 636 | $restrict = $this->get_restrict_markup( $field, 'address' ); |
||
| 637 | |||
| 638 | echo " |
||
| 639 | <div class='wpinv-address-wrapper' $restrict> |
||
| 640 | <draggable v-model='$field.fields' group='address_fields_preview'> |
||
| 641 | <div class='form-group address-field-preview wpinv-payment-form-field-preview' v-for='(field, index) in $field.fields' :key='field.name' v-show='field.visible'> |
||
| 642 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 643 | <label :for='field.name'>{{field.label}}<span class='text-danger' v-if='field.required'> *</span></label> |
||
| 644 | <input v-if='field.name !== \"wpinv_country\" && field.name !== \"wpinv_state\"' class='form-control' type='text' :id='field.name' :placeholder='field.placeholder'> |
||
| 645 | <select v-else class='form-control' :id='field.name'> |
||
| 646 | <option v-if='field.placeholder'>{{field.placeholder}}</option> |
||
| 647 | </select> |
||
| 648 | <small v-if='field.description' class='form-text text-muted' v-html='field.description'></small> |
||
| 649 | </div> |
||
| 650 | </draggable> |
||
| 651 | </div> |
||
| 652 | "; |
||
| 653 | } |
||
| 654 | |||
| 655 | /** |
||
| 656 | * Renders the edit address element template. |
||
| 657 | */ |
||
| 658 | public function edit_address_template( $field ) { |
||
| 659 | $restrict = $this->get_restrict_markup( $field, 'address' ); |
||
| 660 | $label = __( 'Field Label', 'invoicing' ); |
||
| 661 | $label2 = __( 'Placeholder', 'invoicing' ); |
||
| 662 | $label3 = __( 'Description', 'invoicing' ); |
||
| 663 | $label4 = __( 'Is required', 'invoicing' ); |
||
| 664 | $label5 = __( 'Is visible', 'invoicing' ); |
||
| 665 | $id = $field . '.id + "_edit_label"'; |
||
| 666 | $id2 = $field . '.id + "_edit_placeholder"'; |
||
| 667 | $id3 = $field . '.id + "_edit_description"'; |
||
| 668 | $id4 = $field . '.id + "_edit_required"'; |
||
| 669 | $id5 = $field . '.id + "_edit_visible"'; |
||
| 670 | $id5 = $field . '.id + "_edit_visible"'; |
||
| 671 | $id_main = $field . '.id'; |
||
| 672 | |||
| 673 | echo " |
||
| 674 | <div $restrict :id='$id_main'> |
||
| 675 | <draggable v-model='$field.fields' group='address_fields'> |
||
| 676 | <div class='wpinv-form-address-field-editor' v-for='(field, index) in $field.fields' :class=\"[field.name, { 'visible' : field.visible }]\" :key='field.name'> |
||
| 677 | |||
| 678 | <div class='wpinv-form-address-field-editor-header' @click.prevent='toggleAddressPanel($id_main, field.name)'> |
||
| 679 | <span class='label'>{{field.label}}</span> |
||
| 680 | <span class='toggle-visibility-icon' @click.stop='field.visible = !field.visible;'> |
||
| 681 | <span class='dashicons dashicons-hidden'></span> |
||
| 682 | <span class='dashicons dashicons-visibility'></span> |
||
| 683 | </span> |
||
| 684 | <span class='toggle-icon'> |
||
| 685 | <span class='dashicons dashicons-arrow-down'></span> |
||
| 686 | <span class='dashicons dashicons-arrow-up' style='display:none'></span> |
||
| 687 | </span> |
||
| 688 | </div> |
||
| 689 | |||
| 690 | <div class='wpinv-form-address-field-editor-editor-body'> |
||
| 691 | <div class='p-2'> |
||
| 692 | |||
| 693 | <div class='form-group'> |
||
| 694 | <label :for='$id + index'>$label</label> |
||
| 695 | <input :id='$id + index' v-model='field.label' class='form-control' /> |
||
| 696 | </div> |
||
| 697 | |||
| 698 | <div class='form-group'> |
||
| 699 | <label :for='$id2 + index'>$label2</label> |
||
| 700 | <input :id='$id2 + index' v-model='field.placeholder' class='form-control' /> |
||
| 701 | </div> |
||
| 702 | |||
| 703 | <div class='form-group'> |
||
| 704 | <label :for='$id3 + index'>$label3</label> |
||
| 705 | <textarea :id='$id3 + index' v-model='field.description' class='form-control'></textarea> |
||
| 706 | </div> |
||
| 707 | |||
| 708 | <div class='form-group form-check'> |
||
| 709 | <input :id='$id4 + index' v-model='field.required' type='checkbox' class='form-check-input' /> |
||
| 710 | <label class='form-check-label' :for='$id4 + index'>$label4</label> |
||
| 711 | </div> |
||
| 712 | |||
| 713 | <div class='form-group form-check'> |
||
| 714 | <input :id='$id5 + index' v-model='field.visible' type='checkbox' class='form-check-input' /> |
||
| 715 | <label class='form-check-label' :for='$id5 + index'>$label5</label> |
||
| 716 | </div> |
||
| 717 | |||
| 718 | </div> |
||
| 719 | </div> |
||
| 720 | |||
| 721 | </div> |
||
| 722 | </draggable> |
||
| 723 | |||
| 724 | </div> |
||
| 725 | "; |
||
| 726 | |||
| 727 | } |
||
| 728 | |||
| 729 | /** |
||
| 730 | * Renders the email element template. |
||
| 731 | */ |
||
| 732 | public function render_email_template( $field ) { |
||
| 733 | $restrict = $this->get_restrict_markup( $field, 'email' ); |
||
| 734 | $label = "$field.label"; |
||
| 735 | echo " |
||
| 736 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 737 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 738 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 739 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='email'> |
||
| 740 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 741 | </div> |
||
| 742 | "; |
||
| 743 | } |
||
| 744 | |||
| 745 | /** |
||
| 746 | * Renders the billing_email element template. |
||
| 747 | */ |
||
| 748 | public function render_billing_email_template( $field ) { |
||
| 749 | $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
||
| 750 | $label = "$field.label"; |
||
| 751 | echo " |
||
| 752 | <div $restrict> |
||
| 753 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 754 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='email'> |
||
| 755 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 756 | </div> |
||
| 757 | "; |
||
| 758 | } |
||
| 759 | |||
| 760 | /** |
||
| 761 | * Renders the edit email element template. |
||
| 762 | */ |
||
| 763 | public function edit_email_template( $field ) { |
||
| 764 | $restrict = $this->get_restrict_markup( $field, 'email' ); |
||
| 765 | $label = __( 'Field Label', 'invoicing' ); |
||
| 766 | $id = $field . '.id + "_edit"'; |
||
| 767 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 768 | $id2 = $field . '.id + "_edit2"'; |
||
| 769 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 770 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 771 | $id3 = $field . '.id + "_edit3"'; |
||
| 772 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 773 | $id4 = $field . '.id + "_edit4"'; |
||
| 774 | echo " |
||
| 775 | <div $restrict> |
||
| 776 | <div class='form-group'> |
||
| 777 | <label :for='$id'>$label</label> |
||
| 778 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 779 | </div> |
||
| 780 | <div class='form-group'> |
||
| 781 | <label :for='$id2'>$label2</label> |
||
| 782 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 783 | </div> |
||
| 784 | <div class='form-group'> |
||
| 785 | <label :for='$id3'>$label3</label> |
||
| 786 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 787 | </div> |
||
| 788 | <div class='form-group form-check'> |
||
| 789 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 790 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 791 | </div> |
||
| 792 | </div> |
||
| 793 | "; |
||
| 794 | |||
| 795 | } |
||
| 796 | |||
| 797 | /** |
||
| 798 | * Renders the edit billing_email element template. |
||
| 799 | */ |
||
| 800 | public function edit_billing_email_template( $field ) { |
||
| 801 | $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
||
| 802 | $label = __( 'Field Label', 'invoicing' ); |
||
| 803 | $id = $field . '.id + "_edit"'; |
||
| 804 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 805 | $id2 = $field . '.id + "_edit2"'; |
||
| 806 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 807 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 808 | $id3 = $field . '.id + "_edit3"'; |
||
| 809 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 810 | $id4 = $field . '.id + "_edit4"'; |
||
| 811 | echo " |
||
| 812 | <div $restrict> |
||
| 813 | <div class='form-group'> |
||
| 814 | <label :for='$id'>$label</label> |
||
| 815 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 816 | </div> |
||
| 817 | <div class='form-group'> |
||
| 818 | <label :for='$id2'>$label2</label> |
||
| 819 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 820 | </div> |
||
| 821 | <div class='form-group'> |
||
| 822 | <label :for='$id3'>$label3</label> |
||
| 823 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 824 | </div> |
||
| 825 | </div> |
||
| 826 | "; |
||
| 827 | |||
| 828 | } |
||
| 829 | |||
| 830 | /** |
||
| 831 | * Renders the website element template. |
||
| 832 | */ |
||
| 833 | public function render_website_template( $field ) { |
||
| 834 | $restrict = $this->get_restrict_markup( $field, 'website' ); |
||
| 835 | $label = "$field.label"; |
||
| 836 | echo " |
||
| 837 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 838 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 839 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 840 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='url'> |
||
| 841 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 842 | </div> |
||
| 843 | "; |
||
| 844 | } |
||
| 845 | |||
| 846 | /** |
||
| 847 | * Renders the edit website element template. |
||
| 848 | */ |
||
| 849 | public function edit_website_template( $field ) { |
||
| 850 | $restrict = $this->get_restrict_markup( $field, 'website' ); |
||
| 851 | $label = __( 'Field Label', 'invoicing' ); |
||
| 852 | $id = $field . '.id + "_edit"'; |
||
| 853 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 854 | $id2 = $field . '.id + "_edit2"'; |
||
| 855 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 856 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 857 | $id3 = $field . '.id + "_edit3"'; |
||
| 858 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 859 | $id4 = $field . '.id + "_edit4"'; |
||
| 860 | echo " |
||
| 861 | <div $restrict> |
||
| 862 | <div class='form-group'> |
||
| 863 | <label :for='$id'>$label</label> |
||
| 864 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 865 | </div> |
||
| 866 | <div class='form-group'> |
||
| 867 | <label :for='$id2'>$label2</label> |
||
| 868 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 869 | </div> |
||
| 870 | <div class='form-group'> |
||
| 871 | <label :for='$id3'>$label3</label> |
||
| 872 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 873 | </div> |
||
| 874 | <div class='form-group form-check'> |
||
| 875 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 876 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 877 | </div> |
||
| 878 | </div> |
||
| 879 | "; |
||
| 880 | |||
| 881 | } |
||
| 882 | |||
| 883 | /** |
||
| 884 | * Renders the date element template. |
||
| 885 | */ |
||
| 886 | public function render_date_template( $field ) { |
||
| 887 | $restrict = $this->get_restrict_markup( $field, 'date' ); |
||
| 888 | $label = "$field.label"; |
||
| 889 | echo " |
||
| 890 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 891 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 892 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 893 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='date'> |
||
| 894 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 895 | </div> |
||
| 896 | "; |
||
| 897 | } |
||
| 898 | |||
| 899 | /** |
||
| 900 | * Renders the edit date element template. |
||
| 901 | */ |
||
| 902 | public function edit_date_template( $field ) { |
||
| 903 | $restrict = $this->get_restrict_markup( $field, 'date' ); |
||
| 904 | $label = __( 'Field Label', 'invoicing' ); |
||
| 905 | $id = $field . '.id + "_edit"'; |
||
| 906 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 907 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 908 | $id3 = $field . '.id + "_edit3"'; |
||
| 909 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 910 | $id4 = $field . '.id + "_edit4"'; |
||
| 911 | echo " |
||
| 912 | <div $restrict> |
||
| 913 | <div class='form-group'> |
||
| 914 | <label :for='$id'>$label</label> |
||
| 915 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 916 | </div> |
||
| 917 | <div class='form-group'> |
||
| 918 | <label :for='$id3'>$label3</label> |
||
| 919 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 920 | </div> |
||
| 921 | <div class='form-group form-check'> |
||
| 922 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 923 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 924 | </div> |
||
| 925 | </div> |
||
| 926 | "; |
||
| 927 | |||
| 928 | } |
||
| 929 | |||
| 930 | /** |
||
| 931 | * Renders the time element template. |
||
| 932 | */ |
||
| 933 | public function render_time_template( $field ) { |
||
| 934 | $restrict = $this->get_restrict_markup( $field, 'time' ); |
||
| 935 | $label = "$field.label"; |
||
| 936 | echo " |
||
| 937 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 938 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 939 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 940 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='time'> |
||
| 941 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 942 | </div> |
||
| 943 | "; |
||
| 944 | } |
||
| 945 | |||
| 946 | /** |
||
| 947 | * Renders the edit time element template. |
||
| 948 | */ |
||
| 949 | public function edit_time_template( $field ) { |
||
| 950 | $restrict = $this->get_restrict_markup( $field, 'time' ); |
||
| 951 | $label = __( 'Field Label', 'invoicing' ); |
||
| 952 | $id = $field . '.id + "_edit"'; |
||
| 953 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 954 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 955 | $id3 = $field . '.id + "_edit3"'; |
||
| 956 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 957 | $id4 = $field . '.id + "_edit4"'; |
||
| 958 | echo " |
||
| 959 | <div $restrict> |
||
| 960 | <div class='form-group'> |
||
| 961 | <label :for='$id'>$label</label> |
||
| 962 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 963 | </div> |
||
| 964 | <div class='form-group'> |
||
| 965 | <label :for='$id3'>$label3</label> |
||
| 966 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 967 | </div> |
||
| 968 | <div class='form-group form-check'> |
||
| 969 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 970 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 971 | </div> |
||
| 972 | </div> |
||
| 973 | "; |
||
| 974 | |||
| 975 | } |
||
| 976 | |||
| 977 | /** |
||
| 978 | * Renders the number element template. |
||
| 979 | */ |
||
| 980 | public function render_number_template( $field ) { |
||
| 981 | $restrict = $this->get_restrict_markup( $field, 'number' ); |
||
| 982 | $label = "$field.label"; |
||
| 983 | echo " |
||
| 984 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 985 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 986 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 987 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='number'> |
||
| 988 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 989 | </div> |
||
| 990 | "; |
||
| 991 | } |
||
| 992 | |||
| 993 | /** |
||
| 994 | * Renders the edit number element template. |
||
| 995 | */ |
||
| 996 | public function edit_number_template( $field ) { |
||
| 997 | $restrict = $this->get_restrict_markup( $field, 'number' ); |
||
| 998 | $label = __( 'Field Label', 'invoicing' ); |
||
| 999 | $id = $field . '.id + "_edit"'; |
||
| 1000 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 1001 | $id2 = $field . '.id + "_edit2"'; |
||
| 1002 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 1003 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1004 | $id3 = $field . '.id + "_edit3"'; |
||
| 1005 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 1006 | $id4 = $field . '.id + "_edit4"'; |
||
| 1007 | echo " |
||
| 1008 | <div $restrict> |
||
| 1009 | <div class='form-group'> |
||
| 1010 | <label :for='$id'>$label</label> |
||
| 1011 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1012 | </div> |
||
| 1013 | <div class='form-group'> |
||
| 1014 | <label :for='$id2'>$label2</label> |
||
| 1015 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 1016 | </div> |
||
| 1017 | <div class='form-group'> |
||
| 1018 | <label :for='$id3'>$label3</label> |
||
| 1019 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1020 | </div> |
||
| 1021 | <div class='form-group form-check'> |
||
| 1022 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 1023 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 1024 | </div> |
||
| 1025 | </div> |
||
| 1026 | "; |
||
| 1027 | |||
| 1028 | } |
||
| 1029 | |||
| 1030 | /** |
||
| 1031 | * Renders the separator element template. |
||
| 1032 | */ |
||
| 1033 | public function render_separator_template( $field ) { |
||
| 1034 | $restrict = $this->get_restrict_markup( $field, 'separator' ); |
||
| 1035 | echo "<hr class='featurette-divider' $restrict>"; |
||
| 1036 | } |
||
| 1037 | |||
| 1038 | /** |
||
| 1039 | * Renders the pay button element template. |
||
| 1040 | */ |
||
| 1041 | public function render_pay_button_template( $field ) { |
||
| 1042 | $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
||
| 1043 | $label = "$field.label"; |
||
| 1044 | echo " |
||
| 1045 | <div $restrict> |
||
| 1046 | <button class='form-control btn submit-button' :class='$field.class' type='submit' @click.prevent=''>{{" . $label . "}}</button> |
||
| 1047 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1048 | </div> |
||
| 1049 | "; |
||
| 1050 | } |
||
| 1051 | |||
| 1052 | /** |
||
| 1053 | * Renders the pay button element template. |
||
| 1054 | */ |
||
| 1055 | public function edit_pay_button_template( $field ) { |
||
| 1056 | $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
||
| 1057 | $label = __( 'Button Text', 'invoicing' ); |
||
| 1058 | $id = $field . '.id + "_edit"'; |
||
| 1059 | $label2 = __( 'Help text', 'invoicing' ); |
||
| 1060 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1061 | $id2 = $field . '.id + "_edit2"'; |
||
| 1062 | $label4 = esc_attr__( 'Button Type', 'invoicing' ); |
||
| 1063 | $id3 = $field . '.id + "_edit3"'; |
||
| 1064 | |||
| 1065 | echo " |
||
| 1066 | <div $restrict> |
||
| 1067 | <div class='form-group'> |
||
| 1068 | <label :for='$id'>$label</label> |
||
| 1069 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1070 | </div> |
||
| 1071 | <div class='form-group'> |
||
| 1072 | <label :for='$id2'>$label2</label> |
||
| 1073 | <textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1074 | </div> |
||
| 1075 | <div class='form-group'> |
||
| 1076 | <label :for='$id3'>$label4</label> |
||
| 1077 | |||
| 1078 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
||
| 1079 | <option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
||
| 1080 | <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
||
| 1081 | <option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
||
| 1082 | <option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
||
| 1083 | <option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
||
| 1084 | <option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
||
| 1085 | <option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
||
| 1086 | <option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
||
| 1087 | <option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
||
| 1088 | </select> |
||
| 1089 | </div> |
||
| 1090 | </div> |
||
| 1091 | "; |
||
| 1092 | |||
| 1093 | } |
||
| 1094 | |||
| 1095 | /** |
||
| 1096 | * Renders the alert element template. |
||
| 1097 | */ |
||
| 1098 | public function render_alert_template( $field ) { |
||
| 1099 | $restrict = $this->get_restrict_markup( $field, 'alert' ); |
||
| 1100 | $text = "$field.text"; |
||
| 1101 | echo " |
||
| 1102 | <div $restrict class='alert' :class='$field.class' role='alert'> |
||
| 1103 | <span v-html='$text'></span> |
||
| 1104 | <button v-if='$field.dismissible' type='button' class='close' @click.prevent=''> |
||
| 1105 | <span aria-hidden='true'>×</span> |
||
| 1106 | </button> |
||
| 1107 | </div> |
||
| 1108 | "; |
||
| 1109 | } |
||
| 1110 | |||
| 1111 | /** |
||
| 1112 | * Renders the alert element template. |
||
| 1113 | */ |
||
| 1114 | public function edit_alert_template( $field ) { |
||
| 1115 | $restrict = $this->get_restrict_markup( $field, 'alert' ); |
||
| 1116 | $label = __( 'Alert Text', 'invoicing' ); |
||
| 1117 | $label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
||
| 1118 | $id = $field . '.id + "_edit"'; |
||
| 1119 | $label3 = __( 'Is Dismissible?', 'invoicing' ); |
||
| 1120 | $id2 = $field . '.id + "_edit2"'; |
||
| 1121 | $label4 = esc_attr__( 'Alert Type', 'invoicing' ); |
||
| 1122 | $id3 = $field . '.id + "_edit3"'; |
||
| 1123 | echo " |
||
| 1124 | <div $restrict> |
||
| 1125 | <div class='form-group'> |
||
| 1126 | <label :for='$id'>$label</label> |
||
| 1127 | <textarea placeholder='$label2' :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
||
| 1128 | </div> |
||
| 1129 | <div class='form-group form-check'> |
||
| 1130 | <input :id='$id2' v-model='$field.dismissible' type='checkbox' class='form-check-input' /> |
||
| 1131 | <label class='form-check-label' :for='$id2'>$label3</label> |
||
| 1132 | </div> |
||
| 1133 | <div class='form-group'> |
||
| 1134 | <label :for='$id3'>$label4</label> |
||
| 1135 | |||
| 1136 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
||
| 1137 | <option value='alert-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
||
| 1138 | <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
||
| 1139 | <option value='alert-success'>" . __( 'Success', 'invoicing' ) ."</option> |
||
| 1140 | <option value='alert-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
||
| 1141 | <option value='alert-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
||
| 1142 | <option value='alert-info'>" . __( 'Info', 'invoicing' ) ."</option> |
||
| 1143 | <option value='alert-light'>" . __( 'Light', 'invoicing' ) ."</option> |
||
| 1144 | <option value='alert-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
||
| 1145 | </select> |
||
| 1146 | </div> |
||
| 1147 | </div> |
||
| 1148 | "; |
||
| 1149 | |||
| 1150 | } |
||
| 1151 | |||
| 1152 | /** |
||
| 1153 | * Renders the discount element template. |
||
| 1154 | */ |
||
| 1155 | public function render_discount_template( $field ) { |
||
| 1156 | $restrict = $this->get_restrict_markup( $field, 'discount' ); |
||
| 1157 | ?> |
||
| 1158 | |||
| 1159 | <div <?php echo $restrict; ?> class="discount_field border rounded p-3 wpinv-payment-form-field-preview"> |
||
| 1160 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 1161 | <div class="discount_field_inner d-flex flex-column flex-md-row"> |
||
| 1162 | <input :placeholder="<?php echo $field ?>.input_label" class="form-control mr-2 mb-2" style="flex: 1;" type="text"> |
||
| 1163 | <button class="btn btn-secondary submit-button mb-2" type="submit" @click.prevent="">{{<?php echo $field; ?>.button_label}}</button> |
||
| 1164 | </div> |
||
| 1165 | <small v-if='<?php echo $field ?>.description' class='form-text text-muted' v-html='<?php echo $field ?>.description'></small> |
||
| 1166 | </div> |
||
| 1167 | |||
| 1168 | <?php |
||
| 1169 | } |
||
| 1170 | |||
| 1171 | /** |
||
| 1172 | * Renders the discount element template. |
||
| 1173 | */ |
||
| 1174 | public function edit_discount_template( $field ) { |
||
| 1175 | $restrict = $this->get_restrict_markup( $field, 'discount' ); |
||
| 1176 | $label = __( 'Discount Input Placeholder', 'invoicing' ); |
||
| 1177 | $label2 = __( 'Help Text', 'invoicing' ); |
||
| 1178 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1179 | $label4 = __( 'Button Text', 'invoicing' ); |
||
| 1180 | $id = $field . '.id + "_edit"'; |
||
| 1181 | $id2 = $field . '.id + "_edit2"'; |
||
| 1182 | $id3 = $field . '.id + "_edit3"'; |
||
| 1183 | echo " |
||
| 1184 | <div $restrict> |
||
| 1185 | <div class='form-group'> |
||
| 1186 | <label :for='$id'>$label</label> |
||
| 1187 | <input :id='$id' v-model='$field.input_label' class='form-control' /> |
||
| 1188 | </div> |
||
| 1189 | |||
| 1190 | <div class='form-group'> |
||
| 1191 | <label :for='$id2'>$label4</label> |
||
| 1192 | <input :id='$id2' v-model='$field.button_label' class='form-control' /> |
||
| 1193 | </div> |
||
| 1194 | |||
| 1195 | <div class='form-group'> |
||
| 1196 | <label :for='$id3'>$label2</label> |
||
| 1197 | <textarea placeholder='$label3' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1198 | </div> |
||
| 1199 | |||
| 1200 | </div> |
||
| 1201 | "; |
||
| 1202 | |||
| 1203 | } |
||
| 1204 | |||
| 1205 | /** |
||
| 1206 | * Renders the items element template. |
||
| 1207 | */ |
||
| 1208 | public function render_items_template( $field ) { |
||
| 1209 | $restrict = $this->get_restrict_markup( $field, 'items' ); |
||
| 1210 | ?> |
||
| 1211 | |||
| 1212 | <div <?php echo $restrict; ?> class='item_totals'> |
||
| 1213 | <div v-if='!is_default'> |
||
| 1214 | <div v-if='! canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here. Click to set items.', 'invoicing' ) ?></div> |
||
| 1215 | <div v-if='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-danger' role='alert'><?php _e( 'Your form allows customers to buy several recurring items. This is not supported and might lead to unexpected behaviour.', 'invoicing' ); ?></div> |
||
| 1216 | </div> |
||
| 1217 | <div v-if='is_default'> |
||
| 1218 | <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here.', 'invoicing' ) ?></div> |
||
| 1219 | </div> |
||
| 1220 | </div> |
||
| 1221 | |||
| 1222 | <?php |
||
| 1223 | } |
||
| 1224 | |||
| 1225 | /** |
||
| 1226 | * Renders the items element on the frontend. |
||
| 1227 | */ |
||
| 1228 | public function frontend_render_items_template( $field, $items ) { |
||
| 1229 | $tax = 0; |
||
| 1230 | $sub_total = 0; |
||
| 1231 | $total = 0; |
||
| 1232 | |||
| 1233 | ?> |
||
| 1234 | |||
| 1235 | <?php |
||
| 1236 | echo "<div class='form-group item_totals'>"; |
||
| 1237 | |||
| 1238 | $id = esc_attr( $field['id'] ); |
||
| 1239 | |||
| 1240 | if ( empty( $field[ 'items_type' ] ) ) { |
||
| 1241 | $field[ 'items_type' ] = 'total'; |
||
| 1242 | } |
||
| 1243 | |||
| 1244 | if ( 'radio' == $field[ 'items_type' ] ) { ?> |
||
| 1245 | <div class="item_totals_type_radio"> |
||
| 1246 | |||
| 1247 | <?php |
||
| 1248 | foreach( $items as $index => $item ) { |
||
| 1249 | |||
| 1250 | if ( ! empty( $item['required'] ) ) { |
||
| 1251 | continue; |
||
| 1252 | } |
||
| 1253 | ?> |
||
| 1254 | <div class="form-check"> |
||
| 1255 | <input class='form-check-input wpinv-items-selector' <?php checked( ! isset( $selected_radio_item ) ); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'> |
||
| 1256 | <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?> <strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); ?></strong></label> |
||
| 1257 | </div> |
||
| 1258 | <?php if ( ! empty( $item['description'] )) { ?> |
||
| 1259 | <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
||
| 1260 | <?php } ?> |
||
| 1261 | <?php } ?> |
||
| 1262 | |||
| 1263 | <div class="mt-3 border item_totals_type_radio_totals"> |
||
| 1264 | |||
| 1265 | <?php |
||
| 1266 | |||
| 1267 | $total = 0; |
||
| 1268 | $tax = 0; |
||
| 1269 | $sub_total = 0; |
||
| 1270 | |||
| 1271 | foreach ( $items as $item ) { |
||
| 1272 | |||
| 1273 | $class = 'col-8'; |
||
| 1274 | $class2 = ''; |
||
| 1275 | |||
| 1276 | if ( ! empty( $item['allow_quantities'] ) ) { |
||
| 1277 | $class = 'col-6 pt-2'; |
||
| 1278 | $class2 = 'pt-2'; |
||
| 1279 | } |
||
| 1280 | |||
| 1281 | if ( ! empty( $item['custom_price'] ) ) { |
||
| 1282 | $class .= ' pt-2'; |
||
| 1283 | } |
||
| 1284 | |||
| 1285 | $class3 = 'd-none'; |
||
| 1286 | $name = ''; |
||
| 1287 | if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) { |
||
| 1288 | |||
| 1289 | $amount = floatval( $item['price'] ); |
||
| 1290 | |||
| 1291 | if ( wpinv_use_taxes() ) { |
||
| 1292 | |||
| 1293 | $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] ); |
||
| 1294 | |||
| 1295 | if ( wpinv_prices_include_tax() ) { |
||
| 1296 | $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
||
| 1297 | $item_tax = $amount - $pre_tax; |
||
| 1298 | } else { |
||
| 1299 | $pre_tax = $amount; |
||
| 1300 | $item_tax = $amount * $rate * 0.01; |
||
| 1301 | } |
||
| 1302 | |||
| 1303 | $tax = $tax + $item_tax; |
||
| 1304 | $sub_total = $sub_total + $pre_tax; |
||
| 1305 | $total = $sub_total + $tax; |
||
| 1306 | |||
| 1307 | } else { |
||
| 1308 | $total = $total + $amount; |
||
| 1309 | } |
||
| 1310 | |||
| 1311 | $class3 = ''; |
||
| 1312 | $name = "wpinv-items[{$item['id']}]"; |
||
| 1313 | |||
| 1314 | if ( empty( $item['required'] ) ) { |
||
| 1315 | $totals_selected_radio_item = 1; |
||
| 1316 | } |
||
| 1317 | |||
| 1318 | } |
||
| 1319 | |||
| 1320 | $class3 .= " wpinv_item_{$item['id']}"; |
||
| 1321 | |||
| 1322 | ?> |
||
| 1323 | |||
| 1324 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
||
| 1325 | <div class='row pl-2 pr-2 pt-2'> |
||
| 1326 | <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div> |
||
| 1327 | |||
| 1328 | <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
||
| 1329 | |||
| 1330 | <div class='col-2'> |
||
| 1331 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
||
| 1332 | </div> |
||
| 1333 | |||
| 1334 | <?php } else { ?> |
||
| 1335 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
||
| 1336 | <?php } if ( empty( $item['custom_price'] ) ) { ?> |
||
| 1337 | |||
| 1338 | <div class='col-4 <?php echo $class2; ?>'> |
||
| 1339 | <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
||
| 1340 | <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
||
| 1341 | </div> |
||
| 1342 | |||
| 1343 | <?php } else {?> |
||
| 1344 | |||
| 1345 | <div class='col-4'> |
||
| 1346 | <div class='input-group'> |
||
| 1347 | |||
| 1348 | <?php if ( 'left' == wpinv_currency_position() ) { ?> |
||
| 1349 | <div class='input-group-prepend'> |
||
| 1350 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1351 | </div> |
||
| 1352 | <?php } ?> |
||
| 1353 | |||
| 1354 | <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
||
| 1355 | |||
| 1356 | <?php if ( 'left' != wpinv_currency_position() ) { ?> |
||
| 1357 | <div class='input-group-append'> |
||
| 1358 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1359 | </div> |
||
| 1360 | <?php } ?> |
||
| 1361 | |||
| 1362 | </div> |
||
| 1363 | </div> |
||
| 1364 | <?php } ?> |
||
| 1365 | |||
| 1366 | </div> |
||
| 1367 | <?php if ( ! empty( $item['description'] )) { ?> |
||
| 1368 | <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
||
| 1369 | <?php } ?> |
||
| 1370 | </div> |
||
| 1371 | <?php } ?> |
||
| 1372 | |||
| 1373 | <div class='mt-4 border-top item_totals_total p-2'> |
||
| 1374 | |||
| 1375 | <div class='row'> |
||
| 1376 | <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
||
| 1377 | <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
||
| 1378 | </div> |
||
| 1379 | |||
| 1380 | <div class='row' style='display: none;'> |
||
| 1381 | <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div> |
||
| 1382 | <div class='col-4'><strong class='wpinv-items-discount'></strong></div> |
||
| 1383 | </div> |
||
| 1384 | |||
| 1385 | <?php if ( wpinv_use_taxes() ) { ?> |
||
| 1386 | <div class='row'> |
||
| 1387 | <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
||
| 1388 | <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
||
| 1389 | </div> |
||
| 1390 | <?php } ?> |
||
| 1391 | |||
| 1392 | <div class='row'> |
||
| 1393 | <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
||
| 1394 | <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
||
| 1395 | </div> |
||
| 1396 | </div> |
||
| 1397 | |||
| 1398 | </div> |
||
| 1399 | </div> |
||
| 1400 | <?php } ?> |
||
| 1401 | |||
| 1402 | <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?> |
||
| 1403 | |||
| 1404 | <div class="item_totals_type_checkbox"> |
||
| 1405 | |||
| 1406 | <?php |
||
| 1407 | foreach ( $items as $index => $item ) { |
||
| 1408 | |||
| 1409 | if ( ! empty( $item['required'] ) ) { |
||
| 1410 | continue; |
||
| 1411 | } |
||
| 1412 | |||
| 1413 | $title = sanitize_text_field( $item['title'] ); |
||
| 1414 | $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
||
| 1415 | $item_id = esc_attr( $id . "_$index" ); |
||
| 1416 | $value = esc_attr( $item['id'] ); |
||
| 1417 | $checked = checked( ! isset( $selected_checkbox_item ), true, false ); |
||
| 1418 | $selected_checkbox_item = 1; |
||
| 1419 | |||
| 1420 | echo " |
||
| 1421 | <div class='custom-control custom-checkbox'> |
||
| 1422 | <input type='checkbox' name='payment-form-items[]' id='$item_id' value='$value' class='wpi-payment-form-items-select-checkbox form-control custom-control-input' $checked> |
||
| 1423 | <label for='$item_id' class='custom-control-label'>$title ($price)</label> |
||
| 1424 | </div>"; |
||
| 1425 | |||
| 1426 | if ( ! empty( $item['description'] ) ) { |
||
| 1427 | echo "<small class='form-text text-muted'>{$item['description']}</small>"; |
||
| 1428 | } |
||
| 1429 | } |
||
| 1430 | ?> |
||
| 1431 | |||
| 1432 | <div class="mt-3 border item_totals_type_checkbox_totals"> |
||
| 1433 | |||
| 1434 | <?php |
||
| 1435 | |||
| 1436 | $total = 0; |
||
| 1437 | $tax = 0; |
||
| 1438 | $sub_total = 0; |
||
| 1439 | |||
| 1440 | foreach ( $items as $item ) { |
||
| 1441 | |||
| 1442 | $class = 'col-8'; |
||
| 1443 | $class2 = ''; |
||
| 1444 | |||
| 1445 | if ( ! empty( $item['allow_quantities'] ) ) { |
||
| 1446 | $class = 'col-6 pt-2'; |
||
| 1447 | $class2 = 'pt-2'; |
||
| 1448 | } |
||
| 1449 | |||
| 1450 | if ( ! empty( $item['custom_price'] ) ) { |
||
| 1451 | $class .= ' pt-2'; |
||
| 1452 | } |
||
| 1453 | |||
| 1454 | $class3 = 'd-none'; |
||
| 1455 | $name = ''; |
||
| 1456 | if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) { |
||
| 1457 | |||
| 1458 | $amount = floatval( $item['price'] ); |
||
| 1459 | if ( wpinv_use_taxes() ) { |
||
| 1460 | |||
| 1461 | $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] ); |
||
| 1462 | |||
| 1463 | if ( wpinv_prices_include_tax() ) { |
||
| 1464 | $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
||
| 1465 | $item_tax = $amount - $pre_tax; |
||
| 1466 | } else { |
||
| 1467 | $pre_tax = $amount; |
||
| 1468 | $item_tax = $amount * $rate * 0.01; |
||
| 1469 | } |
||
| 1470 | |||
| 1471 | $tax = $tax + $item_tax; |
||
| 1472 | $sub_total = $sub_total + $pre_tax; |
||
| 1473 | $total = $sub_total + $tax; |
||
| 1474 | |||
| 1475 | } else { |
||
| 1476 | $total = $total + $amount; |
||
| 1477 | } |
||
| 1478 | |||
| 1479 | $class3 = ''; |
||
| 1480 | $name = "wpinv-items[{$item['id']}]"; |
||
| 1481 | |||
| 1482 | if ( empty( $item['required'] ) ) { |
||
| 1483 | $totals_selected_checkbox_item = 1; |
||
| 1484 | } |
||
| 1485 | |||
| 1486 | } |
||
| 1487 | |||
| 1488 | $class3 .= " wpinv_item_{$item['id']}"; |
||
| 1489 | |||
| 1490 | ?> |
||
| 1491 | |||
| 1492 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
||
| 1493 | <div class='row pl-2 pr-2 pt-2'> |
||
| 1494 | <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div> |
||
| 1495 | |||
| 1496 | <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
||
| 1497 | |||
| 1498 | <div class='col-2'> |
||
| 1499 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
||
| 1500 | </div> |
||
| 1501 | |||
| 1502 | <?php } else { ?> |
||
| 1503 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
||
| 1504 | <?php } if ( empty( $item['custom_price'] ) ) { ?> |
||
| 1505 | |||
| 1506 | <div class='col-4 <?php echo $class2; ?>'> |
||
| 1507 | <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
||
| 1508 | <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
||
| 1509 | </div> |
||
| 1510 | |||
| 1511 | <?php } else {?> |
||
| 1512 | |||
| 1513 | <div class='col-4'> |
||
| 1514 | <div class='input-group'> |
||
| 1515 | |||
| 1516 | <?php if ( 'left' == wpinv_currency_position() ) { ?> |
||
| 1517 | <div class='input-group-prepend'> |
||
| 1518 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1519 | </div> |
||
| 1520 | <?php } ?> |
||
| 1521 | |||
| 1522 | <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
||
| 1523 | |||
| 1524 | <?php if ( 'left' != wpinv_currency_position() ) { ?> |
||
| 1525 | <div class='input-group-append'> |
||
| 1526 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1527 | </div> |
||
| 1528 | <?php } ?> |
||
| 1529 | |||
| 1530 | </div> |
||
| 1531 | </div> |
||
| 1532 | <?php } ?> |
||
| 1533 | |||
| 1534 | </div> |
||
| 1535 | <?php if ( ! empty( $item['description'] )) { ?> |
||
| 1536 | <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
||
| 1537 | <?php } ?> |
||
| 1538 | </div> |
||
| 1539 | <?php } ?> |
||
| 1540 | |||
| 1541 | <div class='mt-4 border-top item_totals_total p-2'> |
||
| 1542 | |||
| 1543 | <div class='row'> |
||
| 1544 | <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
||
| 1545 | <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
||
| 1546 | </div> |
||
| 1547 | |||
| 1548 | <div class='row' style='display: none;'> |
||
| 1549 | <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div> |
||
| 1550 | <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div> |
||
| 1551 | </div> |
||
| 1552 | |||
| 1553 | <?php if ( wpinv_use_taxes() ) { ?> |
||
| 1554 | <div class='row'> |
||
| 1555 | <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
||
| 1556 | <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
||
| 1557 | </div> |
||
| 1558 | <?php } ?> |
||
| 1559 | |||
| 1560 | <div class='row'> |
||
| 1561 | <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
||
| 1562 | <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
||
| 1563 | </div> |
||
| 1564 | </div> |
||
| 1565 | </div> |
||
| 1566 | </div> |
||
| 1567 | <?php } ?> |
||
| 1568 | |||
| 1569 | <?php if ( 'select' == $field[ 'items_type' ] ) { ?> |
||
| 1570 | |||
| 1571 | <div class="item_totals_type_select"> |
||
| 1572 | |||
| 1573 | <?php |
||
| 1574 | |||
| 1575 | $options = array(); |
||
| 1576 | $selected = ''; |
||
| 1577 | foreach ( $items as $index => $item ) { |
||
| 1578 | |||
| 1579 | if ( ! empty( $item['required'] ) ) { |
||
| 1580 | continue; |
||
| 1581 | } |
||
| 1582 | |||
| 1583 | $title = sanitize_text_field( $item['title'] ); |
||
| 1584 | $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
||
| 1585 | $options[ $item['id'] ] = "$title ($price)"; |
||
| 1586 | |||
| 1587 | if ( ! isset( $selected_item ) ) { |
||
| 1588 | $selected = $item['id']; |
||
| 1589 | $selected_item = 1; |
||
| 1590 | } |
||
| 1591 | |||
| 1592 | } |
||
| 1593 | |||
| 1594 | echo aui()->select( |
||
| 1595 | array( |
||
| 1596 | 'name' => 'payment-form-items', |
||
| 1597 | 'id' => $id, |
||
| 1598 | 'placeholder' => __( 'Select an item', 'invoicing' ), |
||
| 1599 | 'no_wrap' => true, |
||
| 1600 | 'options' => $options, |
||
| 1601 | 'class' => 'wpi_select2 wpinv-items-select-selector', |
||
| 1602 | 'value' => $selected, |
||
| 1603 | ) |
||
| 1604 | ); |
||
| 1605 | ?> |
||
| 1606 | |||
| 1607 | <div class="mt-3 border item_totals_type_select_totals"> |
||
| 1608 | |||
| 1609 | <?php |
||
| 1610 | |||
| 1611 | $total = 0; |
||
| 1612 | $tax = 0; |
||
| 1613 | $sub_total = 0; |
||
| 1614 | |||
| 1615 | foreach ( $items as $item ) { |
||
| 1616 | |||
| 1617 | $class = 'col-8'; |
||
| 1618 | $class2 = ''; |
||
| 1619 | |||
| 1620 | if ( ! empty( $item['allow_quantities'] ) ) { |
||
| 1621 | $class = 'col-6 pt-2'; |
||
| 1622 | $class2 = 'pt-2'; |
||
| 1623 | } |
||
| 1624 | |||
| 1625 | if ( ! empty( $item['custom_price'] ) ) { |
||
| 1626 | $class .= ' pt-2'; |
||
| 1627 | } |
||
| 1628 | |||
| 1629 | $class3 = 'd-none'; |
||
| 1630 | $name = ''; |
||
| 1631 | if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) { |
||
| 1632 | |||
| 1633 | $amount = floatval( $item['price'] ); |
||
| 1634 | if ( wpinv_use_taxes() ) { |
||
| 1635 | |||
| 1636 | $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] ); |
||
| 1637 | |||
| 1638 | if ( wpinv_prices_include_tax() ) { |
||
| 1639 | $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
||
| 1640 | $item_tax = $amount - $pre_tax; |
||
| 1641 | } else { |
||
| 1642 | $pre_tax = $amount; |
||
| 1643 | $item_tax = $amount * $rate * 0.01; |
||
| 1644 | } |
||
| 1645 | |||
| 1646 | $tax = $tax + $item_tax; |
||
| 1647 | $sub_total = $sub_total + $pre_tax; |
||
| 1648 | $total = $sub_total + $tax; |
||
| 1649 | |||
| 1650 | } else { |
||
| 1651 | $total = $total + $amount; |
||
| 1652 | } |
||
| 1653 | |||
| 1654 | $class3 = ''; |
||
| 1655 | $name = "wpinv-items[{$item['id']}]"; |
||
| 1656 | |||
| 1657 | if ( empty( $item['required'] ) ) { |
||
| 1658 | $totals_selected_select_item = 1; |
||
| 1659 | } |
||
| 1660 | |||
| 1661 | } |
||
| 1662 | |||
| 1663 | $class3 .= " wpinv_item_{$item['id']}"; |
||
| 1664 | |||
| 1665 | ?> |
||
| 1666 | |||
| 1667 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
||
| 1668 | <div class='row pl-2 pr-2 pt-2'> |
||
| 1669 | <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div> |
||
| 1670 | |||
| 1671 | <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
||
| 1672 | |||
| 1673 | <div class='col-2'> |
||
| 1674 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
||
| 1675 | </div> |
||
| 1676 | |||
| 1677 | <?php } else { ?> |
||
| 1678 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
||
| 1679 | <?php } if ( empty( $item['custom_price'] ) ) { ?> |
||
| 1680 | |||
| 1681 | <div class='col-4 <?php echo $class2; ?>'> |
||
| 1682 | <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
||
| 1683 | <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
||
| 1684 | </div> |
||
| 1685 | |||
| 1686 | <?php } else {?> |
||
| 1687 | |||
| 1688 | <div class='col-4'> |
||
| 1689 | <div class='input-group'> |
||
| 1690 | |||
| 1691 | <?php if ( 'left' == wpinv_currency_position() ) { ?> |
||
| 1692 | <div class='input-group-prepend'> |
||
| 1693 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1694 | </div> |
||
| 1695 | <?php } ?> |
||
| 1696 | |||
| 1697 | <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
||
| 1698 | |||
| 1699 | <?php if ( 'left' != wpinv_currency_position() ) { ?> |
||
| 1700 | <div class='input-group-append'> |
||
| 1701 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1702 | </div> |
||
| 1703 | <?php } ?> |
||
| 1704 | |||
| 1705 | </div> |
||
| 1706 | </div> |
||
| 1707 | <?php } ?> |
||
| 1708 | |||
| 1709 | </div> |
||
| 1710 | <?php if ( ! empty( $item['description'] )) { ?> |
||
| 1711 | <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
||
| 1712 | <?php } ?> |
||
| 1713 | </div> |
||
| 1714 | <?php } ?> |
||
| 1715 | |||
| 1716 | <div class='mt-4 border-top item_totals_total p-2'> |
||
| 1717 | |||
| 1718 | <div class='row'> |
||
| 1719 | <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
||
| 1720 | <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
||
| 1721 | </div> |
||
| 1722 | |||
| 1723 | <div class='row' style='display: none;'> |
||
| 1724 | <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div> |
||
| 1725 | <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div> |
||
| 1726 | </div> |
||
| 1727 | |||
| 1728 | <?php if ( wpinv_use_taxes() ) { ?> |
||
| 1729 | <div class='row'> |
||
| 1730 | <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
||
| 1731 | <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
||
| 1732 | </div> |
||
| 1733 | <?php } ?> |
||
| 1734 | <div class='row'> |
||
| 1735 | <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
||
| 1736 | <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
||
| 1737 | </div> |
||
| 1738 | </div> |
||
| 1739 | |||
| 1740 | </div> |
||
| 1741 | <?php } ?> |
||
| 1742 | |||
| 1743 | <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?> |
||
| 1744 | |||
| 1745 | <div class="item_totals_type_multi_select"> |
||
| 1746 | |||
| 1747 | <?php |
||
| 1748 | |||
| 1749 | $options = array(); |
||
| 1750 | $selected = array(); |
||
| 1751 | |||
| 1752 | foreach ( $items as $index => $item ) { |
||
| 1753 | |||
| 1754 | if ( ! empty( $item['required'] ) ) { |
||
| 1755 | continue; |
||
| 1756 | } |
||
| 1757 | |||
| 1758 | $title = sanitize_text_field( $item['title'] ); |
||
| 1759 | $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
||
| 1760 | $options[ $item['id'] ] = "$title ($price)"; |
||
| 1761 | |||
| 1762 | if ( ! isset( $selected_item ) ) { |
||
| 1763 | $selected = array( $item['id'] ); |
||
| 1764 | $selected_item = 1; |
||
| 1765 | } |
||
| 1766 | |||
| 1767 | } |
||
| 1768 | |||
| 1769 | echo aui()->select( |
||
| 1770 | array( |
||
| 1771 | 'name' => 'payment-form-items', |
||
| 1772 | 'id' => $id, |
||
| 1773 | 'no_wrap' => true, |
||
| 1774 | 'options' => $options, |
||
| 1775 | 'multiple' => true, |
||
| 1776 | 'class' => 'wpi_select2 wpinv-items-multiselect-selector', |
||
| 1777 | 'value' => $selected, |
||
| 1778 | ) |
||
| 1779 | ); |
||
| 1780 | ?> |
||
| 1781 | |||
| 1782 | <div class="mt-3 border item_totals_type_select_totals"> |
||
| 1783 | |||
| 1784 | <?php |
||
| 1785 | |||
| 1786 | $total = 0; |
||
| 1787 | $tax = 0; |
||
| 1788 | $sub_total = 0; |
||
| 1789 | |||
| 1790 | foreach ( $items as $item ) { |
||
| 1791 | |||
| 1792 | $class = 'col-8'; |
||
| 1793 | $class2 = ''; |
||
| 1794 | |||
| 1795 | if ( ! empty( $item['allow_quantities'] ) ) { |
||
| 1796 | $class = 'col-6 pt-2'; |
||
| 1797 | $class2 = 'pt-2'; |
||
| 1798 | } |
||
| 1799 | |||
| 1800 | if ( ! empty( $item['custom_price'] ) ) { |
||
| 1801 | $class .= ' pt-2'; |
||
| 1802 | } |
||
| 1803 | |||
| 1804 | $class3 = 'd-none'; |
||
| 1805 | $name = ''; |
||
| 1806 | if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) { |
||
| 1807 | |||
| 1808 | $amount = floatval( $item['price'] ); |
||
| 1809 | if ( wpinv_use_taxes() ) { |
||
| 1810 | |||
| 1811 | $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] ); |
||
| 1812 | |||
| 1813 | if ( wpinv_prices_include_tax() ) { |
||
| 1814 | $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
||
| 1815 | $item_tax = $amount - $pre_tax; |
||
| 1816 | } else { |
||
| 1817 | $pre_tax = $amount; |
||
| 1818 | $item_tax = $amount * $rate * 0.01; |
||
| 1819 | } |
||
| 1820 | |||
| 1821 | $tax = $tax + $item_tax; |
||
| 1822 | $sub_total = $sub_total + $pre_tax; |
||
| 1823 | $total = $sub_total + $tax; |
||
| 1824 | |||
| 1825 | } else { |
||
| 1826 | $total = $total + $amount; |
||
| 1827 | } |
||
| 1828 | |||
| 1829 | $class3 = ''; |
||
| 1830 | $name = "wpinv-items[{$item['id']}]"; |
||
| 1831 | |||
| 1832 | if ( empty( $item['required'] ) ) { |
||
| 1833 | $totals_selected_select_item = 1; |
||
| 1834 | } |
||
| 1835 | |||
| 1836 | } |
||
| 1837 | |||
| 1838 | $class3 .= " wpinv_item_{$item['id']}"; |
||
| 1839 | |||
| 1840 | ?> |
||
| 1841 | |||
| 1842 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
||
| 1843 | <div class='row pl-2 pr-2 pt-2'> |
||
| 1844 | <div class='<?php echo $class; ?>'><?php echo sanitize_text_field( $item['title'] ) ?></div> |
||
| 1845 | |||
| 1846 | <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
||
| 1847 | |||
| 1848 | <div class='col-2'> |
||
| 1849 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
||
| 1850 | </div> |
||
| 1851 | |||
| 1852 | <?php } else { ?> |
||
| 1853 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
||
| 1854 | <?php } if ( empty( $item['custom_price'] ) ) { ?> |
||
| 1855 | |||
| 1856 | <div class='col-4 <?php echo $class2; ?>'> |
||
| 1857 | <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
||
| 1858 | <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
||
| 1859 | </div> |
||
| 1860 | |||
| 1861 | <?php } else {?> |
||
| 1862 | |||
| 1863 | <div class='col-4'> |
||
| 1864 | <div class='input-group'> |
||
| 1865 | |||
| 1866 | <?php if ( 'left' == wpinv_currency_position() ) { ?> |
||
| 1867 | <div class='input-group-prepend'> |
||
| 1868 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1869 | </div> |
||
| 1870 | <?php } ?> |
||
| 1871 | |||
| 1872 | <input type='text' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
||
| 1873 | |||
| 1874 | <?php if ( 'left' != wpinv_currency_position() ) { ?> |
||
| 1875 | <div class='input-group-append'> |
||
| 1876 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
||
| 1877 | </div> |
||
| 1878 | <?php } ?> |
||
| 1879 | |||
| 1880 | </div> |
||
| 1881 | </div> |
||
| 1882 | <?php } ?> |
||
| 1883 | |||
| 1884 | </div> |
||
| 1885 | <?php if ( ! empty( $item['description'] )) { ?> |
||
| 1886 | <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
||
| 1887 | <?php } ?> |
||
| 1888 | </div> |
||
| 1889 | <?php } ?> |
||
| 1890 | |||
| 1891 | <div class='mt-4 border-top item_totals_total p-2'> |
||
| 1892 | |||
| 1893 | <div class='row'> |
||
| 1894 | <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
||
| 1895 | <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
||
| 1896 | </div> |
||
| 1897 | |||
| 1898 | <div class='row' style='display: none;'> |
||
| 1899 | <div class='col-8'><strong class='mr-5'><?php _e( 'Discount', 'invoicing' ); ?></strong></div> |
||
| 1900 | <div class='col-4'><strong class='wpinv-items-discount'><?php echo wpinv_price( wpinv_format_amount( 0 ) ) ?></strong></div> |
||
| 1901 | </div> |
||
| 1902 | |||
| 1903 | <?php if ( wpinv_use_taxes() ) { ?> |
||
| 1904 | <div class='row'> |
||
| 1905 | <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
||
| 1906 | <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
||
| 1907 | </div> |
||
| 1908 | <?php } ?> |
||
| 1909 | |||
| 1910 | <div class='row'> |
||
| 1911 | <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
||
| 1912 | <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
||
| 1913 | </div> |
||
| 1914 | </div> |
||
| 1915 | |||
| 1916 | </div> |
||
| 1917 | <?php } ?> |
||
| 1918 | <?php if ( ! empty( $field[ 'description' ] ) ) { ?> |
||
| 1919 | <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small> |
||
| 1920 | <?php } ?> |
||
| 1921 | </div> |
||
| 1922 | <?php |
||
| 1923 | } |
||
| 1924 | |||
| 1925 | /** |
||
| 1926 | * Renders the items element template. |
||
| 1927 | */ |
||
| 1928 | public function edit_items_template( $field ) { |
||
| 1929 | global $wpinv_euvat, $post; |
||
| 1930 | |||
| 1931 | $restrict = $this->get_restrict_markup( $field, 'items' ); |
||
| 1932 | $id2 = $field . '.id + "_edit2"'; |
||
| 1933 | $id3 = $field . '.id + "_edit3"'; |
||
| 1934 | |||
| 1935 | // Item types. |
||
| 1936 | $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
||
| 1937 | |||
| 1938 | ?> |
||
| 1939 | <div <?php echo $restrict; ?>> |
||
| 1940 | <div v-if="!is_default"> |
||
| 1941 | <label class='form-group'> |
||
| 1942 | <input v-model='<?php echo $field; ?>.hide_cart' type='checkbox' /> |
||
| 1943 | <span class='form-check-label'><?php _e( 'Hide cart details', 'invoicing' ); ?></span> |
||
| 1944 | </label> |
||
| 1945 | |||
| 1946 | <div class="mb-1"><?php _e( 'Form Items', 'invoicing' ); ?></div> |
||
| 1947 | <draggable v-model='form_items' group='selectable_form_items'> |
||
| 1948 | <div class='wpinv-available-items-editor' v-for='(item, index) in form_items' :class="'item_' + item.id" :key="item.id"> |
||
| 1949 | |||
| 1950 | <div class='wpinv-available-items-editor-header' @click.prevent='togglePanel(item.id)'> |
||
| 1951 | <span class='label'>{{item.title}}</span> |
||
| 1952 | <span class='price'>({{formatPrice(item.price)}})</span> |
||
| 1953 | <span class='toggle-icon'> |
||
| 1954 | <span class='dashicons dashicons-arrow-down'></span> |
||
| 1955 | <span class='dashicons dashicons-arrow-up' style='display:none'></span> |
||
| 1956 | </span> |
||
| 1957 | </div> |
||
| 1958 | |||
| 1959 | <div class='wpinv-available-items-editor-body'> |
||
| 1960 | <div class='p-3'> |
||
| 1961 | |||
| 1962 | <div class="form-group" v-if="! item.new"> |
||
| 1963 | <span class='form-text'> |
||
| 1964 | <a target="_blank" :href="'<?php echo esc_url( admin_url( '/post.php?action=edit&post' ) ) ?>=' + item.id"> |
||
| 1965 | <?php _e( 'Edit the item name, price and other details', 'invoicing' ); ?> |
||
| 1966 | </a> |
||
| 1967 | </span> |
||
| 1968 | </div> |
||
| 1969 | |||
| 1970 | <div class='form-group' v-if="item.new"> |
||
| 1971 | <label class='mb-0 w-100'> |
||
| 1972 | <span><?php _e( 'Item Name', 'invoicing' ); ?></span> |
||
| 1973 | <input v-model='item.title' type='text' class='w-100'/> |
||
| 1974 | </label> |
||
| 1975 | </div> |
||
| 1976 | |||
| 1977 | <div class='form-group' v-if="item.new"> |
||
| 1978 | <label class='mb-0 w-100'> |
||
| 1979 | <span v-if='!item.custom_price'><?php _e( 'Item Price', 'invoicing' ); ?></span> |
||
| 1980 | <span v-if='item.custom_price'><?php _e( 'Recommended Price', 'invoicing' ); ?></span> |
||
| 1981 | <input v-model='item.price' type='text' class='w-100'/> |
||
| 1982 | </label> |
||
| 1983 | </div> |
||
| 1984 | |||
| 1985 | <div class='form-group' v-if='item.new'> |
||
| 1986 | <label :for="'edit_item_type' + item.id" class='mb-0 w-100'> |
||
| 1987 | <span><?php _e( 'Item Type', 'invoicing' ); ?></span> |
||
| 1988 | <select class='w-100' v-model='item.type'> |
||
| 1989 | <?php |
||
| 1990 | foreach ( $item_types as $type => $_label ) { |
||
| 1991 | $type = esc_attr( $type ); |
||
| 1992 | $_label = esc_html( $_label ); |
||
| 1993 | echo "<option value='$type'>$_label</type>"; |
||
| 1994 | } |
||
| 1995 | ?> |
||
| 1996 | </select> |
||
| 1997 | </label> |
||
| 1998 | </div> |
||
| 1999 | |||
| 2000 | <div v-if='item.new'> |
||
| 2001 | <?php if ( $wpinv_euvat->allow_vat_rules() ) : ?> |
||
| 2002 | <div class='form-group'> |
||
| 2003 | <label class='w-100 mb-0'><?php _e( 'VAT Rule', 'invoicing' ) ; ?> |
||
| 2004 | <select class='w-100' v-model='item.rule'> |
||
| 2005 | <?php |
||
| 2006 | foreach ( $wpinv_euvat->get_rules() as $type => $_label ) { |
||
| 2007 | $type = esc_attr( $type ); |
||
| 2008 | $_label = esc_html( $_label ); |
||
| 2009 | echo "<option value='$type'>$_label</type>"; |
||
| 2010 | } |
||
| 2011 | ?> |
||
| 2012 | </select> |
||
| 2013 | </label> |
||
| 2014 | </div> |
||
| 2015 | <?php endif;?> |
||
| 2016 | |||
| 2017 | <?php if ( $wpinv_euvat->allow_vat_classes() ) : ?> |
||
| 2018 | <div class='form-group'> |
||
| 2019 | <label class='w-100 mb-0'><?php _e( 'VAT class', 'invoicing' ) ; ?> |
||
| 2020 | <select class='w-100' v-model='item.class'> |
||
| 2021 | <?php |
||
| 2022 | foreach ( $wpinv_euvat->get_all_classes() as $type => $_label ) { |
||
| 2023 | $type = esc_attr( $type ); |
||
| 2024 | $_label = esc_html( $_label ); |
||
| 2025 | echo "<option value='$type'>$_label</type>"; |
||
| 2026 | } |
||
| 2027 | ?> |
||
| 2028 | </select> |
||
| 2029 | </label> |
||
| 2030 | </div> |
||
| 2031 | <?php endif;?> |
||
| 2032 | |||
| 2033 | </div> |
||
| 2034 | |||
| 2035 | <label v-if='item.new' class='form-group'> |
||
| 2036 | <input v-model='item.custom_price' type='checkbox' /> |
||
| 2037 | <span class='form-check-label'><?php _e( 'Allow users to pay what they want', 'invoicing' ); ?></span> |
||
| 2038 | </label> |
||
| 2039 | |||
| 2040 | <div class='form-group' v-if='item.new && item.custom_price'> |
||
| 2041 | <label class='mb-0 w-100'> |
||
| 2042 | <span><?php _e( 'Minimum Price', 'invoicing' ); ?></span> |
||
| 2043 | <input placeholder='0.00' v-model='item.minimum_price' class='w-100' /> |
||
| 2044 | <small class='form-text text-muted'><?php _e( 'Enter the minimum price that a user can pay', 'invoicing' ); ?></small> |
||
| 2045 | </label> |
||
| 2046 | </div> |
||
| 2047 | |||
| 2048 | <label class='form-group'> |
||
| 2049 | <input v-model='item.allow_quantities' type='checkbox' /> |
||
| 2050 | <span><?php _e( 'Allow users to buy several quantities', 'invoicing' ); ?></span> |
||
| 2051 | </label> |
||
| 2052 | |||
| 2053 | <label class='form-group'> |
||
| 2054 | <input v-model='item.required' type='checkbox' /> |
||
| 2055 | <span><?php _e( 'This item is required', 'invoicing' ); ?></span> |
||
| 2056 | </label> |
||
| 2057 | |||
| 2058 | <div class='form-group'> |
||
| 2059 | <label class="mb-0 w-100"> |
||
| 2060 | <span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
||
| 2061 | <textarea v-model='item.description' class='w-100'></textarea> |
||
| 2062 | </label> |
||
| 2063 | </div> |
||
| 2064 | |||
| 2065 | <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'><?php _e( 'Delete Item', 'invoicing' ); ?></button> |
||
| 2066 | |||
| 2067 | </div> |
||
| 2068 | </div> |
||
| 2069 | |||
| 2070 | </div> |
||
| 2071 | </draggable> |
||
| 2072 | |||
| 2073 | <small v-if='! form_items.length' class='form-text text-danger'><?php _e( 'You have not set up any items. Please select an item below or create a new item.', 'invoicing' ); ?></small> |
||
| 2074 | |||
| 2075 | <div class='form-group mt-2'> |
||
| 2076 | |||
| 2077 | <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" v-model='selected_item' @change='addSelectedItem'> |
||
| 2078 | <option value=''><?php _e( 'Select an item to add...', 'invoicing' ) ?></option> |
||
| 2079 | <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option> |
||
| 2080 | </select> |
||
| 2081 | |||
| 2082 | </div> |
||
| 2083 | |||
| 2084 | <div class='form-group'> |
||
| 2085 | <button @click.prevent='addNewItem' class="button button-link"><?php _e( 'Or create a new item.', 'invoicing' ) ?></button> |
||
| 2086 | </div> |
||
| 2087 | |||
| 2088 | <div class='form-group mt-5'> |
||
| 2089 | <label :for='<?php echo $id2; ?>'><?php _e( 'Let customers...', 'invoicing' ) ?></label> |
||
| 2090 | |||
| 2091 | <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" :id='<?php echo $id2; ?>' v-model='<?php echo $field; ?>.items_type'> |
||
| 2092 | <option value='total' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Buy all items on the list', 'invoicing' ); ?></option> |
||
| 2093 | <option value='radio'><?php _e( 'Select a single item from the list', 'invoicing' ); ?></option> |
||
| 2094 | <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Select one or more items on the list', 'invoicing' ) ;?></option> |
||
| 2095 | <option value='select'><?php _e( 'Select a single item from a dropdown', 'invoicing' ); ?></option> |
||
| 2096 | <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Select a one or more items from a dropdown', 'invoicing' ) ;?></option> |
||
| 2097 | </select> |
||
| 2098 | |||
| 2099 | </div> |
||
| 2100 | </div> |
||
| 2101 | <div class='form-group'> |
||
| 2102 | <label :for='<?php echo $id3; ?>'><?php _e( 'Help Text', 'invoicing' ); ?></label> |
||
| 2103 | <textarea placeholder='<?php esc_attr_e( 'Add some help text for this element', 'invoicing' ); ?>' :id='<?php echo $id3; ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea> |
||
| 2104 | </div> |
||
| 2105 | |||
| 2106 | </div> |
||
| 2107 | |||
| 2108 | <?php |
||
| 2109 | |||
| 2110 | } |
||
| 2111 | |||
| 2112 | /** |
||
| 2113 | * Returns an array of all published items. |
||
| 2114 | */ |
||
| 2115 | public function get_published_items() { |
||
| 2116 | |||
| 2117 | $item_args = array( |
||
| 2118 | 'post_type' => 'wpi_item', |
||
| 2119 | 'orderby' => 'title', |
||
| 2120 | 'order' => 'ASC', |
||
| 2121 | 'posts_per_page' => -1, |
||
| 2122 | 'post_status' => array( 'publish' ), |
||
| 2123 | 'meta_query' => array( |
||
| 2124 | array( |
||
| 2125 | 'key' => '_wpinv_type', |
||
| 2126 | 'compare' => '!=', |
||
| 2127 | 'value' => 'package' |
||
| 2128 | ) |
||
| 2129 | ) |
||
| 2130 | ); |
||
| 2131 | |||
| 2132 | $items = get_posts( apply_filters( 'getpaid_payment_form_item_dropdown_query_args', $item_args ) ); |
||
| 2133 | |||
| 2134 | if ( empty( $items ) ) { |
||
| 2135 | return array(); |
||
| 2136 | } |
||
| 2137 | |||
| 2138 | $options = array(); |
||
| 2139 | foreach ( $items as $item ) { |
||
| 2140 | $item = new GetPaid_Form_Item( $item ); |
||
| 2141 | $options[] = $item->prepare_data_for_use(); |
||
| 2142 | } |
||
| 2143 | return $options; |
||
| 2144 | |||
| 2145 | } |
||
| 2146 | |||
| 2147 | /** |
||
| 2148 | * Returns an array of items for the currently being edited form. |
||
| 2149 | */ |
||
| 2150 | public function get_form_items( $id = false ) { |
||
| 2151 | $form = new GetPaid_Payment_Form( $id ); |
||
| 2152 | |||
| 2153 | // Is this a default form? |
||
| 2154 | if ( $form->is_default() ) { |
||
| 2155 | return array(); |
||
| 2156 | } |
||
| 2157 | |||
| 2158 | return $form->get_items( 'view', 'arrays' ); |
||
| 2159 | } |
||
| 2160 | |||
| 2161 | /** |
||
| 2162 | * Converts form items for use. |
||
| 2163 | */ |
||
| 2164 | public function convert_checkout_items( $items, $invoice ) { |
||
| 2165 | |||
| 2166 | $converted = array(); |
||
| 2167 | foreach ( $items as $item ) { |
||
| 2168 | |||
| 2169 | $item_id = $item['id']; |
||
| 2170 | $_item = new WPInv_Item( $item_id ); |
||
| 2171 | |||
| 2172 | if( ! $_item ) { |
||
| 2173 | continue; |
||
| 2174 | } |
||
| 2175 | |||
| 2176 | $converted[] = array( |
||
| 2177 | 'title' => esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $_item ), |
||
| 2178 | 'id' => $item['id'], |
||
| 2179 | 'price' => $item['subtotal'], |
||
| 2180 | 'custom_price' => $_item->get_is_dynamic_pricing(), |
||
| 2181 | 'recurring' => $_item->is_recurring(), |
||
| 2182 | 'description' => apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice ), |
||
| 2183 | 'minimum_price' => $_item->get_minimum_price(), |
||
| 2184 | 'allow_quantities' => false, |
||
| 2185 | 'quantity' => $item['quantity'], |
||
| 2186 | 'required' => true, |
||
| 2187 | ); |
||
| 2188 | } |
||
| 2189 | return $converted; |
||
| 2190 | |||
| 2191 | } |
||
| 2192 | |||
| 2193 | /** |
||
| 2194 | * Converts an array of id => quantity for use. |
||
| 2195 | */ |
||
| 2196 | public function convert_normal_items( $items ) { |
||
| 2223 | |||
| 2224 | } |
||
| 2225 | |||
| 2226 | /** |
||
| 2227 | * Returns an array of elements for the currently being edited form. |
||
| 2228 | */ |
||
| 2229 | public function get_form_elements( $id = false ) { |
||
| 2230 | |||
| 2231 | if ( empty( $id ) ) { |
||
| 2232 | return wpinv_get_data( 'sample-payment-form' ); |
||
| 2233 | } |
||
| 2234 | |||
| 2235 | $form_elements = get_post_meta( $id, 'wpinv_form_elements', true ); |
||
| 2236 | |||
| 2237 | if ( is_array( $form_elements ) ) { |
||
| 2238 | return $form_elements; |
||
| 2239 | } |
||
| 2240 | |||
| 2241 | return wpinv_get_data( 'sample-payment-form' ); |
||
| 2242 | } |
||
| 2243 | |||
| 2244 | /** |
||
| 2245 | * Sends a redrect response to payment details. |
||
| 2246 | * |
||
| 2247 | */ |
||
| 2248 | public function send_redirect_response( $url ) { |
||
| 2249 | $url = urlencode( $url ); |
||
| 2250 | wp_send_json_success( $url ); |
||
| 2251 | } |
||
| 2252 | |||
| 2253 | /** |
||
| 2254 | * Fired when a checkout error occurs |
||
| 2255 | * |
||
| 2256 | */ |
||
| 2257 | public function checkout_error() { |
||
| 2268 | |||
| 2269 | } |
||
| 2270 | |||
| 2271 | } |
||
| 2272 |