PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.2.0
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.2.0
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 All 66 releases
better-payment / includes / Admin / Elementor / Form_Actions / Payment_Amount_Integration.php

Payment_Amount_Integration.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.2.0, at includes/Admin/Elementor/Form_Actions/Payment_Amount_Integration.php

558 lines 19.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite\Admin\Elementor\Form_Actions;
4
5 use Better_Payment\Lite\Admin\DB;
6 use Elementor\Controls_Manager;
7 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
8 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
9 use Elementor\Group_Control_Border;
10 use Elementor\Group_Control_Box_Shadow;
11 use Elementor\Group_Control_Typography;
12 use Elementor\Repeater;
13 use ElementorPro\Modules\Forms\Classes\Action_Base;
14 use ElementorPro\Modules\Forms\Classes\Ajax_Handler;
15 use ElementorPro\Modules\Forms\Classes\Form_Record;
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit; // Exit if accessed directly
19 }
20
21 /**
22 * Payment Amount integration class
23 *
24 * @since 0.0.1
25 */
26 class Payment_Amount_Integration extends Action_Base {
27 private $better_payment_global_settings = [];
28
29 public function get_name() {
30 return '';
31 }
32
33 public function get_label() {
34 return __( 'Better Payment', 'better-payment' );
35 }
36
37 /**
38 * @param \Elementor\Widget_Base $widget
39 */
40 public function register_settings_section( $widget ) {
41 $this->better_payment_global_settings = DB::get_settings();
42
43 $widget->start_controls_section(
44 'section_better_payment_payment_amount',
45 [
46 'label' => __( 'Better Payment', 'better-payment' ),
47 'condition' => [
48 ],
49 ]
50 );
51
52 $widget->add_control(
53 'better_payment_payment_amount_enable_notice',
54 [
55 'type' => Controls_Manager::RAW_HTML,
56 'raw' => __( 'Don\'t forget to add PayPal or Stripe on <strong>Actions After Submit</strong>', 'better-payment' ),
57 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
58 'conditions' => [
59 'relation' => 'or',
60 'terms' => [
61 [
62 'name' => 'better_payment_payment_amount_enable',
63 'value' => 'yes',
64 ],
65 [
66 'name' => 'better_payment_show_amount_list_enable',
67 'value' => 'yes',
68 ],
69 ],
70 ],
71 ]
72 );
73
74 $widget->add_control(
75 'better_payment_payment_amount_enable',
76 [
77 'label' => __( 'Payment Amount Field', 'better-payment' ),
78 'description' => __( 'We add an extra field type <b>Payment Amount</b> which offers you to accept payment via Paypal and Stripe. Disable it if you want to hide the field type.<br><br>', 'better-payment' ),
79 'type' => Controls_Manager::SWITCHER,
80 'label_on' => __( 'Yes', 'better-payment' ),
81 'label_off' => __( 'No', 'better-payment' ),
82 'return_value' => 'yes',
83 'default' => 'no',
84 ]
85 );
86
87 $repeater = new Repeater();
88
89
90 $repeater->add_control(
91 'better_payment_amount_val',
92 [
93 'label' => esc_html__( 'Payment Amount', 'better-payment' ),
94 'type' => Controls_Manager::NUMBER,
95 'min' => 1,
96 ]
97 );
98
99 $widget->add_control(
100 'better_payment_form_title',
101 [
102 'label' => __( 'Form Name', 'better-payment' ),
103 'type' => Controls_Manager::TEXT,
104 'dynamic' => [
105 'active' => true,
106 ],
107 'default' => __( 'Better Payment', 'better-payment' ),
108 'ai' => [
109 'active' => false,
110 ],
111 ]
112 );
113
114 $widget->add_control(
115 'better_payment_show_amount_list_enable',
116 [
117 'label' => __( 'Show Amount List', 'better-payment' ),
118 'type' => Controls_Manager::SWITCHER,
119 'label_on' => __( 'Yes', 'better-payment' ),
120 'label_off' => __( 'No', 'better-payment' ),
121 'return_value' => 'yes',
122 'default' => 'no',
123 'condition' => [
124 'better_payment_payment_amount_enable' => 'yes',
125 ],
126 'separator' => 'before',
127 ]
128 );
129
130 $widget->add_control(
131 'better_payment_show_amount_list_notice',
132 [
133 'type' => Controls_Manager::RAW_HTML,
134 'raw' => __( 'Form Fields => Payment Amount => <b>Field Type</b> helps to show Amount List with or without Input field.', 'better-payment' ),
135 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
136 'condition' => [
137 'better_payment_payment_amount_enable' => 'yes',
138 'better_payment_show_amount_list_enable' => 'yes',
139 ],
140 ]
141 );
142
143 $widget->add_control(
144 'better_payment_show_amount_list_items',
145 [
146 'label' => esc_html__( 'Amount List', 'better-payment' ),
147 'type' => Controls_Manager::REPEATER,
148 'default' => [
149 [
150 'better_payment_amount_val' => 5
151 ],
152 [
153 'better_payment_amount_val' => 10
154 ],
155 [
156 'better_payment_amount_val' => 15
157 ],
158 [
159 'better_payment_amount_val' => 20
160 ],
161 ],
162 'fields' => $repeater->get_controls(),
163 'title_field' => '<i class="{{ better_payment_amount_val }}" aria-hidden="true"></i> {{{ better_payment_amount_val }}}',
164 'condition' => [
165 'better_payment_payment_amount_enable' => 'yes',
166 'better_payment_show_amount_list_enable' => 'yes',
167 ],
168 ]
169 );
170
171 $widget->add_control(
172 'better_payment_payment_amount_style',
173 [
174 'label' => __( 'Field Style', 'better-payment' ),
175 'type' => Controls_Manager::SWITCHER,
176 'label_on' => __( 'Yes', 'better-payment' ),
177 'label_off' => __( 'No', 'better-payment' ),
178 'return_value' => 'yes',
179 'default' => 'no',
180 'condition' => [
181 'better_payment_payment_amount_enable' => 'yes',
182 ],
183 'separator' => 'before',
184 ]
185 );
186
187 $widget->add_control(
188 'better_payment_field_text_color',
189 [
190 'label' => esc_html__( 'Text Color', 'better-payment' ),
191 'type' => Controls_Manager::COLOR,
192 'selectors' => [
193 '{{WRAPPER}} .elementor-field-group .elementor-field.bp-elementor-field-textual-amount' => 'color: {{VALUE}};',
194 ],
195 'global' => [
196 'default' => Global_Colors::COLOR_TEXT,
197 ],
198 'condition' => [
199 'better_payment_payment_amount_style' => 'yes',
200 ],
201 ]
202 );
203
204 $widget->add_group_control(
205 Group_Control_Typography::get_type(),
206 [
207 'name' => 'better_payment_field_typography',
208 'selector' => '{{WRAPPER}} .elementor-field-group .elementor-field.bp-elementor-field-textual-amount',
209 'global' => [
210 'default' => Global_Typography::TYPOGRAPHY_TEXT,
211 ],
212 'condition' => [
213 'better_payment_payment_amount_style' => 'yes',
214 ],
215 ]
216 );
217
218 $widget->add_control(
219 'better_payment_field_background_color',
220 [
221 'label' => esc_html__( 'Background Color', 'better-payment' ),
222 'type' => Controls_Manager::COLOR,
223 'default' => '#ffffff',
224 'selectors' => [
225 '{{WRAPPER}} .elementor-field-group .elementor-field.bp-elementor-field-textual-amount' => 'background-color: {{VALUE}};',
226 ],
227 'condition' => [
228 'better_payment_payment_amount_style' => 'yes',
229 ],
230 ]
231 );
232
233 $widget->add_control(
234 'better_payment_field_border_color',
235 [
236 'label' => esc_html__( 'Border Color', 'better-payment' ),
237 'type' => Controls_Manager::COLOR,
238 'selectors' => [
239 '{{WRAPPER}} .elementor-field-group.elementor-field-type-payment_amount .bp-input-group' => 'border-color: {{VALUE}};border-style:solid;',
240 ],
241 'condition' => [
242 'better_payment_payment_amount_style' => 'yes',
243 ],
244 ]
245 );
246
247 $widget->add_control(
248 'better_payment_field_border_width',
249 [
250 'label' => esc_html__( 'Border Width', 'better-payment' ),
251 'type' => Controls_Manager::DIMENSIONS,
252 'placeholder' => '1',
253 'size_units' => [ 'px' ],
254 'selectors' => [
255 '{{WRAPPER}} .elementor-field-group.elementor-field-type-payment_amount .bp-input-group' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
256 ],
257 'condition' => [
258 'better_payment_payment_amount_style' => 'yes',
259 ],
260 ]
261 );
262
263 $widget->add_control(
264 'better_payment_field_border_radius',
265 [
266 'label' => esc_html__( 'Border Radius', 'better-payment' ),
267 'type' => Controls_Manager::DIMENSIONS,
268 'size_units' => [ 'px', '%' ],
269 'selectors' => [
270 '{{WRAPPER}} .elementor-field-group.elementor-field-type-payment_amount .bp-input-group' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
271 ],
272 'condition' => [
273 'better_payment_payment_amount_style' => 'yes',
274 ],
275 ]
276 );
277
278 $widget->add_control(
279 'better_payment_amount_list_style',
280 [
281 'label' => __( 'Amount List Style', 'better-payment' ),
282 'type' => Controls_Manager::SWITCHER,
283 'label_on' => __( 'Yes', 'better-payment' ),
284 'label_off' => __( 'No', 'better-payment' ),
285 'return_value' => 'yes',
286 'default' => 'no',
287 'condition' => [
288 'better_payment_payment_amount_enable' => 'yes',
289 'better_payment_show_amount_list_enable' => 'yes',
290 ],
291 'separator' => 'before',
292 ]
293 );
294
295 $widget->add_responsive_control(
296 'better_payment_form_fields_amount_width',
297 [
298 'label' => __( 'Input Width', 'better-payment' ),
299 'type' => Controls_Manager::SLIDER,
300 'range' => [
301 'px' => [
302 'min' => 0,
303 'max' => 1200,
304 'step' => 1,
305 ],
306 ],
307 'size_units' => [ 'px', 'em', '%' ],
308 'selectors' => [
309 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'width: {{SIZE}}{{UNIT}}',
310 ],
311 'condition' => [
312 'better_payment_amount_list_style' => 'yes',
313 ],
314 ]
315 );
316
317 $widget->add_responsive_control(
318 'better_payment_form_fields_amount_height',
319 [
320 'label' => __( 'Input Height', 'better-payment' ),
321 'type' => Controls_Manager::SLIDER,
322 'range' => [
323 'px' => [
324 'min' => 0,
325 'max' => 1200,
326 'step' => 1,
327 ],
328 ],
329 'size_units' => [ 'px', 'em', '%' ],
330 'selectors' => [
331 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'height: {{SIZE}}{{UNIT}}',
332 ],
333 'condition' => [
334 'better_payment_amount_list_style' => 'yes',
335 ],
336 ]
337 );
338
339 $widget->add_responsive_control(
340 'better_payment_form_fields_amount_spacing',
341 [
342 'label' => __( 'Spacing', 'better-payment' ),
343 'type' => Controls_Manager::SLIDER,
344 'default' => [
345 'size' => '0',
346 'unit' => 'px',
347 ],
348 'range' => [
349 'px' => [
350 'min' => 0,
351 'max' => 100,
352 'step' => 1,
353 ],
354 ],
355 'size_units' => [ 'px', 'em', '%' ],
356 'selectors' => [
357 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'margin-bottom: {{SIZE}}{{UNIT}}',
358 ],
359 'condition' => [
360 'better_payment_amount_list_style' => 'yes',
361 ],
362 ]
363 );
364
365 $widget->start_controls_tabs( 'better_payment_form_amount_tabs_button_style' );
366
367 $widget->start_controls_tab(
368 'better_payment_form_fields_amount_normal',
369 [
370 'label' => __( 'Normal', 'better-payment' ),
371 'condition' => [
372 'better_payment_amount_list_style' => 'yes',
373 ],
374 ]
375 );
376
377 $widget->add_control(
378 'better_payment_form_fields_amount_normal_bg',
379 [
380 'label' => __( 'Background Color', 'better-payment' ),
381 'type' => Controls_Manager::COLOR,
382 'default' => '',
383 'selectors' => [
384 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'background-color: {{VALUE}}',
385 ],
386 'condition' => [
387 'better_payment_amount_list_style' => 'yes',
388 ],
389 ]
390 );
391
392 $widget->add_control(
393 'better_payment_form_fields_amount_normal_text_color',
394 [
395 'label' => __( 'Text Color', 'better-payment' ),
396 'type' => Controls_Manager::COLOR,
397 'default' => '',
398 'selectors' => [
399 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'color: {{VALUE}}',
400 ],
401 'condition' => [
402 'better_payment_amount_list_style' => 'yes',
403 ],
404 ]
405 );
406
407 $widget->end_controls_tab();
408
409 $widget->start_controls_tab(
410 'better_payment_form_fields_amount_selected',
411 [
412 'label' => __( 'Selected', 'better-payment' ),
413 'condition' => [
414 'better_payment_amount_list_style' => 'yes',
415 ],
416 ]
417 );
418
419 $widget->add_control(
420 'better_payment_form_fields_amount_selected_bg',
421 [
422 'label' => __( 'Background Color', 'better-payment' ),
423 'type' => Controls_Manager::COLOR,
424 'default' => '',
425 'selectors' => [
426 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group input[type="radio"].bp-form__control:checked ~ label' => 'background-color: {{VALUE}}',
427 ],
428 'condition' => [
429 'better_payment_amount_list_style' => 'yes',
430 ],
431 ]
432 );
433
434 $widget->add_control(
435 'better_payment_form_fields_amount_selected_text_color',
436 [
437 'label' => __( 'Text Color', 'better-payment' ),
438 'type' => Controls_Manager::COLOR,
439 'default' => '',
440 'selectors' => [
441 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group input[type="radio"].bp-form__control:checked ~ label' => 'color: {{VALUE}}',
442 ],
443 'condition' => [
444 'better_payment_amount_list_style' => 'yes',
445 ],
446 ]
447 );
448
449 $widget->end_controls_tab();
450
451 $widget->end_controls_tabs();
452
453 $widget->add_group_control(
454 Group_Control_Border::get_type(),
455 [
456 'name' => 'better_payment_form_fields_amount_border',
457 'label' => __( 'Border', 'better-payment' ),
458 'placeholder' => '1px',
459 'default' => '1px',
460 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
461 'separator' => 'before',
462 'condition' => [
463 'better_payment_amount_list_style' => 'yes',
464 ],
465 ]
466 );
467
468 $widget->add_control(
469 'better_payment_form_fields_amount_border_radius',
470 [
471 'label' => __( 'Border Radius', 'better-payment' ),
472 'type' => Controls_Manager::DIMENSIONS,
473 'size_units' => [ 'px', 'em', '%' ],
474 'selectors' => [
475 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
476 ],
477 'condition' => [
478 'better_payment_amount_list_style' => 'yes',
479 ],
480 ]
481 );
482
483 $widget->add_group_control(
484 Group_Control_Typography::get_type(),
485 [
486 'name' => 'better_payment_form_fields_amount_typography',
487 'label' => __( 'Typography', 'better-payment' ),
488 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
489 'separator' => 'before',
490 'condition' => [
491 'better_payment_amount_list_style' => 'yes',
492 ],
493 ]
494 );
495
496 $widget->add_group_control(
497 Group_Control_Box_Shadow::get_type(),
498 [
499 'name' => 'better_payment_form_fields_amount_box_shadow',
500 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
501 'condition' => [
502 'better_payment_amount_list_style' => 'yes',
503 ],
504 ]
505 );
506
507 $widget->add_control(
508 'better_payment_message_display_heading',
509 [
510 'label' => __( 'Success/Error Messages', 'better-payment' ),
511 'type' => Controls_Manager::HEADING,
512 'separator' => 'before',
513 ]
514 );
515
516 $widget->add_control(
517 'better_payment_message_display_notice',
518 [
519 'type' => Controls_Manager::RAW_HTML,
520 'raw' => __( 'For proper message display on payment redirection, disable Element Caching in <strong>Advanced Tab → Cache Settings</strong>.', 'better-payment' ),
521 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
522 ]
523 );
524
525 $widget->end_controls_section();
526 }
527
528 /**
529 * @param array $element
530 * @return array
531 */
532 public function on_export( $element ) {
533 unset(
534 $element[ 'settings' ][ 'better_payment_payment_amount_enable' ]
535 );
536
537 return $element;
538 }
539
540 /**
541 * @param Form_Record $record
542 * @param Ajax_Handler $ajax_handler
543 */
544 public function run( $record, $ajax_handler ) {
545 //Silence is golden!
546 // wp_enqueue_style( 'better-payment-el' );
547 // wp_enqueue_style( 'bp-icon-front' );
548 // wp_enqueue_style( 'better-payment-style' );
549 // wp_enqueue_style( 'better-payment-common-style' );
550 // wp_enqueue_style( 'better-payment-admin-style' );
551
552 // wp_enqueue_script( 'better-payment-common-script' );
553 // wp_enqueue_script( 'better-payment' );
554 }
555 }
556
557
558