PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / fields / class-evf-field-payment-coupon.php
everest-forms / includes / fields Last commit date
class-evf-field-address.php 1 year ago class-evf-field-ai.php 1 year ago class-evf-field-captcha.php 1 month ago class-evf-field-checkbox.php 3 months ago class-evf-field-color.php 1 month ago class-evf-field-country.php 3 months ago class-evf-field-credit-card.php 1 month ago class-evf-field-date-time.php 1 month 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 5 months ago class-evf-field-hidden.php 1 year ago class-evf-field-html.php 10 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 1 month ago class-evf-field-number.php 1 year ago class-evf-field-password.php 1 month ago class-evf-field-payment-authorize-net.php 1 month ago class-evf-field-payment-checkbox.php 1 month ago class-evf-field-payment-coupon.php 1 month ago class-evf-field-payment-gateway-selector.php 1 month ago class-evf-field-payment-quantity.php 1 month ago class-evf-field-payment-radio.php 1 month ago class-evf-field-payment-single.php 1 month ago class-evf-field-payment-square.php 1 year ago class-evf-field-payment-subscription-plan.php 1 month ago class-evf-field-payment-subtotal.php 1 month ago class-evf-field-payment-total.php 1 month ago class-evf-field-phone.php 1 year ago class-evf-field-privacy-policy.php 3 months ago class-evf-field-private-note.php 1 year ago class-evf-field-progress.php 1 month ago class-evf-field-radio.php 3 months ago class-evf-field-range-slider.php 1 month ago class-evf-field-rating.php 3 months ago class-evf-field-recaptcha.php 5 months ago class-evf-field-repeater.php 1 month ago class-evf-field-reset.php 1 month ago class-evf-field-scale-rating.php 1 year ago class-evf-field-select.php 1 year ago class-evf-field-signature.php 1 month 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 5 months ago class-evf-field-url.php 1 year ago class-evf-field-wysiwyg.php 3 months ago class-evf-field-yes-no.php 1 year ago payment-amount-helpers.php 1 month ago
class-evf-field-payment-coupon.php
230 lines
1 <?php
2 /**
3 * Coupon field.
4 *
5 * @package EverestForms\Fields
6 * @since 1.8.9
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Field_Payment_Coupon Class.
13 *
14 * Builder-scope (read-only) version shipped in the free plugin so the field can
15 * be shown LOCKED — with its real preview and readable settings — for the AI
16 * upsell. The full functional implementation (front-end display, validation,
17 * processing) lives in Everest Forms Pro, whose class loads in place of this one
18 * when the plugin is active (this file is only autoloaded when that class is not
19 * already defined). Keep `is_pro = true` so the field stays locked.
20 */
21 class EVF_Field_Payment_Coupon extends EVF_Form_Fields {
22
23 /**
24 * Constructor.
25 */
26 public function __construct() {
27 $this->name = esc_html__( 'Coupons', 'everest-forms' );
28 $this->type = 'payment-coupon';
29 $this->icon = 'evf-icon evf-icon-coupon';
30 $this->order = 16;
31 $this->group = 'payment';
32 $this->is_pro = true;
33 $this->plan = 'personal agency themegrill-agency';
34 $this->addon = 'everest-forms-coupons';
35 $this->links = array(
36 'image_id' => '',
37 'vedio_id' => 'GSYQIiyntW0',
38 );
39 $this->settings = array(
40 'basic-options' => array(
41 'field_options' => array(
42 'label',
43 'description',
44 'discount_message',
45 'map_field',
46 'button_text',
47 'invalid_message',
48 ),
49 ),
50 'advanced-options' => array(
51 'field_options' => array(
52 'placeholder',
53 'meta',
54 'label_hide',
55 'css',
56 ),
57 ),
58 );
59
60 parent::__construct();
61 }
62
63 /**
64 * Mapping the payment field with quantity.
65 *
66 * @param array $field Field data object.
67 */
68 public function map_field( $field ) {
69 $form_id = isset( $_GET['form_id'] ) ? wp_unslash( absint( $_GET['form_id'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
70 $form_obj = EVF()->form->get( $form_id );
71 $form_data = ! empty( $form_obj->post_content ) ? evf_decode( $form_obj->post_content ) : '';
72 $options = array();
73
74 if ( isset( $form_data['form_fields'] ) && is_array( $form_data['form_fields'] ) ) {
75 foreach ( $form_data['form_fields'] as $id => $form_field ) {
76 if ( isset( $form_field['enable_payment_slider'] ) && '1' === $form_field['enable_payment_slider'] ) {
77 if ( in_array( $form_field['type'], array( 'payment-single', 'payment-multiple', 'payment-checkbox', 'range-slider' ), true ) ) {
78 $options[ $form_field['id'] ] = $form_field['label'];
79 }
80 } else {
81 if ( in_array( $form_field['type'], array( 'payment-single', 'payment-multiple', 'payment-checkbox' ), true ) ) {
82 $options[ $form_field['id'] ] = $form_field['label'];
83 }
84 }
85 }
86 }
87
88 $options = array_merge( array( '' => __( 'Total', 'everest-forms' ) ), $options );
89
90 // Input Mask.
91 $lbl = $this->field_element(
92 'label',
93 $field,
94 array(
95 'slug' => 'map_field',
96 'value' => esc_html__( 'Calculate with this field', 'everest-forms' ),
97 'tooltip' => esc_html__( 'Choose the field to calculate the coupon discount.', 'everest-forms' ),
98 ),
99 false
100 );
101 $fld = $this->field_element(
102 'select',
103 $field,
104 array(
105 'slug' => 'map_field',
106 'value' => ! empty( $field['map_field'] ) ? esc_attr( $field['map_field'] ) : '',
107 'options' => $options,
108 ),
109 false
110 );
111 $this->field_element(
112 'row',
113 $field,
114 array(
115 'slug' => 'map_field',
116 'content' => $lbl . $fld,
117 )
118 );
119 }
120
121 /**
122 * Apply Button Text.
123 *
124 * @param array $field Field data object.
125 */
126 public function button_text( $field ) {
127
128 // Input Mask.
129 $lbl = $this->field_element(
130 'label',
131 $field,
132 array(
133 'slug' => 'button_text',
134 'value' => esc_html__( 'Button Text', 'everest-forms' ),
135 'tooltip' => esc_html__( 'Add text to the apply coupon button', 'everest-forms' ),
136 ),
137 false
138 );
139 $fld = $this->field_element(
140 'text',
141 $field,
142 array(
143 'slug' => 'button_text',
144 'value' => ! empty( $field['button_text'] ) ? esc_attr( $field['button_text'] ) : __( 'Apply Coupon', 'everest-forms' ),
145 ),
146 false
147 );
148 $this->field_element(
149 'row',
150 $field,
151 array(
152 'slug' => 'button_text',
153 'content' => $lbl . $fld,
154 )
155 );
156 }
157
158 /**
159 * Apply Button Text.
160 *
161 * @param array $field Field data object.
162 */
163 public function invalid_message( $field ) {
164
165 // Input Mask.
166 $lbl = $this->field_element(
167 'label',
168 $field,
169 array(
170 'slug' => 'invalid_message',
171 'value' => esc_html__( 'Invalid Coupon Message', 'everest-forms' ),
172 'tooltip' => esc_html__( 'Add text to be displayed when coupon code is invalid', 'everest-forms' ),
173 ),
174 false
175 );
176 $fld = $this->field_element(
177 'text',
178 $field,
179 array(
180 'slug' => 'invalid_message',
181 'value' => ! empty( $field['invalid_message'] ) ? esc_attr( $field['invalid_message'] ) : __( 'Coupon code is invalid or expired', 'everest-forms' ),
182 ),
183 false
184 );
185 $this->field_element(
186 'row',
187 $field,
188 array(
189 'slug' => 'invalid_message',
190 'content' => $lbl . $fld,
191 )
192 );
193 }
194
195 /**
196 * Field preview inside the builder.
197 *
198 * @since 1.0.0
199 *
200 * @param array $field Field data and settings.
201 */
202 public function field_preview( $field ) {
203 $placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
204 $value = ! empty( $field['coupon_code'] ) ? esc_attr( $field['coupon_code'] ) : '';
205 $button_label = ! empty( $field['button_text'] ) ? esc_attr( $field['button_text'] ) : __( 'Apply Coupon', 'everest-forms' );
206 echo '<div>';
207
208 $this->field_preview_option( 'label', $field );
209
210 echo '<div class="everest-forms-coupons">';
211
212 printf(
213 '<input type="text" placeholder="%s" class="widefat primary-input" value="%s" disabled>',
214 esc_attr( $placeholder ),
215 esc_attr( $value )
216 );
217
218 printf(
219 '<button type="button" class="evf-coupon-apply" disabled>%s</button>',
220 esc_html( $button_label )
221 );
222
223 echo '</div>';
224
225 $this->field_preview_option( 'description', $field );
226
227 echo '</div>';
228 }
229 }
230