class-evf-field-address.php
1 year ago
class-evf-field-ai.php
1 year ago
class-evf-field-captcha.php
4 weeks ago
class-evf-field-checkbox.php
2 months ago
class-evf-field-color.php
4 weeks ago
class-evf-field-country.php
2 months ago
class-evf-field-credit-card.php
4 weeks ago
class-evf-field-date-time.php
4 weeks ago
class-evf-field-divider.php
2 years ago
class-evf-field-email.php
1 year ago
class-evf-field-file-upload.php
1 year ago
class-evf-field-first-name.php
1 year ago
class-evf-field-hcaptcha.php
4 months ago
class-evf-field-hidden.php
1 year ago
class-evf-field-html.php
9 months ago
class-evf-field-image-upload.php
1 year ago
class-evf-field-last-name.php
1 year ago
class-evf-field-likert.php
1 year ago
class-evf-field-lookup.php
4 weeks ago
class-evf-field-number.php
1 year ago
class-evf-field-password.php
4 weeks ago
class-evf-field-payment-authorize-net.php
4 weeks ago
class-evf-field-payment-checkbox.php
4 weeks ago
class-evf-field-payment-coupon.php
4 weeks ago
class-evf-field-payment-gateway-selector.php
4 weeks ago
class-evf-field-payment-quantity.php
4 weeks ago
class-evf-field-payment-radio.php
4 weeks ago
class-evf-field-payment-single.php
4 weeks ago
class-evf-field-payment-square.php
1 year ago
class-evf-field-payment-subscription-plan.php
4 weeks ago
class-evf-field-payment-subtotal.php
4 weeks ago
class-evf-field-payment-total.php
4 weeks ago
class-evf-field-phone.php
1 year ago
class-evf-field-privacy-policy.php
2 months ago
class-evf-field-private-note.php
1 year ago
class-evf-field-progress.php
4 weeks ago
class-evf-field-radio.php
2 months ago
class-evf-field-range-slider.php
4 weeks ago
class-evf-field-rating.php
2 months ago
class-evf-field-recaptcha.php
4 months ago
class-evf-field-repeater.php
4 weeks ago
class-evf-field-reset.php
4 weeks ago
class-evf-field-scale-rating.php
1 year ago
class-evf-field-select.php
1 year ago
class-evf-field-signature.php
4 weeks ago
class-evf-field-text.php
1 year ago
class-evf-field-textarea.php
1 year ago
class-evf-field-title.php
2 years ago
class-evf-field-turnstile.php
4 months ago
class-evf-field-url.php
1 year ago
class-evf-field-wysiwyg.php
2 months ago
class-evf-field-yes-no.php
1 year ago
payment-amount-helpers.php
4 weeks ago
class-evf-field-payment-quantity.php
140 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Payment Quantity field |
| 4 | * |
| 5 | * @package EverestForms\Fields |
| 6 | */ |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * EVF_Field_Payment_Quantity Class. |
| 12 | * |
| 13 | * Builder-scope (read-only) version shipped in the free plugin so the field can |
| 14 | * be shown LOCKED — with its real preview and readable settings — for the AI |
| 15 | * upsell. The full functional implementation (front-end display, validation, |
| 16 | * exporters) lives in Everest Forms Pro, whose class loads in place of this one |
| 17 | * when the plugin is active (this file is only autoloaded when that class is not |
| 18 | * already defined). Keep `is_pro = true` so the field stays locked. |
| 19 | */ |
| 20 | class EVF_Field_Payment_Quantity extends EVF_Form_Fields { |
| 21 | |
| 22 | /** |
| 23 | * Constructor. |
| 24 | */ |
| 25 | public function __construct() { |
| 26 | $this->name = esc_html__( 'Quantity', 'everest-forms' ); |
| 27 | $this->type = 'payment-quantity'; |
| 28 | $this->icon = 'evf-icon evf-icon-single-item'; |
| 29 | $this->order = 40; |
| 30 | $this->group = 'payment'; |
| 31 | $this->is_pro = true; |
| 32 | $this->links = array( |
| 33 | 'image_id' => '', |
| 34 | 'vedio_id' => 'JLRES75WeqM', |
| 35 | ); |
| 36 | $this->settings = array( |
| 37 | 'basic-options' => array( |
| 38 | 'field_options' => array( |
| 39 | 'label', |
| 40 | 'description', |
| 41 | 'map_field', |
| 42 | 'required', |
| 43 | ), |
| 44 | ), |
| 45 | 'advanced-options' => array( |
| 46 | 'field_options' => array( |
| 47 | 'placeholder', |
| 48 | 'meta', |
| 49 | 'label_hide', |
| 50 | 'default_value', |
| 51 | 'css', |
| 52 | ), |
| 53 | ), |
| 54 | ); |
| 55 | |
| 56 | parent::__construct(); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Mapping the payment field with quantity. |
| 61 | * |
| 62 | * @param array $field Field data object. |
| 63 | */ |
| 64 | public function map_field( $field ) { |
| 65 | $form_id = isset( $_GET['form_id'] ) ? wp_unslash( absint( $_GET['form_id'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification |
| 66 | $form_obj = EVF()->form->get( $form_id ); |
| 67 | $form_data = ! empty( $form_obj->post_content ) ? evf_decode( $form_obj->post_content ) : ''; |
| 68 | $options = array(); |
| 69 | |
| 70 | if ( isset( $form_data['form_fields'] ) && is_array( $form_data['form_fields'] ) ) { |
| 71 | foreach ( $form_data['form_fields'] as $id => $form_field ) { |
| 72 | if ( isset( $form_field['enable_payment_slider'] ) && '1' === $form_field['enable_payment_slider'] ) { |
| 73 | if ( in_array( $form_field['type'], array( 'payment-single', 'payment-multiple', 'payment-checkbox', 'range-slider' ), true ) ) { |
| 74 | $options[ $form_field['id'] ] = $form_field['label']; |
| 75 | } |
| 76 | } else { |
| 77 | if ( in_array( $form_field['type'], array( 'payment-single', 'payment-multiple', 'payment-checkbox' ), true ) ) { |
| 78 | $options[ $form_field['id'] ] = $form_field['label']; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | if ( empty( $options ) ) { |
| 85 | $options = array( '' => __( '---Select Field---', 'everest-forms' ) ); |
| 86 | } |
| 87 | |
| 88 | // Input Mask. |
| 89 | $lbl = $this->field_element( |
| 90 | 'label', |
| 91 | $field, |
| 92 | array( |
| 93 | 'slug' => 'map_field', |
| 94 | 'value' => esc_html__( 'Calculate with this field', 'everest-forms' ), |
| 95 | 'tooltip' => esc_html__( 'Choose the number of icons.', 'everest-forms' ), |
| 96 | ), |
| 97 | false |
| 98 | ); |
| 99 | $fld = $this->field_element( |
| 100 | 'select', |
| 101 | $field, |
| 102 | array( |
| 103 | 'slug' => 'map_field', |
| 104 | 'value' => ! empty( $field['map_field'] ) ? esc_attr( $field['map_field'] ) : '', |
| 105 | 'options' => $options, |
| 106 | ), |
| 107 | false |
| 108 | ); |
| 109 | $this->field_element( |
| 110 | 'row', |
| 111 | $field, |
| 112 | array( |
| 113 | 'slug' => 'map_field', |
| 114 | 'content' => $lbl . $fld, |
| 115 | ) |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Field preview inside the builder. |
| 121 | * |
| 122 | * @since 1.0.0 |
| 123 | * |
| 124 | * @param array $field Field data and settings. |
| 125 | */ |
| 126 | public function field_preview( $field ) { |
| 127 | // Define data. |
| 128 | $placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : ''; |
| 129 | |
| 130 | // Label. |
| 131 | $this->field_preview_option( 'label', $field ); |
| 132 | |
| 133 | // Primary input. |
| 134 | echo '<input type="number" placeholder="' . $placeholder . '" class="widefat" disabled>'; // @codingStandardsIgnoreLine. |
| 135 | |
| 136 | // Description. |
| 137 | $this->field_preview_option( 'description', $field ); |
| 138 | } |
| 139 | } |
| 140 |