Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress - Version 1.1.0

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.4 to 1.1.0

admin/assets/css/flow-admin-edit-rtl.css CHANGED
@@ -85,6 +85,19 @@
85
  vertical-align: middle;
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  .wcf-step-wrap.wcf-no-product-step{
89
  border-right: 3px solid #f16334;
90
  }
85
  vertical-align: middle;
86
  }
87
 
88
+ .wcf-global-checkout-badge{
89
+ color: #FFFFFF;
90
+ background-color: #0072A7;
91
+ padding: 0.3em .6em 0.3em;
92
+ font-size: 0.7em;
93
+ font-weight: 600;
94
+ border-radius: 0px;
95
+ line-height: 0.7em;
96
+ margin-right: 10px;
97
+ text-align: center;
98
+ vertical-align: middle;
99
+ }
100
+
101
  .wcf-step-wrap.wcf-no-product-step{
102
  border-right: 3px solid #f16334;
103
  }
admin/assets/css/flow-admin-edit.css CHANGED
@@ -85,6 +85,19 @@
85
  vertical-align: middle;
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  .wcf-step-wrap.wcf-no-product-step{
89
  border-left: 3px solid #f16334;
90
  }
85
  vertical-align: middle;
86
  }
87
 
88
+ .wcf-global-checkout-badge{
89
+ color: #FFFFFF;
90
+ background-color: #0072A7;
91
+ padding: 0.3em .6em 0.3em;
92
+ font-size: 0.7em;
93
+ font-weight: 600;
94
+ border-radius: 0px;
95
+ line-height: 0.7em;
96
+ margin-left: 10px;
97
+ text-align: center;
98
+ vertical-align: middle;
99
+ }
100
+
101
  .wcf-step-wrap.wcf-no-product-step{
102
  border-left: 3px solid #f16334;
103
  }
admin/meta-assets/css/admin-edit-rtl.css CHANGED
@@ -169,6 +169,10 @@ body li.select2-results__option.select2-results__message {
169
  margin-bottom: 0px;
170
  }
171
 
 
 
 
 
172
  .wcf-cpf-row-setting-label {
173
  width: 25%;
174
  display: inline-block;
169
  margin-bottom: 0px;
170
  }
171
 
172
+ .wcf-cpf-fields.wcf-cpf-options .wcf-cpf-row-setting-label{
173
+ vertical-align: top;
174
+ }
175
+
176
  .wcf-cpf-row-setting-label {
177
  width: 25%;
178
  display: inline-block;
admin/meta-assets/css/admin-edit.css CHANGED
@@ -169,6 +169,10 @@ body li.select2-results__option.select2-results__message {
169
  margin-bottom: 0px;
170
  }
171
 
 
 
 
 
172
  .wcf-cpf-row-setting-label {
173
  width: 25%;
174
  display: inline-block;
169
  margin-bottom: 0px;
170
  }
171
 
172
+ .wcf-cpf-fields.wcf-cpf-options .wcf-cpf-row-setting-label{
173
+ vertical-align: top;
174
+ }
175
+
176
  .wcf-cpf-row-setting-label {
177
  width: 25%;
178
  display: inline-block;
admin/meta-assets/js/admin-edit.js CHANGED
@@ -201,6 +201,7 @@
201
  post_id = $('#post_ID').val(),
202
  add_to = wrap.find( '.wcf-cpf-fields.wcf-cpf-add_to select' ).val() || '',
203
  type = wrap.find( '.wcf-cpf-fields.wcf-cpf-type select' ).val() || '',
 
204
  label = wrap.find( '.wcf-cpf-fields.wcf-cpf-label input' ).val() || '',
205
  name = wrap.find( '.wcf-cpf-fields.wcf-cpf-name input' ).val() || '';
206
 
@@ -223,6 +224,7 @@
223
  post_id : post_id,
224
  add_to : add_to,
225
  type : type,
 
226
  label : label,
227
  name : name,
228
  security: cartflows_admin.wcf_add_checkout_custom_field_nonce
@@ -550,6 +552,29 @@
550
  });
551
  }
552
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553
  /* Advance Style Fields Hide / Show */
554
  var wcf_advance_style_fields_events = function() {
555
 
@@ -613,29 +638,6 @@
613
  }
614
  }
615
 
616
- /* Disable/Enable Custom Field section*/
617
- var wcf_custom_fields = function() {
618
-
619
- var wrap = $('.wcf-checkout-table'),
620
- custom_fields = wrap.find('.wcf-column-right .wcf-checkout-custom-fields .wcf-cc-fields .wcf-cc-checkbox-field .field-wcf-custom-checkout-fields input:checkbox');
621
-
622
- var field_names = [
623
- '.wcf-custom-field-box',
624
- '.wcf-cb-fields',
625
- '.wcf-sb-fields',
626
- ];
627
-
628
- if ( custom_fields.is(":checked") ) {
629
- $.each( field_names, function(i, val) {
630
- wrap.find( val ).show();
631
- })
632
- } else {
633
- $.each( field_names, function(i, val) {
634
- wrap.find( val ).hide();
635
- });
636
- }
637
- }
638
-
639
  var wcf_settings_tab = function() {
640
 
641
  if( $('.wcf-tab.active').length ) {
@@ -789,12 +791,12 @@
789
  /* Repeateble Product */
790
  wcf_add_repeatable_product();
791
 
792
- /* Remove Repeatable Product */
793
- wcf_remove_repeatable_product();
794
-
795
  /* Custom Fields Show Hide */
796
  wcf_custom_fields_events();
797
 
 
 
 
798
  /* Advance Style Fields Show Hide */
799
  wcf_advance_style_fields_events();
800
 
201
  post_id = $('#post_ID').val(),
202
  add_to = wrap.find( '.wcf-cpf-fields.wcf-cpf-add_to select' ).val() || '',
203
  type = wrap.find( '.wcf-cpf-fields.wcf-cpf-type select' ).val() || '',
204
+ options = wrap.find( '.wcf-cpf-fields.wcf-cpf-options textarea' ).val() || '',
205
  label = wrap.find( '.wcf-cpf-fields.wcf-cpf-label input' ).val() || '',
206
  name = wrap.find( '.wcf-cpf-fields.wcf-cpf-name input' ).val() || '';
207
 
224
  post_id : post_id,
225
  add_to : add_to,
226
  type : type,
227
+ options : options,
228
  label : label,
229
  name : name,
230
  security: cartflows_admin.wcf_add_checkout_custom_field_nonce
552
  });
553
  }
554
 
555
+ /* Disable/Enable Custom Field section*/
556
+ var wcf_custom_fields = function() {
557
+
558
+ var wrap = $('.wcf-checkout-table'),
559
+ custom_fields = wrap.find('.wcf-column-right .wcf-checkout-custom-fields .wcf-cc-fields .wcf-cc-checkbox-field .field-wcf-custom-checkout-fields input:checkbox');
560
+
561
+ var field_names = [
562
+ '.wcf-custom-field-box',
563
+ '.wcf-cb-fields',
564
+ '.wcf-sb-fields',
565
+ ];
566
+
567
+ if ( custom_fields.is(":checked") ) {
568
+ $.each( field_names, function(i, val) {
569
+ wrap.find( val ).show();
570
+ })
571
+ } else {
572
+ $.each( field_names, function(i, val) {
573
+ wrap.find( val ).hide();
574
+ });
575
+ }
576
+ }
577
+
578
  /* Advance Style Fields Hide / Show */
579
  var wcf_advance_style_fields_events = function() {
580
 
638
  }
639
  }
640
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
641
  var wcf_settings_tab = function() {
642
 
643
  if( $('.wcf-tab.active').length ) {
791
  /* Repeateble Product */
792
  wcf_add_repeatable_product();
793
 
 
 
 
794
  /* Custom Fields Show Hide */
795
  wcf_custom_fields_events();
796
 
797
+ /* Remove Repeatable Product */
798
+ wcf_remove_repeatable_product();
799
+
800
  /* Advance Style Fields Show Hide */
801
  wcf_advance_style_fields_events();
802
 
assets/css/checkout-template-rtl.css CHANGED
@@ -23,6 +23,7 @@
23
  .wcf-embed-checkout-form .woocommerce form .form-row-full,
24
  .wcf-embed-checkout-form .woocommerce-page form .form-row-full{
25
  width: 100%;
 
26
  }
27
 
28
  /* To test divi and all */
@@ -374,10 +375,12 @@
374
 
375
  .wcf-embed-checkout-form .wcf-custom-coupon-field {
376
  display: flex;
377
- margin-bottom: 25px;
378
  margin-top: 25px;
379
  border-top: 1px solid #dcdcdc;
 
380
  padding-top: 25px;
 
381
  }
382
 
383
  .wcf-embed-checkout-form #order_review .wcf-coupon-col-1 {
@@ -477,7 +480,7 @@
477
  }
478
  .wcf-embed-checkout-form .woocommerce-checkout #order_review{
479
  display: inline-block;
480
- float: right;
481
  width: 45%;
482
  border: none;
483
  background-color: inherit/*#F6F6F6*/;
@@ -499,10 +502,10 @@
499
  .wcf-embed-checkout-form .woocommerce-checkout #payment{
500
  background-color: inherit;
501
  border:none;
502
- border-top: 1px solid;
503
  border-radius: 0px;
504
- border-color: #dcdcdc;
505
- padding-top: 20px;
506
  }
507
 
508
  .wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{
@@ -595,6 +598,11 @@
595
  margin-bottom: 8px;
596
  }
597
 
 
 
 
 
 
598
  .wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{
599
  font-family: inherit;
600
  font-weight:inherit;
@@ -680,6 +688,9 @@
680
  }
681
 
682
  @media only screen and (max-width: 768px) {
 
 
 
683
  .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
684
  width: 100%;
685
  }
@@ -709,7 +720,7 @@
709
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
710
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
711
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-2{
712
- padding: 18px;
713
  }
714
 
715
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
@@ -723,6 +734,13 @@
723
  .wcf-embed-checkout-form .woocommerce-page form .form-row-first{
724
  margin-left: 4%;
725
  }
 
 
 
 
 
 
 
726
  }
727
 
728
 
23
  .wcf-embed-checkout-form .woocommerce form .form-row-full,
24
  .wcf-embed-checkout-form .woocommerce-page form .form-row-full{
25
  width: 100%;
26
+ clear: both;
27
  }
28
 
29
  /* To test divi and all */
375
 
376
  .wcf-embed-checkout-form .wcf-custom-coupon-field {
377
  display: flex;
378
+ margin-bottom: 15px;
379
  margin-top: 25px;
380
  border-top: 1px solid #dcdcdc;
381
+ border-bottom: 1px solid #dcdcdc;
382
  padding-top: 25px;
383
+ padding-bottom: 25px;
384
  }
385
 
386
  .wcf-embed-checkout-form #order_review .wcf-coupon-col-1 {
480
  }
481
  .wcf-embed-checkout-form .woocommerce-checkout #order_review{
482
  display: inline-block;
483
+ float: none;
484
  width: 45%;
485
  border: none;
486
  background-color: inherit/*#F6F6F6*/;
502
  .wcf-embed-checkout-form .woocommerce-checkout #payment{
503
  background-color: inherit;
504
  border:none;
505
+ /*border-top: 1px solid;*/
506
  border-radius: 0px;
507
+ /*border-color: #dcdcdc;*/
508
+ /*padding-top: 20px;*/
509
  }
510
 
511
  .wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{
598
  margin-bottom: 8px;
599
  }
600
 
601
+ .wcf-embed-checkout-form .woocommerce .woocommerce-terms-and-conditions-wrapper .woocommerce-terms-and-conditions-checkbox-text{
602
+ line-height: 20px;
603
+ text-transform: initial;
604
+ }
605
+
606
  .wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{
607
  font-family: inherit;
608
  font-weight:inherit;
688
  }
689
 
690
  @media only screen and (max-width: 768px) {
691
+ .wcf-embed-checkout-form form .wcf-form-col-3{
692
+ width: 100%;
693
+ }
694
  .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
695
  width: 100%;
696
  }
720
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
721
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
722
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-2{
723
+ padding: 15px;
724
  }
725
 
726
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
734
  .wcf-embed-checkout-form .woocommerce-page form .form-row-first{
735
  margin-left: 4%;
736
  }
737
+
738
+ .wcf-embed-checkout-form .woocommerce-additional-fields > h3,
739
+ .wcf-embed-checkout-form .woocommerce-billing-fields > h3,
740
+ .wcf-embed-checkout-form #order_review_heading,
741
+ .wcf-embed-checkout-form .woocommerce #ship-to-different-address{
742
+ font-size: 1.0em;
743
+ }
744
  }
745
 
746
 
assets/css/checkout-template.css CHANGED
@@ -23,6 +23,7 @@
23
  .wcf-embed-checkout-form .woocommerce form .form-row-full,
24
  .wcf-embed-checkout-form .woocommerce-page form .form-row-full{
25
  width: 100%;
 
26
  }
27
 
28
  /* To test divi and all */
@@ -374,10 +375,12 @@
374
 
375
  .wcf-embed-checkout-form .wcf-custom-coupon-field {
376
  display: flex;
377
- margin-bottom: 25px;
378
  margin-top: 25px;
379
  border-top: 1px solid #dcdcdc;
 
380
  padding-top: 25px;
 
381
  }
382
 
383
  .wcf-embed-checkout-form #order_review .wcf-coupon-col-1 {
@@ -477,7 +480,7 @@
477
  }
478
  .wcf-embed-checkout-form .woocommerce-checkout #order_review{
479
  display: inline-block;
480
- float: left;
481
  width: 45%;
482
  border: none;
483
  background-color: inherit/*#F6F6F6*/;
@@ -499,10 +502,10 @@
499
  .wcf-embed-checkout-form .woocommerce-checkout #payment{
500
  background-color: inherit;
501
  border:none;
502
- border-top: 1px solid;
503
  border-radius: 0px;
504
- border-color: #dcdcdc;
505
- padding-top: 20px;
506
  }
507
 
508
  .wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{
@@ -595,6 +598,11 @@
595
  margin-bottom: 8px;
596
  }
597
 
 
 
 
 
 
598
  .wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{
599
  font-family: inherit;
600
  font-weight:inherit;
23
  .wcf-embed-checkout-form .woocommerce form .form-row-full,
24
  .wcf-embed-checkout-form .woocommerce-page form .form-row-full{
25
  width: 100%;
26
+ clear: both;
27
  }
28
 
29
  /* To test divi and all */
375
 
376
  .wcf-embed-checkout-form .wcf-custom-coupon-field {
377
  display: flex;
378
+ margin-bottom: 15px;
379
  margin-top: 25px;
380
  border-top: 1px solid #dcdcdc;
381
+ border-bottom: 1px solid #dcdcdc;
382
  padding-top: 25px;
383
+ padding-bottom: 25px;
384
  }
385
 
386
  .wcf-embed-checkout-form #order_review .wcf-coupon-col-1 {
480
  }
481
  .wcf-embed-checkout-form .woocommerce-checkout #order_review{
482
  display: inline-block;
483
+ float: none;
484
  width: 45%;
485
  border: none;
486
  background-color: inherit/*#F6F6F6*/;
502
  .wcf-embed-checkout-form .woocommerce-checkout #payment{
503
  background-color: inherit;
504
  border:none;
505
+ /*border-top: 1px solid;*/
506
  border-radius: 0px;
507
+ /*border-color: #dcdcdc;*/
508
+ /*padding-top: 20px;*/
509
  }
510
 
511
  .wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{
598
  margin-bottom: 8px;
599
  }
600
 
601
+ .wcf-embed-checkout-form .woocommerce .woocommerce-terms-and-conditions-wrapper .woocommerce-terms-and-conditions-checkbox-text{
602
+ line-height: 20px;
603
+ text-transform: initial;
604
+ }
605
+
606
  .wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{
607
  font-family: inherit;
608
  font-weight:inherit;
assets/css/import-rtl.css CHANGED
@@ -35,21 +35,30 @@
35
 
36
  .template .notice {
37
  padding: .5em;
38
- background: #fff;
39
- color: initial;
40
  font-weight: normal;
 
 
41
  text-decoration: none;
42
  position: absolute;
 
 
 
43
  top: 50%;
44
- transform: translateY(-50%);
45
- left: 27%;
46
- right: 27%;
47
  z-index: 4;
48
  text-align: center;
49
  border-radius: 3px;
50
  transition: opacity .1s ease-in-out;
51
  }
52
 
 
 
 
 
53
  .preview:focus,
54
  .preview:hover {
55
  color: #fff;
@@ -764,25 +773,27 @@ html.wcf-popup-open{
764
  .wcf-templates-popup-content .wcf-template-header .wcf-tab-wrapper{
765
  margin: 0 auto;
766
  }
767
- #wcf-upcoming-page-builders {
768
  overflow-y: auto;
769
  max-height: 450px;
770
  padding: 20px 20px 20px 20px;
771
  clear: both;
772
- }
773
- #wcf-upcoming-page-builders h3 {
774
  font-size: 2em;
775
 
776
- }
777
- #wcf-upcoming-page-builders .inner {
778
  position: absolute;
779
  top: 40%;
780
- right: 50%;
781
- transform: translate(50%,-40%);
782
  width: auto;
783
- }
784
  #wcf-upcoming-page-builders .description {
785
  font-size: 1rem;
 
 
786
  }
787
  #wcf-remote-step-filters {
788
  padding: 0 15px;
35
 
36
  .template .notice {
37
  padding: .5em;
38
+ background: rgba(0,0,0,.7);
39
+ color: #fff;
40
  font-weight: normal;
41
+ border: navajowhite;
42
+ font-size: 11px;
43
  text-decoration: none;
44
  position: absolute;
45
+ width: 100%;
46
+ /* height: 100%; */
47
+ vertical-align: middle;
48
  top: 50%;
49
+ transform: translateY(-60%);
50
+ left: 0%;
51
+ right: 0%;
52
  z-index: 4;
53
  text-align: center;
54
  border-radius: 3px;
55
  transition: opacity .1s ease-in-out;
56
  }
57
 
58
+ #wcf_create_notice{
59
+ display: none;
60
+ }
61
+
62
  .preview:focus,
63
  .preview:hover {
64
  color: #fff;
773
  .wcf-templates-popup-content .wcf-template-header .wcf-tab-wrapper{
774
  margin: 0 auto;
775
  }
776
+ /*#wcf-upcoming-page-builders {
777
  overflow-y: auto;
778
  max-height: 450px;
779
  padding: 20px 20px 20px 20px;
780
  clear: both;
781
+ }*/
782
+ /*#wcf-upcoming-page-builders h3 {
783
  font-size: 2em;
784
 
785
+ }*/
786
+ /*#wcf-upcoming-page-builders .inner {
787
  position: absolute;
788
  top: 40%;
789
+ left: 50%;
790
+ transform: translate(-50%,-40%);
791
  width: auto;
792
+ }*/
793
  #wcf-upcoming-page-builders .description {
794
  font-size: 1rem;
795
+ margin: 4em 0 0 0;
796
+ text-align: center;
797
  }
798
  #wcf-remote-step-filters {
799
  padding: 0 15px;
assets/css/import.css CHANGED
@@ -35,21 +35,30 @@
35
 
36
  .template .notice {
37
  padding: .5em;
38
- background: #fff;
39
- color: initial;
40
  font-weight: normal;
 
 
41
  text-decoration: none;
42
  position: absolute;
 
 
 
43
  top: 50%;
44
- transform: translateY(-50%);
45
- right: 27%;
46
- left: 27%;
47
  z-index: 4;
48
  text-align: center;
49
  border-radius: 3px;
50
  transition: opacity .1s ease-in-out;
51
  }
52
 
 
 
 
 
53
  .preview:focus,
54
  .preview:hover {
55
  color: #fff;
35
 
36
  .template .notice {
37
  padding: .5em;
38
+ background: rgba(0,0,0,.7);
39
+ color: #fff;
40
  font-weight: normal;
41
+ border: navajowhite;
42
+ font-size: 11px;
43
  text-decoration: none;
44
  position: absolute;
45
+ width: 100%;
46
+ /* height: 100%; */
47
+ vertical-align: middle;
48
  top: 50%;
49
+ transform: translateY(-60%);
50
+ right: 0%;
51
+ left: 0%;
52
  z-index: 4;
53
  text-align: center;
54
  border-radius: 3px;
55
  transition: opacity .1s ease-in-out;
56
  }
57
 
58
+ #wcf_create_notice{
59
+ display: none;
60
+ }
61
+
62
  .preview:focus,
63
  .preview:hover {
64
  color: #fff;
assets/js/import.js CHANGED
@@ -976,11 +976,35 @@ var CartFlowsAjaxQueue = (function() {
976
  return;
977
  }
978
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
979
  $('#wcf-remote-step-importer').addClass('request-process');
980
 
981
  $('.cartflows-step-import').addClass('disabled');
982
  btn.addClass('importing updating-message').text('Creating..');
983
- btn.parents('.template').addClass('importing');
984
 
985
  // Process Import Page.
986
  if( $( 'body' ).hasClass( 'post-type-cartflows_flow' ) ) {
@@ -992,6 +1016,8 @@ var CartFlowsAjaxQueue = (function() {
992
  security : cartflows_admin.cf_step_create_blank_nonce
993
  };
994
 
 
 
995
  // Import Template AJAX.
996
  self._ajax( data, function( data ) {
997
 
@@ -1028,6 +1054,33 @@ var CartFlowsAjaxQueue = (function() {
1028
  btn = $('#wcf-remote-step-importer .cartflows-step-import.updating-message'),
1029
  self = CartFlowsImport;
1030
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1031
  var plugin_slug = '';
1032
  plugin = response.slug;
1033
 
976
  return;
977
  }
978
 
979
+ btn.parents('.template').addClass('importing');
980
+
981
+ if ( ! CartFlowsImportVars._is_pro_active ) {
982
+
983
+ if ( 'checkout' === step_type ) {
984
+ var checkout_steps = $( '.wcf-step-wrap[data-term-slug="checkout"]');
985
+
986
+ if ( 0 < checkout_steps.length ) {
987
+
988
+ var parent_template = btn.parents('.template.importing');
989
+
990
+ btn.removeClass('importing updating-message')
991
+ .text('Import Failed!');
992
+
993
+ var notice_wrap = parent_template.find('#wcf_create_notice').show();
994
+
995
+ notice_wrap.find('a')
996
+ .addClass('notice notice-warning ')
997
+ .text ( 'Upgrade to Pro for adding more than one Checkout step' );
998
+ return;
999
+ }
1000
+ }
1001
+ }
1002
+
1003
  $('#wcf-remote-step-importer').addClass('request-process');
1004
 
1005
  $('.cartflows-step-import').addClass('disabled');
1006
  btn.addClass('importing updating-message').text('Creating..');
1007
+
1008
 
1009
  // Process Import Page.
1010
  if( $( 'body' ).hasClass( 'post-type-cartflows_flow' ) ) {
1016
  security : cartflows_admin.cf_step_create_blank_nonce
1017
  };
1018
 
1019
+
1020
+
1021
  // Import Template AJAX.
1022
  self._ajax( data, function( data ) {
1023
 
1054
  btn = $('#wcf-remote-step-importer .cartflows-step-import.updating-message'),
1055
  self = CartFlowsImport;
1056
 
1057
+ if ( ! CartFlowsImportVars._is_pro_active ) {
1058
+
1059
+ if ( 'checkout' === step_slug ) {
1060
+
1061
+ var checkout_steps = $( '.wcf-step-wrap[data-term-slug="checkout"]');
1062
+
1063
+ if ( 0 < checkout_steps.length ) {
1064
+
1065
+ var parent_template = btn.parents('.template.importing');
1066
+
1067
+ btn.removeClass('importing updating-message')
1068
+ .text('Import Failed!');
1069
+
1070
+ parent_template.find('.preview').hide();
1071
+ var notice_wrap = parent_template.find('#wcf_create_notice')
1072
+ .show();
1073
+
1074
+ notice_wrap.find('a')
1075
+ .addClass('notice notice-warning ')
1076
+ .text ( 'Upgrade to Pro for adding more than one Checkout step' );
1077
+
1078
+ $('#wcf-remote-step-importer').removeClass('request-process');
1079
+ return;
1080
+ }
1081
+ }
1082
+ }
1083
+
1084
  var plugin_slug = '';
1085
  plugin = response.slug;
1086
 
cartflows.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
- /**
3
- * Plugin Name: CartFlows
4
- * Plugin URI: https://cartflows.com/
5
- * Description: Create beautiful checkout pages & sales flows for WooCommerce.
6
- * Version: 1.0.4
7
- * Author: CartFlows Inc
8
- * Author URI: https://cartflows.com/
9
- * Text Domain: cartflows
10
- * WC requires at least: 3.0
11
- * WC tested up to: 3.5.1
12
- *
13
- * @package CartFlows
14
- */
15
-
16
- /**
17
- * Set constants.
18
- */
19
- define( 'CARTFLOWS_FILE', __FILE__ );
20
-
21
- /**
22
- * Extensions
23
- */
24
- require_once 'classes/class-cartflows-loader.php';
1
+ <?php
2
+ /**
3
+ * Plugin Name: CartFlows
4
+ * Plugin URI: https://cartflows.com/
5
+ * Description: Create beautiful checkout pages & sales flows for WooCommerce.
6
+ * Version: 1.1.0
7
+ * Author: CartFlows Inc
8
+ * Author URI: https://cartflows.com/
9
+ * Text Domain: cartflows
10
+ * WC requires at least: 3.0
11
+ * WC tested up to: 3.5.1
12
+ *
13
+ * @package CartFlows
14
+ */
15
+
16
+ /**
17
+ * Set constants.
18
+ */
19
+ define( 'CARTFLOWS_FILE', __FILE__ );
20
+
21
+ /**
22
+ * Extensions
23
+ */
24
+ require_once 'classes/class-cartflows-loader.php';
changelog.txt CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  Version 1.0.4 - Friday, 23rd November 2018
2
  - Fix: Thank you page style meta option issue.
3
 
1
+ Version 1.1.0 - Wednesday, 5th December 2018
2
+ - New: Ready for Order Bump Positions.
3
+ - Improvement: PixelYourSite compatibility added.
4
+ - Fix: Elementor preview not working for some permalinks.
5
+ - Fix: Checkout field label alignment issue.
6
+ - Fix: Long field text overlap on mobile.
7
+
8
  Version 1.0.4 - Friday, 23rd November 2018
9
  - Fix: Thank you page style meta option issue.
10
 
classes/class-cartflows-admin-fields.php CHANGED
@@ -1,156 +1,157 @@
1
- <?php
2
- /**
3
- * CARTFLOWS Admin Fields.
4
- *
5
- * @package CARTFLOWS
6
- */
7
-
8
- /**
9
- * Class Cartflows_Admin_Fields.
10
- */
11
- class Cartflows_Admin_Fields {
12
-
13
- /**
14
- * Text Field
15
- *
16
- * @param array $args Args.
17
- * @return string
18
- */
19
- static public function text_field( $args ) {
20
-
21
- $id = $args['id'];
22
- $name = $args['name'];
23
- $title = $args['title'];
24
- $value = $args['value'];
25
-
26
- $output = '<div class="form-field">';
27
- $output .= '<label for="' . $id . '">' . $title . '</label>';
28
- $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
29
- $output .= '</div>';
30
-
31
- return $output;
32
- }
33
-
34
- /**
35
- * URL Field
36
- *
37
- * @param array $args Args.
38
- * @return string
39
- */
40
- static public function url_field( $args ) {
41
-
42
- $id = $args['id'];
43
- $name = $args['name'];
44
- $title = $args['title'];
45
- $value = $args['value'];
46
-
47
- $output = '<div class="form-field">';
48
- $output .= '<label for="' . $id . '">' . $title . '</label>';
49
- $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
50
- $output .= '</div>';
51
-
52
- return $output;
53
- }
54
-
55
- /**
56
- * Checkbox Field
57
- *
58
- * @param array $args Args.
59
- * @return string
60
- */
61
- static public function checkobox_field( $args ) {
62
-
63
- $id = $args['id'];
64
- $name = $args['name'];
65
- $title = $args['title'];
66
- $value = $args['value'];
67
-
68
- $output = '<div class="form-field">';
69
- $output .= '<label for="' . $id . '">';
70
- $output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
71
- $output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
72
- $output .= $title;
73
- $output .= '</label>';
74
- $output .= '</div>';
75
-
76
- return $output;
77
- }
78
-
79
- /**
80
- * Checkout Selection Field
81
- *
82
- * @param array $args Args.
83
- * @return string
84
- */
85
- static public function flow_checkout_selection_field( $args ) {
86
-
87
- $id = $args['id'];
88
- $name = $args['name'];
89
- $title = $args['title'];
90
- $value = $args['value'];
91
-
92
- $checkout_steps = get_posts(
93
- array(
94
- 'posts_per_page' => -1,
95
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
96
- 'post_status' => 'publish',
97
- 'orderby' => 'ID',
98
- 'order' => 'ASC',
99
- 'tax_query' => array(
100
- array(
101
- 'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
102
- 'field' => 'slug',
103
- 'terms' => 'checkout',
104
- ),
105
- ),
106
- )
107
- );
108
-
109
- $output = '<div class="form-field">';
110
-
111
- $output .= '<div class="form-field-label">';
112
- $output .= '<label for="' . $id . '">';
113
- $output .= $title;
114
- $output .= '</label>';
115
- $output .= '</div>';
116
-
117
- $output .= '<div class="form-field-data">';
118
- $output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
119
-
120
- if ( ! empty( $checkout_steps ) ) {
121
- $output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
122
- } else {
123
-
124
- $output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
125
- }
126
-
127
- foreach ( $checkout_steps as $index => $step_data ) {
128
-
129
- $output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
130
- }
131
-
132
- $output .= '</select>';
133
- $output .= '</div>';
134
-
135
- if ( '' !== $value ) {
136
- $output .= '<div class="form-field-actions">';
137
- $output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
138
- $output .= '<span class="dashicons dashicons-edit"></span>';
139
- $output .= '<span class="">Edit</span>';
140
- $output .= '</a>';
141
- $output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
142
- $output .= '<span class="dashicons dashicons-visibility"></span>';
143
- $output .= '<span class="">View</span>';
144
- $output .= '</a>';
145
- $output .= '</div>';
146
- }
147
-
148
- $output .= '<div class="form-field-desc">';
149
- $output .= '<p>' . __( 'Be sure not to add any products in the Global checkout page you select above.', 'cartflows' ) . '</p>';
150
- $output .= '</div>';
151
-
152
- $output .= '</div>';
153
-
154
- return $output;
155
- }
156
- }
 
1
+ <?php
2
+ /**
3
+ * CARTFLOWS Admin Fields.
4
+ *
5
+ * @package CARTFLOWS
6
+ */
7
+
8
+ /**
9
+ * Class Cartflows_Admin_Fields.
10
+ */
11
+ class Cartflows_Admin_Fields {
12
+
13
+ /**
14
+ * Text Field
15
+ *
16
+ * @param array $args Args.
17
+ * @return string
18
+ */
19
+ static public function text_field( $args ) {
20
+
21
+ $id = $args['id'];
22
+ $name = $args['name'];
23
+ $title = $args['title'];
24
+ $value = $args['value'];
25
+
26
+ $output = '<div class="form-field">';
27
+ $output .= '<label for="' . $id . '">' . $title . '</label>';
28
+ $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
29
+ $output .= '</div>';
30
+
31
+ return $output;
32
+ }
33
+
34
+ /**
35
+ * URL Field
36
+ *
37
+ * @param array $args Args.
38
+ * @return string
39
+ */
40
+ static public function url_field( $args ) {
41
+
42
+ $id = $args['id'];
43
+ $name = $args['name'];
44
+ $title = $args['title'];
45
+ $value = $args['value'];
46
+
47
+ $output = '<div class="form-field">';
48
+ $output .= '<label for="' . $id . '">' . $title . '</label>';
49
+ $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
50
+ $output .= '</div>';
51
+
52
+ return $output;
53
+ }
54
+
55
+ /**
56
+ * Checkbox Field
57
+ *
58
+ * @param array $args Args.
59
+ * @return string
60
+ */
61
+ static public function checkobox_field( $args ) {
62
+
63
+ $id = $args['id'];
64
+ $name = $args['name'];
65
+ $title = $args['title'];
66
+ $value = $args['value'];
67
+
68
+ $output = '<div class="form-field">';
69
+ $output .= '<label for="' . $id . '">';
70
+ $output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
71
+ $output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
72
+ $output .= $title;
73
+ $output .= '</label>';
74
+ $output .= '</div>';
75
+
76
+ return $output;
77
+ }
78
+
79
+ /**
80
+ * Checkout Selection Field
81
+ *
82
+ * @param array $args Args.
83
+ * @return string
84
+ */
85
+ static public function flow_checkout_selection_field( $args ) {
86
+
87
+ $id = $args['id'];
88
+ $name = $args['name'];
89
+ $title = $args['title'];
90
+ $value = $args['value'];
91
+
92
+ $checkout_steps = get_posts(
93
+ array(
94
+ 'posts_per_page' => -1,
95
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
96
+ 'post_status' => 'publish',
97
+ 'orderby' => 'ID',
98
+ 'order' => 'ASC',
99
+ 'tax_query' => array(
100
+ array(
101
+ 'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
102
+ 'field' => 'slug',
103
+ 'terms' => 'checkout',
104
+ ),
105
+ ),
106
+ )
107
+ );
108
+
109
+ $output = '<div class="form-field">';
110
+
111
+ $output .= '<div class="form-field-label">';
112
+ $output .= '<label for="' . $id . '">';
113
+ $output .= $title;
114
+ $output .= '</label>';
115
+ $output .= '</div>';
116
+
117
+ $output .= '<div class="form-field-data">';
118
+ $output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
119
+
120
+ if ( ! empty( $checkout_steps ) ) {
121
+ $output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
122
+ } else {
123
+
124
+ $output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
125
+ }
126
+
127
+ foreach ( $checkout_steps as $index => $step_data ) {
128
+
129
+ $output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
130
+ }
131
+
132
+ $output .= '</select>';
133
+ $output .= '</div>';
134
+
135
+ if ( '' !== $value ) {
136
+ $output .= '<div class="form-field-actions">';
137
+ $output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
138
+ $output .= '<span class="dashicons dashicons-edit"></span>';
139
+ $output .= '<span class="">Edit</span>';
140
+ $output .= '</a>';
141
+ $output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
142
+ $output .= '<span class="dashicons dashicons-visibility"></span>';
143
+ $output .= '<span class="">View</span>';
144
+ $output .= '</a>';
145
+ $output .= '</div>';
146
+ }
147
+
148
+ $output .= '<div class="form-field-desc">';
149
+ /* translators: %s: link */
150
+ $output .= '<p>' . sprintf( __( 'Be sure not to add any product in above selected Global Checkout step. Please read information about how to set up Global Checkout %1$shere%2$s.', 'cartflows' ), '<a href="https://cartflows.com/docs/global-checkout/" target="_blank">', '</a>' ) . '</p>';
151
+ $output .= '</div>';
152
+
153
+ $output .= '</div>';
154
+
155
+ return $output;
156
+ }
157
+ }
classes/class-cartflows-admin.php CHANGED
@@ -1,398 +1,398 @@
1
- <?php
2
- /**
3
- * CartFlows Admin.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Class Cartflows_Admin.
10
- */
11
- class Cartflows_Admin {
12
-
13
- /**
14
- * Calls on initialization
15
- *
16
- * @since 1.0.0
17
- */
18
- public static function init() {
19
-
20
- self::initialise_plugin();
21
- self::init_hooks();
22
- }
23
-
24
- /**
25
- * Init Hooks.
26
- *
27
- * @since 1.0.0
28
- * @return void
29
- */
30
- static public function init_hooks() {
31
-
32
- if ( ! is_admin() ) {
33
- return;
34
- }
35
-
36
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
37
-
38
- // Add CARTFLOWS menu option to admin.
39
- add_action( 'network_admin_menu', __CLASS__ . '::menu' );
40
- add_action( 'admin_menu', __CLASS__ . '::menu' );
41
- add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
42
-
43
- add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
44
-
45
- // Enqueue admin scripts.
46
- if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
47
-
48
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
49
-
50
- self::save_settings();
51
- }
52
-
53
- /* Global Addmin Script */
54
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
55
-
56
- add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
57
- }
58
-
59
- /**
60
- * Initialises the Plugin Name.
61
- *
62
- * @since 1.0.0
63
- * @return void
64
- */
65
- static public function initialise_plugin() {
66
-
67
- $name = 'Cartflows';
68
- $short_name = 'Cflows';
69
-
70
- define( 'CARTFLOWS_PLUGIN_NAME', $name );
71
- define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
72
- }
73
-
74
- /**
75
- * Renders the admin settings menu.
76
- *
77
- * @since 1.0.0
78
- * @return void
79
- */
80
- static public function menu() {
81
-
82
- if ( ! current_user_can( 'manage_options' ) ) {
83
- return;
84
- }
85
-
86
- add_menu_page(
87
- 'CartFlows',
88
- 'CartFlows',
89
- 'manage_options',
90
- CARTFLOWS_SLUG,
91
- __CLASS__ . '::render',
92
- 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
93
- 39.7
94
- );
95
-
96
- }
97
-
98
- /**
99
- * Add submenu to admin menu.
100
- *
101
- * @since 1.0.0
102
- */
103
- static function submenu() {
104
-
105
- $parent_slug = CARTFLOWS_SLUG;
106
- $page_title = __( 'Settings', 'cartflows' );
107
- $menu_title = __( 'Settings', 'cartflows' );
108
- $capability = 'manage_options';
109
- $menu_slug = 'cartflows_settings';
110
- $callback = __CLASS__ . '::render';
111
-
112
- add_submenu_page(
113
- $parent_slug,
114
- $page_title,
115
- $menu_title,
116
- $capability,
117
- $menu_slug,
118
- $callback
119
- );
120
- }
121
-
122
- /**
123
- * Renders the admin settings.
124
- *
125
- * @since 1.0.0
126
- * @return void
127
- */
128
- static public function render() {
129
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
130
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
131
- $action = str_replace( '_', '-', $action );
132
-
133
- // Enable header icon filter below.
134
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
135
-
136
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
137
- }
138
-
139
- /**
140
- * Renders the admin settings content.
141
- *
142
- * @since 1.0.0
143
- * @return void
144
- */
145
- static public function render_content() {
146
-
147
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
148
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
149
- $action = str_replace( '_', '-', $action );
150
- $action = 'general';
151
-
152
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
153
-
154
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
155
- }
156
-
157
- /**
158
- * Save Global Setting options.
159
- *
160
- * @since 1.0.0
161
- */
162
- static public function save_common_settings() {
163
-
164
- if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
165
-
166
- $url = $_SERVER['REQUEST_URI'];
167
- $input_settings = array();
168
- $new_settings = array();
169
-
170
- if ( isset( $_POST['_cartflows_common'] ) ) {
171
-
172
- $input_settings = $_POST['_cartflows_common'];
173
-
174
- // Loop through the input and sanitize each of the values.
175
- foreach ( $input_settings as $key => $val ) {
176
-
177
- if ( is_array( $val ) ) {
178
- foreach ( $val as $k => $v ) {
179
- $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
180
- }
181
- } else {
182
- $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
183
- }
184
- }
185
- }
186
-
187
- Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
188
-
189
- $query = array(
190
- 'message' => 'saved',
191
- );
192
-
193
- $redirect_to = add_query_arg( $query, $url );
194
-
195
- wp_redirect( $redirect_to );
196
- exit;
197
- } // End if statement.
198
- }
199
-
200
- /**
201
- * Check is cartflows admin.
202
- *
203
- * @since 1.0.0
204
- * @return boolean
205
- */
206
- static public function is_global_admin() {
207
-
208
- $current_screen = get_current_screen();
209
-
210
- if (
211
- is_object( $current_screen ) &&
212
- isset( $current_screen->post_type ) &&
213
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
214
- CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
215
- )
216
- ) {
217
- return true;
218
- }
219
- return false;
220
- }
221
-
222
- /**
223
- * Check is flow admin.
224
- *
225
- * @since 1.0.0
226
- * @return boolean
227
- */
228
- static public function is_flow_edit_admin() {
229
-
230
- $current_screen = get_current_screen();
231
-
232
- if (
233
- is_object( $current_screen ) &&
234
- isset( $current_screen->post_type ) &&
235
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
236
- isset( $current_screen->base ) &&
237
- ( 'post' === $current_screen->base )
238
- ) {
239
- return true;
240
- }
241
- return false;
242
- }
243
-
244
- /**
245
- * Global Admin Scripts.
246
- *
247
- * @since 1.0.0
248
- */
249
- static public function global_admin_scripts() {
250
-
251
- $localize = array(
252
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
253
- 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
254
- );
255
-
256
- wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
257
-
258
- if ( self::is_global_admin() ) {
259
-
260
- // Styles.
261
- wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
262
- wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
263
-
264
- wp_enqueue_script(
265
- 'wcf-global-admin',
266
- CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
267
- array( 'jquery' ),
268
- CARTFLOWS_VER,
269
- true
270
- );
271
-
272
- do_action( 'cartflows_global_admin_scripts' );
273
- }
274
- }
275
-
276
- /**
277
- * Global Admin Data.
278
- *
279
- * @since 1.0.0
280
- */
281
- static public function global_admin_data() {
282
-
283
- $current_screen = get_current_screen();
284
-
285
- if ( CARTFLOWS_FLOW_POST_TYPE !== $current_screen->post_type ) {
286
- return;
287
- }
288
-
289
- ?>
290
-
291
- <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
292
- <div class="wcf-templates-popup-content">
293
- <div class="spinner"></div>
294
- <div class="wcf-templates-wrap wcf-templates-wrap-flows">
295
-
296
- <div id="wcf-remote-flow-actions" class="wcf-template-header">
297
- <div class="wcf-template-logo-wrap">
298
- <span class="wcf-cartflows-logo-img">
299
- <span class="cartflows-icon"></span>
300
- </span>
301
- <span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
302
- </div>
303
- <div class="wcf-tab-wrapper">
304
- <div id="wcf-page-builders">
305
- <ul class="wcf-page-builder-links filter-links">
306
- <li><a href="#" class="current" data-id="elementor"><?php _e( 'Elementor', 'cartflows' ); ?></a></li>
307
- <li><a href="#" data-id="divi"><?php _e( 'Divi', 'cartflows' ); ?></a></li>
308
- <li><a href="#" data-id="bb"><?php _e( 'Beaver Builder', 'cartflows' ); ?></a></li>
309
- </ul>
310
- </div>
311
- <!-- <div id="wcf-remote-flow-filters">
312
- <div id="cartflows-flow-funnel-type"></div>
313
- </div> -->
314
- </div>
315
- <div class="wcf-popup-close-wrap">
316
- <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
317
- </div>
318
- </div>
319
- <!-- <div class="wcf-search-form">
320
- <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
321
- <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
322
- </div> -->
323
-
324
- <div id="wcf-remote-content">
325
- <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"></div>
326
- <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
327
- </div>
328
- </div>
329
- </div>
330
- </div>
331
-
332
- <?php
333
- }
334
-
335
- /**
336
- * Enqueues the needed CSS/JS for the builder's admin settings page.
337
- *
338
- * @since 1.0.0
339
- */
340
- static public function styles_scripts() {
341
-
342
- // Styles.
343
- wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
344
- wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
345
-
346
- // Script.
347
- wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
348
-
349
- $localize = array(
350
- 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
351
- );
352
-
353
- wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
354
- }
355
-
356
- /**
357
- * Save All admin settings here
358
- */
359
- static public function save_settings() {
360
-
361
- // Only admins can save settings.
362
- if ( ! current_user_can( 'manage_options' ) ) {
363
- return;
364
- }
365
-
366
- self::save_common_settings();
367
-
368
- // Let extensions hook into saving.
369
- do_action( 'cartflows_admin_settings_save' );
370
- }
371
-
372
- /**
373
- * Get and return page URL
374
- *
375
- * @param string $menu_slug Menu name.
376
- * @since 1.0.0
377
- * @return string page url
378
- */
379
- static public function get_page_url( $menu_slug ) {
380
-
381
- $parent_page = self::$default_menu_position;
382
-
383
- if ( strpos( $parent_page, '?' ) !== false ) {
384
- $query_var = '&page=' . self::$plugin_slug;
385
- } else {
386
- $query_var = '?page=' . self::$plugin_slug;
387
- }
388
-
389
- $parent_page_url = admin_url( $parent_page . $query_var );
390
-
391
- $url = $parent_page_url . '&action=' . $menu_slug;
392
-
393
- return esc_url( $url );
394
- }
395
-
396
- }
397
-
398
- Cartflows_Admin::init();
1
+ <?php
2
+ /**
3
+ * CartFlows Admin.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Class Cartflows_Admin.
10
+ */
11
+ class Cartflows_Admin {
12
+
13
+ /**
14
+ * Calls on initialization
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ public static function init() {
19
+
20
+ self::initialise_plugin();
21
+ self::init_hooks();
22
+ }
23
+
24
+ /**
25
+ * Init Hooks.
26
+ *
27
+ * @since 1.0.0
28
+ * @return void
29
+ */
30
+ static public function init_hooks() {
31
+
32
+ if ( ! is_admin() ) {
33
+ return;
34
+ }
35
+
36
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
37
+
38
+ // Add CARTFLOWS menu option to admin.
39
+ add_action( 'network_admin_menu', __CLASS__ . '::menu' );
40
+ add_action( 'admin_menu', __CLASS__ . '::menu' );
41
+ add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
42
+
43
+ add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
44
+
45
+ // Enqueue admin scripts.
46
+ if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
47
+
48
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
49
+
50
+ self::save_settings();
51
+ }
52
+
53
+ /* Global Addmin Script */
54
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
55
+
56
+ add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
57
+ }
58
+
59
+ /**
60
+ * Initialises the Plugin Name.
61
+ *
62
+ * @since 1.0.0
63
+ * @return void
64
+ */
65
+ static public function initialise_plugin() {
66
+
67
+ $name = 'Cartflows';
68
+ $short_name = 'Cflows';
69
+
70
+ define( 'CARTFLOWS_PLUGIN_NAME', $name );
71
+ define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
72
+ }
73
+
74
+ /**
75
+ * Renders the admin settings menu.
76
+ *
77
+ * @since 1.0.0
78
+ * @return void
79
+ */
80
+ static public function menu() {
81
+
82
+ if ( ! current_user_can( 'manage_options' ) ) {
83
+ return;
84
+ }
85
+
86
+ add_menu_page(
87
+ 'CartFlows',
88
+ 'CartFlows',
89
+ 'manage_options',
90
+ CARTFLOWS_SLUG,
91
+ __CLASS__ . '::render',
92
+ 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
93
+ 39.7
94
+ );
95
+
96
+ }
97
+
98
+ /**
99
+ * Add submenu to admin menu.
100
+ *
101
+ * @since 1.0.0
102
+ */
103
+ static function submenu() {
104
+
105
+ $parent_slug = CARTFLOWS_SLUG;
106
+ $page_title = __( 'Settings', 'cartflows' );
107
+ $menu_title = __( 'Settings', 'cartflows' );
108
+ $capability = 'manage_options';
109
+ $menu_slug = 'cartflows_settings';
110
+ $callback = __CLASS__ . '::render';
111
+
112
+ add_submenu_page(
113
+ $parent_slug,
114
+ $page_title,
115
+ $menu_title,
116
+ $capability,
117
+ $menu_slug,
118
+ $callback
119
+ );
120
+ }
121
+
122
+ /**
123
+ * Renders the admin settings.
124
+ *
125
+ * @since 1.0.0
126
+ * @return void
127
+ */
128
+ static public function render() {
129
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
130
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
131
+ $action = str_replace( '_', '-', $action );
132
+
133
+ // Enable header icon filter below.
134
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
135
+
136
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
137
+ }
138
+
139
+ /**
140
+ * Renders the admin settings content.
141
+ *
142
+ * @since 1.0.0
143
+ * @return void
144
+ */
145
+ static public function render_content() {
146
+
147
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
148
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
149
+ $action = str_replace( '_', '-', $action );
150
+ $action = 'general';
151
+
152
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
153
+
154
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
155
+ }
156
+
157
+ /**
158
+ * Save Global Setting options.
159
+ *
160
+ * @since 1.0.0
161
+ */
162
+ static public function save_common_settings() {
163
+
164
+ if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
165
+
166
+ $url = $_SERVER['REQUEST_URI'];
167
+ $input_settings = array();
168
+ $new_settings = array();
169
+
170
+ if ( isset( $_POST['_cartflows_common'] ) ) {
171
+
172
+ $input_settings = $_POST['_cartflows_common'];
173
+
174
+ // Loop through the input and sanitize each of the values.
175
+ foreach ( $input_settings as $key => $val ) {
176
+
177
+ if ( is_array( $val ) ) {
178
+ foreach ( $val as $k => $v ) {
179
+ $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
180
+ }
181
+ } else {
182
+ $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
183
+ }
184
+ }
185
+ }
186
+
187
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
188
+
189
+ $query = array(
190
+ 'message' => 'saved',
191
+ );
192
+
193
+ $redirect_to = add_query_arg( $query, $url );
194
+
195
+ wp_redirect( $redirect_to );
196
+ exit;
197
+ } // End if statement.
198
+ }
199
+
200
+ /**
201
+ * Check is cartflows admin.
202
+ *
203
+ * @since 1.0.0
204
+ * @return boolean
205
+ */
206
+ static public function is_global_admin() {
207
+
208
+ $current_screen = get_current_screen();
209
+
210
+ if (
211
+ is_object( $current_screen ) &&
212
+ isset( $current_screen->post_type ) &&
213
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
214
+ CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
215
+ )
216
+ ) {
217
+ return true;
218
+ }
219
+ return false;
220
+ }
221
+
222
+ /**
223
+ * Check is flow admin.
224
+ *
225
+ * @since 1.0.0
226
+ * @return boolean
227
+ */
228
+ static public function is_flow_edit_admin() {
229
+
230
+ $current_screen = get_current_screen();
231
+
232
+ if (
233
+ is_object( $current_screen ) &&
234
+ isset( $current_screen->post_type ) &&
235
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
236
+ isset( $current_screen->base ) &&
237
+ ( 'post' === $current_screen->base )
238
+ ) {
239
+ return true;
240
+ }
241
+ return false;
242
+ }
243
+
244
+ /**
245
+ * Global Admin Scripts.
246
+ *
247
+ * @since 1.0.0
248
+ */
249
+ static public function global_admin_scripts() {
250
+
251
+ $localize = array(
252
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
253
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
254
+ );
255
+
256
+ wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
257
+
258
+ if ( self::is_global_admin() ) {
259
+
260
+ // Styles.
261
+ wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
262
+ wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
263
+
264
+ wp_enqueue_script(
265
+ 'wcf-global-admin',
266
+ CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
267
+ array( 'jquery' ),
268
+ CARTFLOWS_VER,
269
+ true
270
+ );
271
+
272
+ do_action( 'cartflows_global_admin_scripts' );
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Global Admin Data.
278
+ *
279
+ * @since 1.0.0
280
+ */
281
+ static public function global_admin_data() {
282
+
283
+ $current_screen = get_current_screen();
284
+
285
+ if ( CARTFLOWS_FLOW_POST_TYPE !== $current_screen->post_type ) {
286
+ return;
287
+ }
288
+
289
+ ?>
290
+
291
+ <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
292
+ <div class="wcf-templates-popup-content">
293
+ <div class="spinner"></div>
294
+ <div class="wcf-templates-wrap wcf-templates-wrap-flows">
295
+
296
+ <div id="wcf-remote-flow-actions" class="wcf-template-header">
297
+ <div class="wcf-template-logo-wrap">
298
+ <span class="wcf-cartflows-logo-img">
299
+ <span class="cartflows-icon"></span>
300
+ </span>
301
+ <span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
302
+ </div>
303
+ <div class="wcf-tab-wrapper">
304
+ <div id="wcf-page-builders">
305
+ <ul class="wcf-page-builder-links filter-links">
306
+ <li><a href="#" class="current" data-id="elementor"><?php _e( 'Elementor', 'cartflows' ); ?></a></li>
307
+ <li><a href="#" data-id="divi"><?php _e( 'Divi', 'cartflows' ); ?></a></li>
308
+ <li><a href="#" data-id="bb"><?php _e( 'Beaver Builder', 'cartflows' ); ?></a></li>
309
+ </ul>
310
+ </div>
311
+ <!-- <div id="wcf-remote-flow-filters">
312
+ <div id="cartflows-flow-funnel-type"></div>
313
+ </div> -->
314
+ </div>
315
+ <div class="wcf-popup-close-wrap">
316
+ <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
317
+ </div>
318
+ </div>
319
+ <!-- <div class="wcf-search-form">
320
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
321
+ <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
322
+ </div> -->
323
+
324
+ <div id="wcf-remote-content">
325
+ <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"></div>
326
+ <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
327
+ </div>
328
+ </div>
329
+ </div>
330
+ </div>
331
+
332
+ <?php
333
+ }
334
+
335
+ /**
336
+ * Enqueues the needed CSS/JS for the builder's admin settings page.
337
+ *
338
+ * @since 1.0.0
339
+ */
340
+ static public function styles_scripts() {
341
+
342
+ // Styles.
343
+ wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
344
+ wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
345
+
346
+ // Script.
347
+ wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
348
+
349
+ $localize = array(
350
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
351
+ );
352
+
353
+ wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
354
+ }
355
+
356
+ /**
357
+ * Save All admin settings here
358
+ */
359
+ static public function save_settings() {
360
+
361
+ // Only admins can save settings.
362
+ if ( ! current_user_can( 'manage_options' ) ) {
363
+ return;
364
+ }
365
+
366
+ self::save_common_settings();
367
+
368
+ // Let extensions hook into saving.
369
+ do_action( 'cartflows_admin_settings_save' );
370
+ }
371
+
372
+ /**
373
+ * Get and return page URL
374
+ *
375
+ * @param string $menu_slug Menu name.
376
+ * @since 1.0.0
377
+ * @return string page url
378
+ */
379
+ static public function get_page_url( $menu_slug ) {
380
+
381
+ $parent_page = self::$default_menu_position;
382
+
383
+ if ( strpos( $parent_page, '?' ) !== false ) {
384
+ $query_var = '&page=' . self::$plugin_slug;
385
+ } else {
386
+ $query_var = '?page=' . self::$plugin_slug;
387
+ }
388
+
389
+ $parent_page_url = admin_url( $parent_page . $query_var );
390
+
391
+ $url = $parent_page_url . '&action=' . $menu_slug;
392
+
393
+ return esc_url( $url );
394
+ }
395
+
396
+ }
397
+
398
+ Cartflows_Admin::init();
classes/class-cartflows-bsf-updater.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
- /**
3
- * Main builder BSF Updater class.
4
- *
5
- * @package cartflows
6
- */
7
-
8
- // Prohibit direct script loading.
9
- defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
10
- if ( ! class_exists( 'Cartflows_Bsf_Updater' ) ) {
11
- /**
12
- * Class Cartflows_Bsf_Updater.
13
- */
14
- class Cartflows_Bsf_Updater {
15
-
16
- /**
17
- * Constructor.
18
- */
19
- function __construct() {
20
-
21
- $this->set_bsf_path();
22
-
23
- add_filter( 'bsf_authors_list', array( $this, 'add_cartflows_author' ) );
24
-
25
- add_action( 'init', array( $this, 'bsf_core_load' ), 999 );
26
- add_filter( 'bsf_skip_braisntorm_menu', array( $this, 'skip_brainstorm_menu' ) );
27
- add_filter( 'bsf_skip_author_registration', array( $this, 'skip_brainstorm_menu' ) );
28
-
29
- // Disable license activation notice for cartflows.
30
- add_filter( 'bsf_display_product_activation_notice_cartflows', '__return_false' );
31
- }
32
-
33
- /**
34
- * Function Name: add_cartflows_author.
35
- * Function Description: Adds cartflows author to get updates.
36
- *
37
- * @param array $authors authors array.
38
- */
39
- public function add_cartflows_author( $authors ) {
40
-
41
- $authors[] = 'CartFlows Inc';
42
- return $authors;
43
- }
44
-
45
- /**
46
- * Function Name: set_bsf_path.
47
- * Function Description: Set path.
48
- */
49
- public function set_bsf_path() {
50
-
51
- $bsf_core_version_file = CARTFLOWS_DIR . 'admin/bsf-core/version.yml';
52
-
53
- if ( is_file( $bsf_core_version_file ) ) {
54
- global $bsf_core_version, $bsf_core_path;
55
- $bsf_core_dir = CARTFLOWS_DIR . 'admin/bsf-core/';
56
- $version = file_get_contents( $bsf_core_version_file );
57
- if ( version_compare( $version, $bsf_core_version, '>' ) ) {
58
- $bsf_core_version = $version;
59
- $bsf_core_path = $bsf_core_dir;
60
- }
61
- }
62
- }
63
-
64
- /**
65
- * Function Name: bsf_core_load.
66
- * Function Description: Load Core.
67
- */
68
- public function bsf_core_load() {
69
- global $bsf_core_version, $bsf_core_path;
70
-
71
- if ( is_file( realpath( $bsf_core_path . '/index.php' ) ) ) {
72
- include_once realpath( $bsf_core_path . '/index.php' );
73
- }
74
- }
75
-
76
- /**
77
- * Function Name: bsf_get_option.
78
- * Function Description: Get options.
79
- *
80
- * @param Boolean $request true or false.
81
- */
82
- public function bsf_get_option( $request = false ) {
83
- $bsf_options = get_option( 'bsf_options' );
84
- if ( ! $request ) {
85
- return $bsf_options;
86
- } else {
87
- return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false;
88
- }
89
- }
90
-
91
- /**
92
- * Function Name: skip_brainstorm_menu.
93
- * Function Description: skip_brainstorm_menu.
94
- *
95
- * @param string $products products.
96
- */
97
- public function skip_brainstorm_menu( $products ) {
98
-
99
- $product_id = 'cartflows';
100
- $products[] = $product_id;
101
-
102
- return $products;
103
- }
104
-
105
- }
106
- }
107
-
108
- if ( class_exists( 'Cartflows_Bsf_Updater' ) ) {
109
- new Cartflows_Bsf_Updater();
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cartflows-frontend.php CHANGED
@@ -1,319 +1,325 @@
1
- <?php
2
- /**
3
- * CartFlows Frontend.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Class Cartflows_Frontend.
10
- */
11
- class Cartflows_Frontend {
12
-
13
- /**
14
- * Member Variable
15
- *
16
- * @var instance
17
- */
18
- private static $instance;
19
-
20
- /**
21
- * Initiator
22
- */
23
- public static function get_instance() {
24
- if ( ! isset( self::$instance ) ) {
25
- self::$instance = new self;
26
- }
27
- return self::$instance;
28
- }
29
-
30
- /**
31
- * Constructor
32
- */
33
- public function __construct() {
34
-
35
- /* Set / Destroy Flow Sessions. Set data */
36
- add_action( 'wp', array( $this, 'init_actions' ), 1 );
37
-
38
- /* Enqueue global required scripts */
39
- add_action( 'wp', array( $this, 'wp_actions' ), 55 );
40
-
41
- /* Modify the checkout order received url to go thank you page in our flow */
42
- add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
43
-
44
- add_filter( 'woocommerce_get_cancel_order_url_raw', array( $this, 'redirect_to_checkout_on_cancel' ), 10 );
45
-
46
- }
47
-
48
- /**
49
- * Redirect to thank page if upsell not exists
50
- *
51
- * @param string $order_recieve_url url.
52
- * @param object $order order object.
53
- * @since 1.0.0
54
- */
55
- function redirect_to_thankyou_page( $order_recieve_url, $order ) {
56
-
57
- /* Only for thank you page */
58
- wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
59
- wcf()->logger->log( 'Only for thank you page' );
60
-
61
- if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
62
-
63
- if ( _is_wcf_doing_checkout_ajax() ) {
64
-
65
- $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
66
-
67
- if ( ! $checkout_id ) {
68
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
69
- }
70
- } else {
71
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
72
- }
73
-
74
- wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
75
-
76
- if ( $checkout_id ) {
77
-
78
- $thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
79
-
80
- if ( $thankyou_step_id ) {
81
-
82
- $order_recieve_url = get_permalink( $thankyou_step_id );
83
-
84
- $order_recieve_url = add_query_arg(
85
- array(
86
- 'wcf-order' => $order->get_id(),
87
- 'wcf-key' => $order->get_order_key(),
88
- ),
89
- $order_recieve_url
90
- );
91
- }
92
- }
93
- }
94
-
95
- wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
96
-
97
- return $order_recieve_url;
98
- }
99
-
100
- /**
101
- * Cancel and redirect to checkout
102
- *
103
- * @param string $return_url url.
104
- * @since 1.0.0
105
- */
106
- function redirect_to_checkout_on_cancel( $return_url ) {
107
-
108
- if ( _is_wcf_doing_checkout_ajax() ) {
109
-
110
- $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
111
-
112
- if ( ! $checkout_id ) {
113
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
114
- }
115
- } else {
116
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
117
- }
118
-
119
- if ( $checkout_id ) {
120
-
121
- $return_url = add_query_arg(
122
- array(
123
- 'cancel_order' => 'true',
124
- '_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
125
- ),
126
- get_permalink( $checkout_id )
127
- );
128
- }
129
-
130
- return $return_url;
131
- }
132
-
133
-
134
- /**
135
- * Remove theme styles.
136
- *
137
- * @since 1.0.0
138
- */
139
- function remove_theme_styles() {
140
-
141
- // get all styles data.
142
- global $wp_styles;
143
- global $wp_scripts;
144
-
145
- $get_stylesheet = get_stylesheet();
146
- $get_template = get_template();
147
-
148
- if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
149
- return;
150
- }
151
-
152
- $get_stylesheet = 'themes/' . get_stylesheet();
153
- $get_template = 'themes/' . get_template();
154
-
155
- // loop over all of the registered scripts..
156
- foreach ( $wp_styles->registered as $handle => $data ) {
157
-
158
- if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
159
-
160
- // remove it.
161
- wp_deregister_style( $handle );
162
- wp_dequeue_style( $handle );
163
- }
164
- }
165
-
166
- // loop over all of the registered scripts.
167
- foreach ( $wp_scripts->registered as $handle => $data ) {
168
-
169
- if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
170
-
171
- // remove it.
172
- wp_deregister_script( $handle );
173
- wp_dequeue_script( $handle );
174
- }
175
- }
176
- }
177
-
178
- /**
179
- * Update main order data in transient.
180
- *
181
- * @param array $woo_styles new styles array.
182
- * @since 1.0.0
183
- * @return array.
184
- */
185
- function woo_default_css( $woo_styles ) {
186
-
187
- $woo_styles = array(
188
- 'woocommerce-layout' => array(
189
- 'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
190
- 'deps' => '',
191
- 'version' => WC_VERSION,
192
- 'media' => 'all',
193
- 'has_rtl' => true,
194
- ),
195
- 'woocommerce-smallscreen' => array(
196
- 'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
197
- 'deps' => 'woocommerce-layout',
198
- 'version' => WC_VERSION,
199
- 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
200
- 'has_rtl' => true,
201
- ),
202
- 'woocommerce-general' => array(
203
- 'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
204
- 'deps' => '',
205
- 'version' => WC_VERSION,
206
- 'media' => 'all',
207
- 'has_rtl' => true,
208
- ),
209
- );
210
-
211
- return $woo_styles;
212
- }
213
-
214
- /**
215
- * Init Actions.
216
- *
217
- * @since 1.0.0
218
- */
219
- function init_actions() {
220
-
221
- $this->set_flow_session();
222
- }
223
-
224
- /**
225
- * Set flow session.
226
- *
227
- * @since 1.0.0
228
- */
229
- function set_flow_session() {
230
-
231
- if ( wcf()->utils->is_step_post_type() ) {
232
-
233
- add_action( 'wp_head', array( $this, 'noindex_flow' ) );
234
-
235
- wcf()->utils->do_not_cache();
236
- }
237
- }
238
-
239
- /**
240
- * Add noindex, nofollow.
241
- *
242
- * @since 1.0.0
243
- */
244
- function noindex_flow() {
245
-
246
- $common = Cartflows_Helper::get_common_settings();
247
-
248
- if ( 'enable' === $common['disallow_indexing'] ) {
249
- echo '<meta name="robots" content="noindex,nofollow">';
250
- }
251
- }
252
-
253
- /**
254
- * WP Actions.
255
- *
256
- * @since 1.0.0
257
- */
258
- function wp_actions() {
259
-
260
- if ( wcf()->utils->is_step_post_type() ) {
261
-
262
- /* CSS Compatibility for All theme */
263
- add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
264
-
265
- add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
266
-
267
- add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
268
- }
269
-
270
- }
271
-
272
- /**
273
- * Global flow scripts.
274
- *
275
- * @since 1.0.0
276
- */
277
- function global_flow_scripts() {
278
-
279
- global $post;
280
-
281
- $flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
282
- $current_step = $post->ID;
283
- $next_step_link = '';
284
- $compatibility = Cartflows_Compatibility::get_instance();
285
-
286
- if ( _is_wcf_landing_type() ) {
287
-
288
- $next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
289
- $next_step_link = get_permalink( $next_step_id );
290
- }
291
-
292
- $localize = array(
293
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
294
- 'is_pb_preview' => $compatibility->is_page_builder_preview(),
295
- 'current_flow' => $flow,
296
- 'current_step' => $current_step,
297
- 'next_step' => $next_step_link,
298
- );
299
-
300
- wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
301
-
302
- wp_enqueue_style( 'wcf-frontend-global', CARTFLOWS_URL . 'assets/css/frontend.css', array(), CARTFLOWS_VER );
303
- wp_style_add_data( 'wcf-frontend-global', 'rtl', 'replace' );
304
-
305
- wp_enqueue_script(
306
- 'wcf-frontend-global',
307
- CARTFLOWS_URL . 'assets/js/frontend.js',
308
- array( 'jquery' ),
309
- CARTFLOWS_VER,
310
- true
311
- );
312
- }
313
- }
314
-
315
- /**
316
- * Prepare if class 'Cartflows_Frontend' exist.
317
- * Kicking this off by calling 'get_instance()' method
318
- */
319
- Cartflows_Frontend::get_instance();
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CartFlows Frontend.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Class Cartflows_Frontend.
10
+ */
11
+ class Cartflows_Frontend {
12
+
13
+ /**
14
+ * Member Variable
15
+ *
16
+ * @var instance
17
+ */
18
+ private static $instance;
19
+
20
+ /**
21
+ * Initiator
22
+ */
23
+ public static function get_instance() {
24
+ if ( ! isset( self::$instance ) ) {
25
+ self::$instance = new self;
26
+ }
27
+ return self::$instance;
28
+ }
29
+
30
+ /**
31
+ * Constructor
32
+ */
33
+ public function __construct() {
34
+
35
+ /* Set / Destroy Flow Sessions. Set data */
36
+ add_action( 'wp', array( $this, 'init_actions' ), 1 );
37
+
38
+ /* Enqueue global required scripts */
39
+ add_action( 'wp', array( $this, 'wp_actions' ), 55 );
40
+
41
+ /* Modify the checkout order received url to go thank you page in our flow */
42
+ add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
43
+
44
+ add_filter( 'woocommerce_get_cancel_order_url_raw', array( $this, 'redirect_to_checkout_on_cancel' ), 10 );
45
+
46
+ }
47
+
48
+ /**
49
+ * Redirect to thank page if upsell not exists
50
+ *
51
+ * @param string $order_recieve_url url.
52
+ * @param object $order order object.
53
+ * @since 1.0.0
54
+ */
55
+ function redirect_to_thankyou_page( $order_recieve_url, $order ) {
56
+
57
+ /* Only for thank you page */
58
+ wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
59
+ wcf()->logger->log( 'Only for thank you page' );
60
+
61
+ if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
62
+
63
+ if ( _is_wcf_doing_checkout_ajax() ) {
64
+
65
+ $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
66
+
67
+ if ( ! $checkout_id ) {
68
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
69
+ }
70
+ } else {
71
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
72
+ }
73
+
74
+ wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
75
+
76
+ if ( $checkout_id ) {
77
+
78
+ $thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
79
+
80
+ if ( $thankyou_step_id ) {
81
+
82
+ $order_recieve_url = get_permalink( $thankyou_step_id );
83
+
84
+ $order_recieve_url = add_query_arg(
85
+ array(
86
+ 'wcf-order' => $order->get_id(),
87
+ 'wcf-key' => $order->get_order_key(),
88
+ ),
89
+ $order_recieve_url
90
+ );
91
+ }
92
+ }
93
+ }
94
+
95
+ wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
96
+
97
+ return $order_recieve_url;
98
+ }
99
+
100
+ /**
101
+ * Cancel and redirect to checkout
102
+ *
103
+ * @param string $return_url url.
104
+ * @since 1.0.0
105
+ */
106
+ function redirect_to_checkout_on_cancel( $return_url ) {
107
+
108
+ if ( _is_wcf_doing_checkout_ajax() ) {
109
+
110
+ $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
111
+
112
+ if ( ! $checkout_id ) {
113
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
114
+ }
115
+ } else {
116
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
117
+ }
118
+
119
+ if ( $checkout_id ) {
120
+
121
+ $return_url = add_query_arg(
122
+ array(
123
+ 'cancel_order' => 'true',
124
+ '_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
125
+ ),
126
+ get_permalink( $checkout_id )
127
+ );
128
+ }
129
+
130
+ return $return_url;
131
+ }
132
+
133
+
134
+ /**
135
+ * Remove theme styles.
136
+ *
137
+ * @since 1.0.0
138
+ */
139
+ function remove_theme_styles() {
140
+
141
+ // get all styles data.
142
+ global $wp_styles;
143
+ global $wp_scripts;
144
+
145
+ $get_stylesheet = get_stylesheet();
146
+ $get_template = get_template();
147
+
148
+ if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
149
+ return;
150
+ }
151
+
152
+ $get_stylesheet = 'themes/' . get_stylesheet();
153
+ $get_template = 'themes/' . get_template();
154
+
155
+ // loop over all of the registered scripts..
156
+ foreach ( $wp_styles->registered as $handle => $data ) {
157
+
158
+ if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
159
+
160
+ // remove it.
161
+ wp_deregister_style( $handle );
162
+ wp_dequeue_style( $handle );
163
+ }
164
+ }
165
+
166
+ // loop over all of the registered scripts.
167
+ foreach ( $wp_scripts->registered as $handle => $data ) {
168
+
169
+ if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
170
+
171
+ // remove it.
172
+ wp_deregister_script( $handle );
173
+ wp_dequeue_script( $handle );
174
+ }
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Update main order data in transient.
180
+ *
181
+ * @param array $woo_styles new styles array.
182
+ * @since 1.0.0
183
+ * @return array.
184
+ */
185
+ function woo_default_css( $woo_styles ) {
186
+
187
+ $woo_styles = array(
188
+ 'woocommerce-layout' => array(
189
+ 'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
190
+ 'deps' => '',
191
+ 'version' => WC_VERSION,
192
+ 'media' => 'all',
193
+ 'has_rtl' => true,
194
+ ),
195
+ 'woocommerce-smallscreen' => array(
196
+ 'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
197
+ 'deps' => 'woocommerce-layout',
198
+ 'version' => WC_VERSION,
199
+ 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
200
+ 'has_rtl' => true,
201
+ ),
202
+ 'woocommerce-general' => array(
203
+ 'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
204
+ 'deps' => '',
205
+ 'version' => WC_VERSION,
206
+ 'media' => 'all',
207
+ 'has_rtl' => true,
208
+ ),
209
+ );
210
+
211
+ return $woo_styles;
212
+ }
213
+
214
+ /**
215
+ * Init Actions.
216
+ *
217
+ * @since 1.0.0
218
+ */
219
+ function init_actions() {
220
+
221
+ $this->set_flow_session();
222
+ }
223
+
224
+ /**
225
+ * Set flow session.
226
+ *
227
+ * @since 1.0.0
228
+ */
229
+ function set_flow_session() {
230
+
231
+ if ( wcf()->utils->is_step_post_type() ) {
232
+
233
+ add_action( 'wp_head', array( $this, 'noindex_flow' ) );
234
+
235
+ wcf()->utils->do_not_cache();
236
+
237
+ /* Set key to support pixel */
238
+ if ( isset( $_GET['wcf-key'] ) ) {
239
+ $_GET['key'] = $_GET['wcf-key'];
240
+ $_REQUEST['key'] = $_GET['wcf-key'];
241
+ }
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Add noindex, nofollow.
247
+ *
248
+ * @since 1.0.0
249
+ */
250
+ function noindex_flow() {
251
+
252
+ $common = Cartflows_Helper::get_common_settings();
253
+
254
+ if ( 'enable' === $common['disallow_indexing'] ) {
255
+ echo '<meta name="robots" content="noindex,nofollow">';
256
+ }
257
+ }
258
+
259
+ /**
260
+ * WP Actions.
261
+ *
262
+ * @since 1.0.0
263
+ */
264
+ function wp_actions() {
265
+
266
+ if ( wcf()->utils->is_step_post_type() ) {
267
+
268
+ /* CSS Compatibility for All theme */
269
+ add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
270
+
271
+ add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
272
+
273
+ add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
274
+ }
275
+
276
+ }
277
+
278
+ /**
279
+ * Global flow scripts.
280
+ *
281
+ * @since 1.0.0
282
+ */
283
+ function global_flow_scripts() {
284
+
285
+ global $post;
286
+
287
+ $flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
288
+ $current_step = $post->ID;
289
+ $next_step_link = '';
290
+ $compatibility = Cartflows_Compatibility::get_instance();
291
+
292
+ if ( _is_wcf_landing_type() ) {
293
+
294
+ $next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
295
+ $next_step_link = get_permalink( $next_step_id );
296
+ }
297
+
298
+ $localize = array(
299
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
300
+ 'is_pb_preview' => $compatibility->is_page_builder_preview(),
301
+ 'current_flow' => $flow,
302
+ 'current_step' => $current_step,
303
+ 'next_step' => $next_step_link,
304
+ );
305
+
306
+ wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
307
+
308
+ wp_enqueue_style( 'wcf-frontend-global', CARTFLOWS_URL . 'assets/css/frontend.css', array(), CARTFLOWS_VER );
309
+ wp_style_add_data( 'wcf-frontend-global', 'rtl', 'replace' );
310
+
311
+ wp_enqueue_script(
312
+ 'wcf-frontend-global',
313
+ CARTFLOWS_URL . 'assets/js/frontend.js',
314
+ array( 'jquery' ),
315
+ CARTFLOWS_VER,
316
+ true
317
+ );
318
+ }
319
+ }
320
+
321
+ /**
322
+ * Prepare if class 'Cartflows_Frontend' exist.
323
+ * Kicking this off by calling 'get_instance()' method
324
+ */
325
+ Cartflows_Frontend::get_instance();
classes/class-cartflows-importer.php CHANGED
@@ -1,1036 +1,1038 @@
1
- <?php
2
- /**
3
- * CartFlows Admin
4
- *
5
- * @package CartFlows
6
- * @since 1.0.0
7
- */
8
-
9
- if ( ! class_exists( 'CartFlows_Importer' ) ) :
10
-
11
- /**
12
- * CartFlows Import
13
- *
14
- * @since 1.0.0
15
- */
16
- class CartFlows_Importer {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.0.0
22
- * @access private
23
- * @var object Class object.
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Initiator
29
- *
30
- * @since 1.0.0
31
- * @return object initialized object of class.
32
- */
33
- public static function get_instance() {
34
- if ( ! isset( self::$instance ) ) {
35
- self::$instance = new self;
36
- }
37
-
38
- return self::$instance;
39
- }
40
-
41
- /**
42
- * Constructor
43
- *
44
- * @since 1.0.0
45
- */
46
- public function __construct() {
47
- add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
48
- add_action( 'wp_ajax_cartflows_load_steps', array( $this, 'load_templates' ) );
49
- add_action( 'wp_ajax_cartflows_step_import', array( $this, 'import_step' ) );
50
- add_action( 'wp_ajax_cartflows_create_flow', array( $this, 'create_flow' ) );
51
- add_action( 'wp_ajax_cartflows_default_flow', array( $this, 'create_default_flow' ) );
52
- add_action( 'wp_ajax_cartflows_step_create_blank', array( $this, 'step_create_blank' ) );
53
- add_action( 'wp_ajax_cartflows_import_flow_step', array( $this, 'import_flow' ) );
54
- add_action( 'admin_footer', array( $this, 'js_templates' ) );
55
- add_action( 'cartflows_import_complete', array( $this, 'clear_cache' ) );
56
-
57
- add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
58
-
59
- add_action( 'wp_ajax_cartflows_activate_plugin', array( $this, 'activate_plugin' ) );
60
- }
61
-
62
- /**
63
- * Clear Cache.
64
- *
65
- * @since 1.0.0
66
- */
67
- public function clear_cache() {
68
- // Clear 'Elementor' file cache.
69
- if ( class_exists( '\Elementor\Plugin' ) ) {
70
- Elementor\Plugin::$instance->files_manager->clear_cache();
71
- }
72
- }
73
-
74
- /**
75
- * JS Templates
76
- *
77
- * @since 1.0.0
78
- *
79
- * @return void
80
- */
81
- function js_templates() {
82
-
83
- // Loading Templates.
84
- ?>
85
- <script type="text/template" id="tmpl-cartflows-step-loading">
86
- <div class="template-message-block cartflows-step-loading">
87
- <h2>
88
- <span class="spinner"></span>
89
- <?php _e( 'Loading Steps', 'cartflows' ); ?>
90
- </h2>
91
- <p class="description"><?php _e( 'Getting steps from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
92
- </div>
93
- </script>
94
-
95
- <?php
96
- // Search Templates.
97
- ?>
98
- <script type="text/template" id="tmpl-cartflows-searching-templates">
99
- <div class="template-message-block cartflows-searching-templates">
100
- <h2>
101
- <span class="spinner"></span>
102
- <?php _e( 'Searching Template..', 'cartflows' ); ?>
103
- </h2>
104
- <p class="description"><?php _e( 'Getting templates from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
105
- </div>
106
- </script>
107
-
108
- <?php
109
- // CartFlows Importing Template.
110
- ?>
111
- <script type="text/template" id="tmpl-cartflows-step-importing">
112
- <div class="template-message-block cartflows-step-importing">
113
- <h2><span class="spinner"></span> <?php _e( 'Importing..', 'cartflows' ); ?></h2>
114
- </div>
115
- </script>
116
-
117
- <?php
118
- // CartFlows Imported.
119
- ?>
120
- <script type="text/template" id="tmpl-cartflows-step-imported">
121
- <div class="template-message-block cartflows-step-imported">
122
- <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
123
- <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span></p></div>
124
- </script>
125
-
126
- <?php
127
- // No templates.
128
- ?>
129
- <script type="text/template" id="tmpl-cartflows-no-steps">
130
- <div class="cartflows-no-steps">
131
- <div class="template-message-block">
132
- <h2><?php _e( 'Steps not found!', 'cartflows' ); ?></h2>
133
- <p class="description"><?php _e( 'We\'ll provide the ready made steps to import.', 'cartflows' ); ?></p>
134
- </div>
135
- </div>
136
- </script>
137
-
138
- <?php
139
- // No templates.
140
- ?>
141
- <script type="text/template" id="tmpl-cartflows-no-flows">
142
- <div class="cartflows-no-flows">
143
- <div class="template-message-block">
144
- <h2><?php _e( 'Flows not found!', 'cartflows' ); ?></h2>
145
- <p class="description"><?php _e( 'We\'ll provide the ready made flows to import.', 'cartflows' ); ?></p>
146
- </div>
147
- </div>
148
- </script>
149
-
150
- <?php
151
- // Error handling.
152
- ?>
153
- <script type="text/template" id="tmpl-templator-error">
154
- <div class="notice notice-error"><p>{{ data }}</p></div>
155
- </script>
156
-
157
- <?php
158
- // Redirect to Elementor.
159
- ?>
160
- <script type="text/template" id="tmpl-templator-redirect-to-elementor">
161
- <div class="template-message-block templator-redirect-to-elementor">
162
- <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
163
- <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span><br/><br/><?php _e( 'Redirecting to the Elementor edit window.', 'cartflows' ); ?> </p></div>
164
- </script>
165
-
166
- <?php
167
- /**
168
- * Responsive Buttons
169
- */
170
- ?>
171
- <script type="text/template" id="tmpl-cartflows-responsive-view">
172
- <span class="responsive-view">
173
- <span class="actions">
174
- <a class="desktop" href="#"><span data-view="desktop " class="active dashicons dashicons-desktop"></span></a>
175
- <a class="tablet" href="#"><span data-view="tablet" class="dashicons dashicons-tablet"></span></a>
176
- <a class="mobile" href="#"><span data-view="mobile" class="dashicons dashicons-smartphone"></span></a>
177
- </span>
178
- </span>
179
- </script>
180
-
181
- <?php
182
- /** Blank flow */
183
- ?>
184
- <script type="text/template" id="tmpl-cartflows-create-blank-flow">
185
- <div class="inner">
186
- <div class="template">
187
- <span class="thumbnail site-preview">
188
- <div class="template-screenshot">
189
- <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
190
- </div>
191
- </span>
192
- <div class="template-id-container">
193
- <h3 class="template-name"> <?php _e( 'Canvas', 'cartflows' ); ?> </h3>
194
- <div class="template-actions">
195
- <a href="#" class="button button-primary cartflows-flow-import-blank"><?php _e( 'Create Flow', 'cartflows' ); ?></a>
196
- </div>
197
- </div>
198
- </div>
199
- </div>
200
- </script>
201
-
202
- <?php
203
- // Templates data.
204
- $installed_plugins = get_plugins();
205
-
206
- $import_btn_title = __( 'Import', 'cartflows' );
207
-
208
- $required_plugins = array(
209
- 'elementor' => array(
210
- 'active' => is_plugin_active( 'elementor/elementor.php' ) ? 'yes' : 'no',
211
- 'install' => isset( $installed_plugins['elementor/elementor.php'] ) ? 'yes' : 'no',
212
- ),
213
- );
214
-
215
- if ( 'yes' == $required_plugins['elementor']['install'] && 'no' == $required_plugins['elementor']['active'] ) {
216
- $import_btn_title = __( 'Activate Elementor & Import', 'cartflows' );
217
- } elseif ( 'no' == $required_plugins['elementor']['install'] ) {
218
- $import_btn_title = __( 'Install Elementor & Import', 'cartflows' );
219
- }
220
-
221
- ?>
222
- <script type="text/template" id="tmpl-cartflows-flows-list">
223
-
224
- <# if ( data.items.length ) { #>
225
- <# for ( key in data.items ) { #>
226
- <#
227
- var flow_steps = [];
228
- if( data.items[ key ].flow_steps ) {
229
- flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
230
- return value['id'];
231
- });
232
- }
233
- #>
234
- <div class="inner">
235
- <div class="template">
236
- <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
237
- <div class="template-screenshot">
238
- <# if( data.items[ key ].featured_image_url ) { #>
239
- <img src="{{ data.items[ key ].featured_image_url }}" />
240
- <# } else { #>
241
- <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
242
- <# } #>
243
- </div>
244
- <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>flow={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
245
- <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
246
- <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
247
- <# } #>
248
- </span>
249
- <div class="template-id-container">
250
- <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
251
- <div class="template-actions">
252
-
253
- <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
254
- <a data-flow-steps="{{ flow_steps }}" data-required="<?php echo htmlspecialchars( json_encode( $required_plugins ), ENT_QUOTES, 'UTF-8' ); ?>" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}"><?php echo $import_btn_title; ?></a>
255
- <# } else if( CartFlowsImportVars._is_pro_active ) { #>
256
- <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
257
- <# } else { #>
258
- <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
259
- <# } #>
260
- </div>
261
- </div>
262
- </div>
263
- </div>
264
- <# } #>
265
- <# } #>
266
- </script>
267
-
268
- <?php
269
- // Empty Step.
270
- ?>
271
- <script type="text/template" id="tmpl-cartflows-create-blank-step">
272
- <div class="inner">
273
- <div class="template">
274
- <span class="thumbnail site-preview cartflows-flow-preview">
275
- <div class="template-screenshot">
276
- <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
277
- </div>
278
- </span>
279
- <div class="template-id-container">
280
- <h3 class="template-name"> Blank </h3>
281
- <div class="template-actions">
282
- <a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create', 'cartflows' ); ?></a>
283
- </div>
284
- </div>
285
- </div>
286
- </div>
287
- </script>
288
-
289
- <?php
290
- // Templates data.
291
- ?>
292
- <script type="text/template" id="tmpl-cartflows-steps-list">
293
- <# if ( data.items.length ) { #>
294
- <# for ( key in data.items ) { #>
295
- <#
296
- var flow_steps = [];
297
- if( data.items[ key ].flow_steps ) {
298
- flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
299
- return value['id'];
300
- });
301
- }
302
- #>
303
- <div class="inner">
304
- <div class="template">
305
- <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
306
- <div class="template-screenshot">
307
- <# if( data.items[ key ].featured_image_url ) { #>
308
- <img src="{{ data.items[ key ].featured_image_url }}" />
309
- <# } else { #>
310
- <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
311
- <# } #>
312
- </div>
313
- <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>step={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
314
- <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
315
- <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
316
- <# } #>
317
- </span>
318
- <div class="template-id-container">
319
- <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
320
- <div class="template-actions">
321
- <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
322
- <a data-required="<?php echo htmlspecialchars( json_encode( $required_plugins ), ENT_QUOTES, 'UTF-8' ); ?>" data-flow-steps="{{ flow_steps }}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}"><?php echo $import_btn_title; ?></a>
323
- <# } else if( CartFlowsImportVars._is_pro_active ) { #>
324
- <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
325
- <# } else { #>
326
- <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
327
- <# } #>
328
- </div>
329
- </div>
330
- </div>
331
- </div>
332
- <# } #>
333
- <# } #>
334
- </script>
335
-
336
- <?php
337
- /**
338
- * TMPL - Filters
339
- */
340
- ?>
341
- <script type="text/template" id="tmpl-cartflows-term-filters">
342
-
343
- <# if ( data ) { #>
344
-
345
- <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
346
-
347
- <# console.log( data.args.show_all ) #>
348
- <# if ( data.args.show_all ) { #>
349
- <li>
350
- <a href="#" data-group="all"> All </a>
351
- </li>
352
- <# } #>
353
-
354
- <# for ( key in data.items ) { #>
355
- <li>
356
- <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</a>
357
- </li>
358
- <# } #>
359
-
360
- </ul>
361
- <# } #>
362
- </script>
363
-
364
- <?php
365
- // Step Type.
366
- ?>
367
- <script type="text/template" id="tmpl-cartflows-step-types">
368
- <ul class="wcf-tab nav-tabs">
369
- <# if( data.items_count ) { #>
370
- <# for( key in data.items ) { #>
371
- <# console.log( data.items[ key ].id ) #>
372
- <li data-slug="{{data.items[ key ].slug}}" data-title="{{ data.items[ key ].name }}">
373
- <a href="#{{{ data.items[ key ].slug }}}">{{{ data.items[ key ].name }}}</a>
374
- </li>
375
- <# } #>
376
- <# } #>
377
- </ul>
378
- </script>
379
-
380
- <?php
381
- // Add to library button.
382
- ?>
383
- <script type="text/template" id="tmpl-templator-add-to-library">
384
- <a class="templator-add-to-library page-title-action cartflows-load-steps-library"><i class="dashicons dashicons-cloud"></i><?php esc_attr_e( 'Import from Cloud', 'cartflows' ); ?></a>
385
- </script>
386
- <?php
387
- }
388
-
389
- /**
390
- * Enqueue scripts
391
- *
392
- * @since 1.0.0
393
- *
394
- * @hook admin_enqueue_scripts
395
- * @param string $hook Current page hook.
396
- */
397
- function scripts( $hook = '' ) {
398
-
399
- if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
400
- return;
401
- }
402
-
403
- wp_enqueue_script( 'cartflows-rest-api', CARTFLOWS_URL . 'assets/js/rest-api.js', array( 'jquery' ), CARTFLOWS_VER, true );
404
- wp_enqueue_style( 'cartflows-import', CARTFLOWS_URL . 'assets/css/import.css', null, CARTFLOWS_VER, 'all' );
405
- wp_style_add_data( 'cartflows-import', 'rtl', 'replace' );
406
- wp_enqueue_script( 'cartflows-import', CARTFLOWS_URL . 'assets/js/import.js', array( 'jquery', 'wp-util', 'cartflows-rest-api', 'updates' ), CARTFLOWS_VER, true );
407
-
408
- $localize_vars = array(
409
- '_is_pro_active' => _is_cartflows_pro(),
410
-
411
- // Flow and its rest fields.
412
- 'flow' => CARTFLOWS_FLOW_POST_TYPE,
413
- 'flow_fields' => array(
414
- 'id',
415
- 'title',
416
- 'flow_type',
417
- 'flow_steps',
418
- 'licence_status',
419
- 'featured_image_url',
420
- 'featured_media', // @required for field `featured_image_url`.
421
- ),
422
-
423
- // Flow type and rest fields.
424
- 'flow_type' => CARTFLOWS_TAXONOMY_FLOW_CATEGORY,
425
- 'flow_type_fields' => array(
426
- 'id',
427
- 'name',
428
- 'slug',
429
- ),
430
-
431
- // Step and its rest fields.
432
- 'step' => CARTFLOWS_STEP_POST_TYPE,
433
- 'step_fields' => array(
434
- 'title',
435
- 'featured_image_url',
436
- 'featured_media', // @required for field `featured_image_url`.
437
- 'id',
438
- 'flow_type',
439
- 'licence_status',
440
- ),
441
-
442
- // Step type and its rest fields.
443
- 'step_type' => CARTFLOWS_TAXONOMY_STEP_TYPE,
444
- 'step_type_fields' => array(
445
- 'id',
446
- 'name',
447
- 'slug',
448
- ),
449
-
450
- 'domain_url' => CARTFLOWS_DOMAIN_URL,
451
- 'server_url' => CARTFLOWS_TEMPLATES_URL,
452
- 'server_rest_url' => CARTFLOWS_TEMPLATES_URL . 'wp-json/wp/v2/',
453
- 'site_url' => site_url(),
454
- 'admin_url' => admin_url(),
455
- 'licence_args' => CartFlows_API::get_instance()->get_licence_args(),
456
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
457
- 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
458
- );
459
-
460
- // Add thickbox.
461
- add_thickbox();
462
-
463
- wp_localize_script( 'cartflows-import', 'CartFlowsImportVars', $localize_vars );
464
- wp_localize_script( 'cartflows-rest-api', 'CartFlowsImportVars', $localize_vars );
465
- }
466
-
467
- /**
468
- * Load Template
469
- *
470
- * @since 1.0.0
471
- *
472
- * @hook cartflows_load_steps
473
- * @return void
474
- */
475
- function load_templates() {
476
-
477
- check_ajax_referer( 'cf-load-steps', 'security' );
478
-
479
- $args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array();
480
- $templates = CartFlows_API::get_instance()->get_templates( $args );
481
-
482
- if ( $templates['templates_count'] ) {
483
- wp_send_json_success( $templates );
484
- } else {
485
- wp_send_json_error( $templates );
486
- }
487
- wp_die();
488
- }
489
-
490
- /**
491
- * Import.
492
- *
493
- * @since 1.0.0
494
- *
495
- * @hook wp_ajax_cartflows_import_flow_step
496
- * @return void
497
- */
498
- function import_flow() {
499
-
500
- check_ajax_referer( 'cf-import-flow-step', 'security' );
501
-
502
- $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
503
- $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
504
-
505
- wcf()->logger->import_log( '------------------------------------' );
506
- wcf()->logger->import_log( 'STARTED! Importing FLOW' );
507
- wcf()->logger->import_log( '------------------------------------' );
508
- wcf()->logger->import_log( '(✓) Creating new step from remote step [' . $template_id . '] for FLOW ' . get_the_title( $flow_id ) . ' [' . $flow_id . ']' );
509
-
510
- $response = CartFlows_API::get_instance()->get_template( $template_id );
511
-
512
- if ( false === $response['success'] ) {
513
- wcf()->logger->import_log( '(✕) Failed to fetch remote data.' );
514
- wp_send_json_error( $response );
515
- }
516
-
517
- wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . json_encode( $response ) );
518
-
519
- $new_step_id = wp_insert_post(
520
- array(
521
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
522
- 'post_title' => $response['title'],
523
- 'post_content' => '',
524
- 'post_status' => 'publish',
525
- )
526
- );
527
-
528
- if ( is_wp_error( $new_step_id ) ) {
529
- wcf()->logger->import_log( '(✕) Failed to create new step for flow ' . $flow_id );
530
- wp_send_json_error( $new_step_id );
531
- }
532
-
533
- wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );
534
- // insert post meta.
535
- update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
536
- wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
537
-
538
- /**
539
- * Import & Set type.
540
- */
541
- $term = isset( $response['data']['step_type'] ) ? $response['data']['step_type'] : '';
542
- $term_slug = '';
543
- if ( $term ) {
544
-
545
- $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
546
- $term_exist = term_exists( $term->name, $taxonomy );
547
-
548
- if ( empty( $term_exist ) ) {
549
- $terms = array(
550
- array(
551
- 'name' => $term->name,
552
- ),
553
- );
554
-
555
- Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
556
- wcf()->logger->import_log( '(✓) Created new term ' . $term->name );
557
- }
558
-
559
- $current_term = term_exists( $term->name, $taxonomy );
560
-
561
- // Set type object.
562
- $data = get_term( $current_term['term_id'], $taxonomy );
563
- $term_slug = $data->slug;
564
- $term_name = $data->name;
565
- wp_set_object_terms( $new_step_id, $term_slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
566
- wcf()->logger->import_log( '(✓) Assigned existing term ' . $term_name . ' to the template ' . $new_step_id );
567
-
568
- // Set type.
569
- update_post_meta( $new_step_id, 'wcf-step-type', $term_slug );
570
- wcf()->logger->import_log( '(✓) Updated term ' . $term_name . ' to the post meta wcf-step-type.' );
571
- }
572
-
573
- // Set flow.
574
- wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
575
- wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
576
-
577
- /**
578
- * Update steps for the current flow.
579
- */
580
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
581
-
582
- if ( ! is_array( $flow_steps ) ) {
583
- $flow_steps = array();
584
- }
585
-
586
- $flow_steps[] = array(
587
- 'id' => $new_step_id,
588
- 'title' => $response['title'],
589
- 'type' => $term_slug,
590
- );
591
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
592
- wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
593
-
594
- // Import Post Meta.
595
- self::import_post_meta( $new_step_id, $response );
596
-
597
- wcf()->logger->import_log( '(✓) Importing step "' . get_the_title( $new_step_id ) . '" [' . $new_step_id . '] for FLOW "' . get_the_title( $flow_id ) . '" [' . $flow_id . ']' );
598
- wcf()->logger->import_log( '------------------------------------' );
599
- wcf()->logger->import_log( 'COMPLETE! Importing FLOW' );
600
- wcf()->logger->import_log( '------------------------------------' );
601
-
602
- do_action( 'cartflows_import_complete' );
603
- wcf()->logger->import_log( '(✓) BATCH STARTED for step ' . $new_step_id . ' for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
604
-
605
- // Batch Process.
606
- do_action( 'cartflows_after_template_import', $new_step_id, $response );
607
-
608
- /**
609
- * End
610
- */
611
- wp_send_json_success( $new_step_id );
612
- }
613
-
614
- /**
615
- * Import Step.
616
- *
617
- * @since 1.0.0
618
- * @hook wp_ajax_cartflows_step_import
619
- *
620
- * @return void
621
- */
622
- function create_default_flow() {
623
-
624
- check_ajax_referer( 'cf-default-flow', 'security' );
625
-
626
- // Create post object.
627
- $new_flow_post = array(
628
- 'post_content' => '',
629
- 'post_status' => 'publish',
630
- 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
631
- );
632
-
633
- // Insert the post into the database.
634
- $flow_id = wp_insert_post( $new_flow_post );
635
-
636
- if ( is_wp_error( $flow_id ) ) {
637
- wp_send_json_error( $flow_id->get_error_message() );
638
- }
639
-
640
- $flow_steps = array();
641
-
642
- $steps_data = array(
643
- 'landing' => __( 'Landing Page', 'cartflows' ),
644
- 'checkout' => __( 'Checkout Page', 'cartflows' ),
645
- 'thankyou' => __( 'Thank You Page', 'cartflows' ),
646
- );
647
-
648
- foreach ( $steps_data as $slug => $title ) {
649
-
650
- $post_content = '';
651
-
652
- switch ( $slug ) {
653
- case 'checkout':
654
- $post_content = '';
655
- break;
656
- case 'thankyou':
657
- $post_content = '';
658
- break;
659
- default:
660
- $post_content = '';
661
- break;
662
- }
663
-
664
- $step_id = wp_insert_post(
665
- array(
666
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
667
- 'post_title' => $title,
668
- 'post_content' => $post_content,
669
- 'post_status' => 'publish',
670
- )
671
- );
672
-
673
- if ( is_wp_error( $step_id ) ) {
674
- wp_send_json_error( $step_id->get_error_message() );
675
- }
676
-
677
- if ( $step_id ) {
678
-
679
- $flow_steps[] = array(
680
- 'id' => $step_id,
681
- 'title' => $title,
682
- 'type' => $slug,
683
- );
684
-
685
- // insert post meta.
686
- update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
687
- update_post_meta( $step_id, 'wcf-step-type', $slug );
688
-
689
- wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
690
- wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
691
- }
692
- }
693
-
694
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
695
-
696
- wp_send_json_success( $flow_id );
697
- }
698
-
699
- /**
700
- * Create Flow
701
- *
702
- * @return void
703
- */
704
- function create_flow() {
705
-
706
- check_ajax_referer( 'cf-create-flow', 'security' );
707
-
708
- // Create post object.
709
- $new_flow_post = array(
710
- 'post_content' => '',
711
- 'post_status' => 'publish',
712
- 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
713
- );
714
-
715
- // Insert the post into the database.
716
- $flow_id = wp_insert_post( $new_flow_post );
717
-
718
- if ( is_wp_error( $flow_id ) ) {
719
- wp_send_json_error( $flow_id->get_error_message() );
720
- }
721
-
722
- wp_send_json_success( $flow_id );
723
- }
724
-
725
- /**
726
- * Create Step
727
- *
728
- * @return void
729
- */
730
- function import_step() {
731
-
732
- check_ajax_referer( 'cf-step-import', 'security' );
733
-
734
- $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
735
- $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
736
- $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
737
- $step_type = isset( $_POST['step_type'] ) ? sanitize_title( $_POST['step_type'] ) : '';
738
- $step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( $_POST['step_custom_title'] ) : $step_title;
739
-
740
- $cartflow_meta = Cartflows_Flow_Meta::get_instance();
741
-
742
- $post_id = $cartflow_meta->create_step( $flow_id, $step_type, $step_custom_title );
743
-
744
- wcf()->logger->import_log( '------------------------------------' );
745
- wcf()->logger->import_log( 'STARTED! Importing STEP' );
746
- wcf()->logger->import_log( '------------------------------------' );
747
-
748
- if ( empty( $template_id ) || empty( $post_id ) ) {
749
- /* translators: %s: template ID */
750
- $data = sprintf( __( 'Invalid template id %1$s or post id %2$s.', 'cartflows' ), $template_id, $post_id );
751
- wcf()->logger->import_log( $data );
752
- wp_send_json_error( $data );
753
- }
754
-
755
- wcf()->logger->import_log( 'Remote Step ' . $template_id . ' for local flow "' . get_the_title( $post_id ) . '" [' . $post_id . ']' );
756
-
757
- $response = CartFlows_API::get_instance()->get_template( $template_id );
758
-
759
- wcf()->logger->import_log( json_encode( $response ) );
760
-
761
- // Import Post Meta.
762
- self::import_post_meta( $post_id, $response );
763
-
764
- do_action( 'cartflows_import_complete' );
765
-
766
- // Batch Process.
767
- do_action( 'cartflows_after_template_import', $post_id, $response );
768
-
769
- wcf()->logger->import_log( '------------------------------------' );
770
- wcf()->logger->import_log( 'COMPLETE! Importing Step' );
771
- wcf()->logger->import_log( '------------------------------------' );
772
-
773
- wp_send_json_success( $post_id );
774
- }
775
-
776
- /**
777
- * Import Step.
778
- *
779
- * @since 1.0.0
780
- * @hook wp_ajax_cartflows_step_create_blank
781
- *
782
- * @return void
783
- */
784
- function step_create_blank() {
785
-
786
- check_ajax_referer( 'cf-step-create-blank', 'security' );
787
-
788
- $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
789
- $step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( $_POST['step_type'] ) : '';
790
- $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
791
-
792
- if ( empty( $flow_id ) || empty( $step_type ) ) {
793
- /* translators: %s: flow ID */
794
- $data = sprintf( __( 'Invalid flow id %1$s or step type %2$s.', 'cartflows' ), $flow_id, $step_type );
795
- wcf()->logger->import_log( $data );
796
- wp_send_json_error( $data );
797
- }
798
-
799
- wcf()->logger->import_log( '------------------------------------' );
800
- wcf()->logger->import_log( 'STARTED! Creating Blank STEP for Flow ' . $flow_id );
801
-
802
- $step_type_title = str_replace( '-', ' ', $step_type );
803
- $step_type_slug = strtolower( str_replace( '-', ' ', $step_type ) );
804
-
805
- $new_step_id = wp_insert_post(
806
- array(
807
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
808
- 'post_title' => $step_title,
809
- 'post_content' => '',
810
- 'post_status' => 'publish',
811
- )
812
- );
813
-
814
- // insert post meta.
815
- update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
816
-
817
- $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
818
- $term_exist = term_exists( $step_type_title, $taxonomy );
819
-
820
- if ( empty( $term_exist ) ) {
821
- $terms = array(
822
- array(
823
- 'name' => $step_type_title,
824
- ),
825
- );
826
-
827
- Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
828
- wcf()->logger->import_log( '(✓) Created new term ' . $step_type_title );
829
- }
830
-
831
- $current_term = term_exists( $step_type_title, $taxonomy );
832
-
833
- // Set type object.
834
- $data = get_term( $current_term['term_id'], $taxonomy );
835
- $step_slug = $data->slug;
836
- wp_set_object_terms( $new_step_id, $data->slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
837
- wcf()->logger->import_log( '(✓) Assigned existing term ' . $step_type_title . ' to the template ' . $new_step_id );
838
-
839
- // Set type.
840
- update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
841
- wcf()->logger->import_log( '(✓) Updated term ' . $data->name . ' to the post meta wcf-step-type.' );
842
-
843
- // Set flow.
844
- wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
845
- wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
846
-
847
- CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step_type_title, $step_slug );
848
-
849
- wcf()->logger->import_log( 'COMPLETE! Creating Blank STEP for Flow ' . $flow_id );
850
- wcf()->logger->import_log( '------------------------------------' );
851
-
852
- wp_send_json_success( $new_step_id );
853
- }
854
-
855
- /**
856
- * Import Post Meta
857
- *
858
- * @since 1.0.0
859
- *
860
- * @param integer $post_id Post ID.
861
- * @param array $response Post meta.
862
- * @return void
863
- */
864
- public static function import_post_meta( $post_id, $response ) {
865
-
866
- $metadata = (array) $response['post_meta'];
867
-
868
- foreach ( $metadata as $meta_key => $meta_value ) {
869
- $meta_value = isset( $meta_value[0] ) ? $meta_value[0] : '';
870
-
871
- if ( $meta_value ) {
872
-
873
- if ( is_serialized( $meta_value, true ) ) {
874
- $raw_data = maybe_unserialize( stripslashes( $meta_value ) );
875
- } elseif ( is_array( $meta_value ) ) {
876
- $raw_data = json_decode( stripslashes( $meta_value ), true );
877
- } else {
878
- $raw_data = $meta_value;
879
- }
880
-
881
- if ( '_elementor_data' === $meta_key ) {
882
-
883
- if ( is_array( $raw_data ) ) {
884
- $raw_data = wp_slash( json_encode( $raw_data ) );
885
- } else {
886
- $raw_data = wp_slash( $raw_data );
887
- }
888
- wcf()->logger->import_log( $raw_data );
889
- }
890
-
891
- if ( is_array( $raw_data ) ) {
892
- wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . json_encode( $raw_data ) );
893
- } else {
894
- wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
895
- }
896
-
897
- update_post_meta( $post_id, $meta_key, $raw_data );
898
- }
899
- }
900
- }
901
-
902
- /**
903
- * Import Template for Elementor
904
- *
905
- * @since 1.0.0
906
- *
907
- * @param integer $post_id Post ID.
908
- * @param array $response Post meta.
909
- * @param array $page_build_data Page build data.
910
- * @return void
911
- */
912
- public static function import_template_elementor( $post_id, $response, $page_build_data ) {
913
- if ( ! is_plugin_active( 'elementor/elementor.php' ) ) {
914
- $data = __( 'Elementor is not activated. Please activate plugin Elementor Page Builder to import the step.', 'cartflows' );
915
- wcf()->logger->import_log( $data );
916
- wp_send_json_error( $data );
917
- }
918
-
919
- require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
920
-
921
- wcf()->logger->import_log( '# Started "importing page builder data" for step ' . $post_id );
922
-
923
- $obj = new \Elementor\TemplateLibrary\CartFlows_Importer_Elementor();
924
- $obj->import_single_template( $post_id );
925
-
926
- wcf()->logger->import_log( '# Complete "importing page builder data" for step ' . $post_id );
927
- }
928
-
929
- /**
930
- * Supported post types
931
- *
932
- * @since 1.0.0
933
- *
934
- * @return array Supported post types.
935
- */
936
- public static function supported_post_types() {
937
- return apply_filters(
938
- 'cartflows_supported_post_types',
939
- array(
940
- CARTFLOWS_FLOW_POST_TYPE,
941
- )
942
- );
943
- }
944
-
945
- /**
946
- * Check supported post type
947
- *
948
- * @since 1.0.0
949
- *
950
- * @param string $post_type Post type.
951
- * @return boolean Supported post type status.
952
- */
953
- public static function is_supported_post( $post_type = '' ) {
954
- if ( in_array( $post_type, self::supported_post_types() ) ) {
955
- return true;
956
- }
957
-
958
- return false;
959
- }
960
-
961
- /**
962
- * Set steps to the flow
963
- *
964
- * @param integer $flow_id Flow ID.
965
- * @param integer $new_step_id New step ID.
966
- * @param string $step_title Flow Type.
967
- * @param string $step_slug Flow Type.
968
- */
969
- function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
970
- // Update steps for the current flow.
971
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
972
-
973
- if ( ! is_array( $flow_steps ) ) {
974
- $flow_steps = array();
975
- }
976
-
977
- $flow_steps[] = array(
978
- 'id' => $new_step_id,
979
- 'title' => $step_title,
980
- 'type' => $step_slug,
981
- );
982
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
983
- wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
984
- }
985
-
986
- /**
987
- * Localize variables in admin
988
- *
989
- * @param array $vars variables.
990
- */
991
- function localize_vars( $vars ) {
992
-
993
- $ajax_actions = array(
994
- 'cf_step_import',
995
- 'cf_load_steps',
996
- 'cf_create_flow',
997
- 'cf_default_flow',
998
- 'cf_step_create_blank',
999
- 'cf_import_flow_step',
1000
- );
1001
-
1002
- foreach ( $ajax_actions as $action ) {
1003
-
1004
- $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
1005
- }
1006
-
1007
- return $vars;
1008
- }
1009
-
1010
- /**
1011
- * Ajax action to activate plugin
1012
- */
1013
- public function activate_plugin() {
1014
-
1015
- $plugin_slug = isset( $_POST['plugin_slug'] ) ? sanitize_text_field( $_POST['plugin_slug'] ) : '';
1016
-
1017
- if ( ! is_plugin_active( $plugin_slug ) ) {
1018
-
1019
- $activate = activate_plugin( $plugin_slug, '', false, true );
1020
-
1021
- if ( is_wp_error( $activate ) ) {
1022
- wp_send_json_error();
1023
- }
1024
- }
1025
-
1026
- wp_send_json_success();
1027
- }
1028
-
1029
- }
1030
-
1031
- /**
1032
- * Initialize class object with 'get_instance()' method
1033
- */
1034
- CartFlows_Importer::get_instance();
1035
-
1036
- endif;
 
 
1
+ <?php
2
+ /**
3
+ * CartFlows Admin
4
+ *
5
+ * @package CartFlows
6
+ * @since 1.0.0
7
+ */
8
+
9
+ if ( ! class_exists( 'CartFlows_Importer' ) ) :
10
+
11
+ /**
12
+ * CartFlows Import
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ class CartFlows_Importer {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.0
22
+ * @access private
23
+ * @var object Class object.
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.0.0
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function get_instance() {
34
+ if ( ! isset( self::$instance ) ) {
35
+ self::$instance = new self;
36
+ }
37
+
38
+ return self::$instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ *
44
+ * @since 1.0.0
45
+ */
46
+ public function __construct() {
47
+ add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
48
+ add_action( 'wp_ajax_cartflows_load_steps', array( $this, 'load_templates' ) );
49
+ add_action( 'wp_ajax_cartflows_step_import', array( $this, 'import_step' ) );
50
+ add_action( 'wp_ajax_cartflows_create_flow', array( $this, 'create_flow' ) );
51
+ add_action( 'wp_ajax_cartflows_default_flow', array( $this, 'create_default_flow' ) );
52
+ add_action( 'wp_ajax_cartflows_step_create_blank', array( $this, 'step_create_blank' ) );
53
+ add_action( 'wp_ajax_cartflows_import_flow_step', array( $this, 'import_flow' ) );
54
+ add_action( 'admin_footer', array( $this, 'js_templates' ) );
55
+ add_action( 'cartflows_import_complete', array( $this, 'clear_cache' ) );
56
+
57
+ add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
58
+
59
+ add_action( 'wp_ajax_cartflows_activate_plugin', array( $this, 'activate_plugin' ) );
60
+ }
61
+
62
+ /**
63
+ * Clear Cache.
64
+ *
65
+ * @since 1.0.0
66
+ */
67
+ public function clear_cache() {
68
+ // Clear 'Elementor' file cache.
69
+ if ( class_exists( '\Elementor\Plugin' ) ) {
70
+ Elementor\Plugin::$instance->files_manager->clear_cache();
71
+ }
72
+ }
73
+
74
+ /**
75
+ * JS Templates
76
+ *
77
+ * @since 1.0.0
78
+ *
79
+ * @return void
80
+ */
81
+ function js_templates() {
82
+
83
+ // Loading Templates.
84
+ ?>
85
+ <script type="text/template" id="tmpl-cartflows-step-loading">
86
+ <div class="template-message-block cartflows-step-loading">
87
+ <h2>
88
+ <span class="spinner"></span>
89
+ <?php _e( 'Loading Steps', 'cartflows' ); ?>
90
+ </h2>
91
+ <p class="description"><?php _e( 'Getting steps from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
92
+ </div>
93
+ </script>
94
+
95
+ <?php
96
+ // Search Templates.
97
+ ?>
98
+ <script type="text/template" id="tmpl-cartflows-searching-templates">
99
+ <div class="template-message-block cartflows-searching-templates">
100
+ <h2>
101
+ <span class="spinner"></span>
102
+ <?php _e( 'Searching Template..', 'cartflows' ); ?>
103
+ </h2>
104
+ <p class="description"><?php _e( 'Getting templates from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
105
+ </div>
106
+ </script>
107
+
108
+ <?php
109
+ // CartFlows Importing Template.
110
+ ?>
111
+ <script type="text/template" id="tmpl-cartflows-step-importing">
112
+ <div class="template-message-block cartflows-step-importing">
113
+ <h2><span class="spinner"></span> <?php _e( 'Importing..', 'cartflows' ); ?></h2>
114
+ </div>
115
+ </script>
116
+
117
+ <?php
118
+ // CartFlows Imported.
119
+ ?>
120
+ <script type="text/template" id="tmpl-cartflows-step-imported">
121
+ <div class="template-message-block cartflows-step-imported">
122
+ <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
123
+ <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span></p></div>
124
+ </script>
125
+
126
+ <?php
127
+ // No templates.
128
+ ?>
129
+ <script type="text/template" id="tmpl-cartflows-no-steps">
130
+ <div class="cartflows-no-steps">
131
+ <div class="template-message-block">
132
+ <h2><?php _e( 'Steps not found!', 'cartflows' ); ?></h2>
133
+ <p class="description"><?php _e( 'We\'ll provide the ready made steps to import.', 'cartflows' ); ?></p>
134
+ </div>
135
+ </div>
136
+ </script>
137
+
138
+ <?php
139
+ // No templates.
140
+ ?>
141
+ <script type="text/template" id="tmpl-cartflows-no-flows">
142
+ <div class="cartflows-no-flows">
143
+ <div class="template-message-block">
144
+ <h2><?php _e( 'Flows not found!', 'cartflows' ); ?></h2>
145
+ <p class="description"><?php _e( 'We\'ll provide the ready made flows to import.', 'cartflows' ); ?></p>
146
+ </div>
147
+ </div>
148
+ </script>
149
+
150
+ <?php
151
+ // Error handling.
152
+ ?>
153
+ <script type="text/template" id="tmpl-templator-error">
154
+ <div class="notice notice-error"><p>{{ data }}</p></div>
155
+ </script>
156
+
157
+ <?php
158
+ // Redirect to Elementor.
159
+ ?>
160
+ <script type="text/template" id="tmpl-templator-redirect-to-elementor">
161
+ <div class="template-message-block templator-redirect-to-elementor">
162
+ <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
163
+ <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span><br/><br/><?php _e( 'Redirecting to the Elementor edit window.', 'cartflows' ); ?> </p></div>
164
+ </script>
165
+
166
+ <?php
167
+ /**
168
+ * Responsive Buttons
169
+ */
170
+ ?>
171
+ <script type="text/template" id="tmpl-cartflows-responsive-view">
172
+ <span class="responsive-view">
173
+ <span class="actions">
174
+ <a class="desktop" href="#"><span data-view="desktop " class="active dashicons dashicons-desktop"></span></a>
175
+ <a class="tablet" href="#"><span data-view="tablet" class="dashicons dashicons-tablet"></span></a>
176
+ <a class="mobile" href="#"><span data-view="mobile" class="dashicons dashicons-smartphone"></span></a>
177
+ </span>
178
+ </span>
179
+ </script>
180
+
181
+ <?php
182
+ /** Blank flow */
183
+ ?>
184
+ <script type="text/template" id="tmpl-cartflows-create-blank-flow">
185
+ <div class="inner">
186
+ <div class="template">
187
+ <span class="thumbnail site-preview">
188
+ <div class="template-screenshot">
189
+ <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
190
+ </div>
191
+ </span>
192
+ <div class="template-id-container">
193
+ <h3 class="template-name"> <?php _e( 'Canvas', 'cartflows' ); ?> </h3>
194
+ <div class="template-actions">
195
+ <a href="#" class="button button-primary cartflows-flow-import-blank"><?php _e( 'Create Flow', 'cartflows' ); ?></a>
196
+ </div>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ </script>
201
+
202
+ <?php
203
+ // Templates data.
204
+ $installed_plugins = get_plugins();
205
+
206
+ $import_btn_title = __( 'Import', 'cartflows' );
207
+
208
+ $required_plugins = array(
209
+ 'elementor' => array(
210
+ 'active' => is_plugin_active( 'elementor/elementor.php' ) ? 'yes' : 'no',
211
+ 'install' => isset( $installed_plugins['elementor/elementor.php'] ) ? 'yes' : 'no',
212
+ ),
213
+ );
214
+
215
+ if ( 'yes' == $required_plugins['elementor']['install'] && 'no' == $required_plugins['elementor']['active'] ) {
216
+ $import_btn_title = __( 'Activate Elementor & Import', 'cartflows' );
217
+ } elseif ( 'no' == $required_plugins['elementor']['install'] ) {
218
+ $import_btn_title = __( 'Install Elementor & Import', 'cartflows' );
219
+ }
220
+
221
+ ?>
222
+ <script type="text/template" id="tmpl-cartflows-flows-list">
223
+
224
+ <# if ( data.items.length ) { #>
225
+ <# for ( key in data.items ) { #>
226
+ <#
227
+ var flow_steps = [];
228
+ if( data.items[ key ].flow_steps ) {
229
+ flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
230
+ return value['id'];
231
+ });
232
+ }
233
+ #>
234
+ <div class="inner">
235
+ <div class="template">
236
+ <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
237
+ <div class="template-screenshot">
238
+ <# if( data.items[ key ].featured_image_url ) { #>
239
+ <img src="{{ data.items[ key ].featured_image_url }}" />
240
+ <# } else { #>
241
+ <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
242
+ <# } #>
243
+ </div>
244
+ <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>flow={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
245
+ <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
246
+ <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
247
+ <# } #>
248
+ </span>
249
+ <div class="template-id-container">
250
+ <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
251
+ <div class="template-actions">
252
+
253
+ <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
254
+ <a data-flow-steps="{{ flow_steps }}" data-required="<?php echo htmlspecialchars( json_encode( $required_plugins ), ENT_QUOTES, 'UTF-8' ); ?>" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}"><?php echo $import_btn_title; ?></a>
255
+ <# } else if( CartFlowsImportVars._is_pro_active ) { #>
256
+ <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
257
+ <# } else { #>
258
+ <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
259
+ <# } #>
260
+ </div>
261
+ </div>
262
+ </div>
263
+ </div>
264
+ <# } #>
265
+ <# } #>
266
+ </script>
267
+
268
+ <?php
269
+ // Empty Step.
270
+ ?>
271
+ <script type="text/template" id="tmpl-cartflows-create-blank-step">
272
+ <div class="inner">
273
+ <div class="template">
274
+ <span class="thumbnail site-preview cartflows-flow-preview">
275
+ <div class="template-screenshot">
276
+ <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
277
+ </div>
278
+ <div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
279
+ </span>
280
+ <div class="template-id-container">
281
+ <h3 class="template-name"> Blank </h3>
282
+ <div class="template-actions">
283
+ <a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create', 'cartflows' ); ?></a>
284
+ </div>
285
+ </div>
286
+ </div>
287
+ </div>
288
+ </script>
289
+
290
+ <?php
291
+ // Templates data.
292
+ ?>
293
+ <script type="text/template" id="tmpl-cartflows-steps-list">
294
+ <# if ( data.items.length ) { #>
295
+ <# for ( key in data.items ) { #>
296
+ <#
297
+ var flow_steps = [];
298
+ if( data.items[ key ].flow_steps ) {
299
+ flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
300
+ return value['id'];
301
+ });
302
+ }
303
+ #>
304
+ <div class="inner">
305
+ <div class="template">
306
+ <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
307
+ <div class="template-screenshot">
308
+ <# if( data.items[ key ].featured_image_url ) { #>
309
+ <img src="{{ data.items[ key ].featured_image_url }}" />
310
+ <# } else { #>
311
+ <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
312
+ <# } #>
313
+ </div>
314
+ <div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
315
+ <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>step={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
316
+ <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
317
+ <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
318
+ <# } #>
319
+ </span>
320
+ <div class="template-id-container">
321
+ <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
322
+ <div class="template-actions">
323
+ <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
324
+ <a data-required="<?php echo htmlspecialchars( json_encode( $required_plugins ), ENT_QUOTES, 'UTF-8' ); ?>" data-flow-steps="{{ flow_steps }}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}"><?php echo $import_btn_title; ?></a>
325
+ <# } else if( CartFlowsImportVars._is_pro_active ) { #>
326
+ <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
327
+ <# } else { #>
328
+ <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
329
+ <# } #>
330
+ </div>
331
+ </div>
332
+ </div>
333
+ </div>
334
+ <# } #>
335
+ <# } #>
336
+ </script>
337
+
338
+ <?php
339
+ /**
340
+ * TMPL - Filters
341
+ */
342
+ ?>
343
+ <script type="text/template" id="tmpl-cartflows-term-filters">
344
+
345
+ <# if ( data ) { #>
346
+
347
+ <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
348
+
349
+ <# console.log( data.args.show_all ) #>
350
+ <# if ( data.args.show_all ) { #>
351
+ <li>
352
+ <a href="#" data-group="all"> All </a>
353
+ </li>
354
+ <# } #>
355
+
356
+ <# for ( key in data.items ) { #>
357
+ <li>
358
+ <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</a>
359
+ </li>
360
+ <# } #>
361
+
362
+ </ul>
363
+ <# } #>
364
+ </script>
365
+
366
+ <?php
367
+ // Step Type.
368
+ ?>
369
+ <script type="text/template" id="tmpl-cartflows-step-types">
370
+ <ul class="wcf-tab nav-tabs">
371
+ <# if( data.items_count ) { #>
372
+ <# for( key in data.items ) { #>
373
+ <# console.log( data.items[ key ].id ) #>
374
+ <li data-slug="{{data.items[ key ].slug}}" data-title="{{ data.items[ key ].name }}">
375
+ <a href="#{{{ data.items[ key ].slug }}}">{{{ data.items[ key ].name }}}</a>
376
+ </li>
377
+ <# } #>
378
+ <# } #>
379
+ </ul>
380
+ </script>
381
+
382
+ <?php
383
+ // Add to library button.
384
+ ?>
385
+ <script type="text/template" id="tmpl-templator-add-to-library">
386
+ <a class="templator-add-to-library page-title-action cartflows-load-steps-library"><i class="dashicons dashicons-cloud"></i><?php esc_attr_e( 'Import from Cloud', 'cartflows' ); ?></a>
387
+ </script>
388
+ <?php
389
+ }
390
+
391
+ /**
392
+ * Enqueue scripts
393
+ *
394
+ * @since 1.0.0
395
+ *
396
+ * @hook admin_enqueue_scripts
397
+ * @param string $hook Current page hook.
398
+ */
399
+ function scripts( $hook = '' ) {
400
+
401
+ if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
402
+ return;
403
+ }
404
+
405
+ wp_enqueue_script( 'cartflows-rest-api', CARTFLOWS_URL . 'assets/js/rest-api.js', array( 'jquery' ), CARTFLOWS_VER, true );
406
+ wp_enqueue_style( 'cartflows-import', CARTFLOWS_URL . 'assets/css/import.css', null, CARTFLOWS_VER, 'all' );
407
+ wp_style_add_data( 'cartflows-import', 'rtl', 'replace' );
408
+ wp_enqueue_script( 'cartflows-import', CARTFLOWS_URL . 'assets/js/import.js', array( 'jquery', 'wp-util', 'cartflows-rest-api', 'updates' ), CARTFLOWS_VER, true );
409
+
410
+ $localize_vars = array(
411
+ '_is_pro_active' => _is_cartflows_pro(),
412
+
413
+ // Flow and its rest fields.
414
+ 'flow' => CARTFLOWS_FLOW_POST_TYPE,
415
+ 'flow_fields' => array(
416
+ 'id',
417
+ 'title',
418
+ 'flow_type',
419
+ 'flow_steps',
420
+ 'licence_status',
421
+ 'featured_image_url',
422
+ 'featured_media', // @required for field `featured_image_url`.
423
+ ),
424
+
425
+ // Flow type and rest fields.
426
+ 'flow_type' => CARTFLOWS_TAXONOMY_FLOW_CATEGORY,
427
+ 'flow_type_fields' => array(
428
+ 'id',
429
+ 'name',
430
+ 'slug',
431
+ ),
432
+
433
+ // Step and its rest fields.
434
+ 'step' => CARTFLOWS_STEP_POST_TYPE,
435
+ 'step_fields' => array(
436
+ 'title',
437
+ 'featured_image_url',
438
+ 'featured_media', // @required for field `featured_image_url`.
439
+ 'id',
440
+ 'flow_type',
441
+ 'licence_status',
442
+ ),
443
+
444
+ // Step type and its rest fields.
445
+ 'step_type' => CARTFLOWS_TAXONOMY_STEP_TYPE,
446
+ 'step_type_fields' => array(
447
+ 'id',
448
+ 'name',
449
+ 'slug',
450
+ ),
451
+
452
+ 'domain_url' => CARTFLOWS_DOMAIN_URL,
453
+ 'server_url' => CARTFLOWS_TEMPLATES_URL,
454
+ 'server_rest_url' => CARTFLOWS_TEMPLATES_URL . 'wp-json/wp/v2/',
455
+ 'site_url' => site_url(),
456
+ 'admin_url' => admin_url(),
457
+ 'licence_args' => CartFlows_API::get_instance()->get_licence_args(),
458
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
459
+ 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
460
+ );
461
+
462
+ // Add thickbox.
463
+ add_thickbox();
464
+
465
+ wp_localize_script( 'cartflows-import', 'CartFlowsImportVars', $localize_vars );
466
+ wp_localize_script( 'cartflows-rest-api', 'CartFlowsImportVars', $localize_vars );
467
+ }
468
+
469
+ /**
470
+ * Load Template
471
+ *
472
+ * @since 1.0.0
473
+ *
474
+ * @hook cartflows_load_steps
475
+ * @return void
476
+ */
477
+ function load_templates() {
478
+
479
+ check_ajax_referer( 'cf-load-steps', 'security' );
480
+
481
+ $args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array();
482
+ $templates = CartFlows_API::get_instance()->get_templates( $args );
483
+
484
+ if ( $templates['templates_count'] ) {
485
+ wp_send_json_success( $templates );
486
+ } else {
487
+ wp_send_json_error( $templates );
488
+ }
489
+ wp_die();
490
+ }
491
+
492
+ /**
493
+ * Import.
494
+ *
495
+ * @since 1.0.0
496
+ *
497
+ * @hook wp_ajax_cartflows_import_flow_step
498
+ * @return void
499
+ */
500
+ function import_flow() {
501
+
502
+ check_ajax_referer( 'cf-import-flow-step', 'security' );
503
+
504
+ $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
505
+ $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
506
+
507
+ wcf()->logger->import_log( '------------------------------------' );
508
+ wcf()->logger->import_log( 'STARTED! Importing FLOW' );
509
+ wcf()->logger->import_log( '------------------------------------' );
510
+ wcf()->logger->import_log( '(✓) Creating new step from remote step [' . $template_id . '] for FLOW ' . get_the_title( $flow_id ) . ' [' . $flow_id . ']' );
511
+
512
+ $response = CartFlows_API::get_instance()->get_template( $template_id );
513
+
514
+ if ( false === $response['success'] ) {
515
+ wcf()->logger->import_log( '(✕) Failed to fetch remote data.' );
516
+ wp_send_json_error( $response );
517
+ }
518
+
519
+ wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . json_encode( $response ) );
520
+
521
+ $new_step_id = wp_insert_post(
522
+ array(
523
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
524
+ 'post_title' => $response['title'],
525
+ 'post_content' => '',
526
+ 'post_status' => 'publish',
527
+ )
528
+ );
529
+
530
+ if ( is_wp_error( $new_step_id ) ) {
531
+ wcf()->logger->import_log( '(✕) Failed to create new step for flow ' . $flow_id );
532
+ wp_send_json_error( $new_step_id );
533
+ }
534
+
535
+ wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );
536
+ // insert post meta.
537
+ update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
538
+ wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
539
+
540
+ /**
541
+ * Import & Set type.
542
+ */
543
+ $term = isset( $response['data']['step_type'] ) ? $response['data']['step_type'] : '';
544
+ $term_slug = '';
545
+ if ( $term ) {
546
+
547
+ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
548
+ $term_exist = term_exists( $term->name, $taxonomy );
549
+
550
+ if ( empty( $term_exist ) ) {
551
+ $terms = array(
552
+ array(
553
+ 'name' => $term->name,
554
+ ),
555
+ );
556
+
557
+ Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
558
+ wcf()->logger->import_log( '(✓) Created new term ' . $term->name );
559
+ }
560
+
561
+ $current_term = term_exists( $term->name, $taxonomy );
562
+
563
+ // Set type object.
564
+ $data = get_term( $current_term['term_id'], $taxonomy );
565
+ $term_slug = $data->slug;
566
+ $term_name = $data->name;
567
+ wp_set_object_terms( $new_step_id, $term_slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
568
+ wcf()->logger->import_log( '(✓) Assigned existing term ' . $term_name . ' to the template ' . $new_step_id );
569
+
570
+ // Set type.
571
+ update_post_meta( $new_step_id, 'wcf-step-type', $term_slug );
572
+ wcf()->logger->import_log( '(✓) Updated term ' . $term_name . ' to the post meta wcf-step-type.' );
573
+ }
574
+
575
+ // Set flow.
576
+ wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
577
+ wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
578
+
579
+ /**
580
+ * Update steps for the current flow.
581
+ */
582
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
583
+
584
+ if ( ! is_array( $flow_steps ) ) {
585
+ $flow_steps = array();
586
+ }
587
+
588
+ $flow_steps[] = array(
589
+ 'id' => $new_step_id,
590
+ 'title' => $response['title'],
591
+ 'type' => $term_slug,
592
+ );
593
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
594
+ wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
595
+
596
+ // Import Post Meta.
597
+ self::import_post_meta( $new_step_id, $response );
598
+
599
+ wcf()->logger->import_log( '(✓) Importing step "' . get_the_title( $new_step_id ) . '" [' . $new_step_id . '] for FLOW "' . get_the_title( $flow_id ) . '" [' . $flow_id . ']' );
600
+ wcf()->logger->import_log( '------------------------------------' );
601
+ wcf()->logger->import_log( 'COMPLETE! Importing FLOW' );
602
+ wcf()->logger->import_log( '------------------------------------' );
603
+
604
+ do_action( 'cartflows_import_complete' );
605
+ wcf()->logger->import_log( '(✓) BATCH STARTED for step ' . $new_step_id . ' for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
606
+
607
+ // Batch Process.
608
+ do_action( 'cartflows_after_template_import', $new_step_id, $response );
609
+
610
+ /**
611
+ * End
612
+ */
613
+ wp_send_json_success( $new_step_id );
614
+ }
615
+
616
+ /**
617
+ * Import Step.
618
+ *
619
+ * @since 1.0.0
620
+ * @hook wp_ajax_cartflows_step_import
621
+ *
622
+ * @return void
623
+ */
624
+ function create_default_flow() {
625
+
626
+ check_ajax_referer( 'cf-default-flow', 'security' );
627
+
628
+ // Create post object.
629
+ $new_flow_post = array(
630
+ 'post_content' => '',
631
+ 'post_status' => 'publish',
632
+ 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
633
+ );
634
+
635
+ // Insert the post into the database.
636
+ $flow_id = wp_insert_post( $new_flow_post );
637
+
638
+ if ( is_wp_error( $flow_id ) ) {
639
+ wp_send_json_error( $flow_id->get_error_message() );
640
+ }
641
+
642
+ $flow_steps = array();
643
+
644
+ $steps_data = array(
645
+ 'landing' => __( 'Landing Page', 'cartflows' ),
646
+ 'checkout' => __( 'Checkout Page', 'cartflows' ),
647
+ 'thankyou' => __( 'Thank You Page', 'cartflows' ),
648
+ );
649
+
650
+ foreach ( $steps_data as $slug => $title ) {
651
+
652
+ $post_content = '';
653
+
654
+ switch ( $slug ) {
655
+ case 'checkout':
656
+ $post_content = '';
657
+ break;
658
+ case 'thankyou':
659
+ $post_content = '';
660
+ break;
661
+ default:
662
+ $post_content = '';
663
+ break;
664
+ }
665
+
666
+ $step_id = wp_insert_post(
667
+ array(
668
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
669
+ 'post_title' => $title,
670
+ 'post_content' => $post_content,
671
+ 'post_status' => 'publish',
672
+ )
673
+ );
674
+
675
+ if ( is_wp_error( $step_id ) ) {
676
+ wp_send_json_error( $step_id->get_error_message() );
677
+ }
678
+
679
+ if ( $step_id ) {
680
+
681
+ $flow_steps[] = array(
682
+ 'id' => $step_id,
683
+ 'title' => $title,
684
+ 'type' => $slug,
685
+ );
686
+
687
+ // insert post meta.
688
+ update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
689
+ update_post_meta( $step_id, 'wcf-step-type', $slug );
690
+
691
+ wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
692
+ wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
693
+ }
694
+ }
695
+
696
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
697
+
698
+ wp_send_json_success( $flow_id );
699
+ }
700
+
701
+ /**
702
+ * Create Flow
703
+ *
704
+ * @return void
705
+ */
706
+ function create_flow() {
707
+
708
+ check_ajax_referer( 'cf-create-flow', 'security' );
709
+
710
+ // Create post object.
711
+ $new_flow_post = array(
712
+ 'post_content' => '',
713
+ 'post_status' => 'publish',
714
+ 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
715
+ );
716
+
717
+ // Insert the post into the database.
718
+ $flow_id = wp_insert_post( $new_flow_post );
719
+
720
+ if ( is_wp_error( $flow_id ) ) {
721
+ wp_send_json_error( $flow_id->get_error_message() );
722
+ }
723
+
724
+ wp_send_json_success( $flow_id );
725
+ }
726
+
727
+ /**
728
+ * Create Step
729
+ *
730
+ * @return void
731
+ */
732
+ function import_step() {
733
+
734
+ check_ajax_referer( 'cf-step-import', 'security' );
735
+
736
+ $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
737
+ $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
738
+ $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
739
+ $step_type = isset( $_POST['step_type'] ) ? sanitize_title( $_POST['step_type'] ) : '';
740
+ $step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( $_POST['step_custom_title'] ) : $step_title;
741
+
742
+ $cartflow_meta = Cartflows_Flow_Meta::get_instance();
743
+
744
+ $post_id = $cartflow_meta->create_step( $flow_id, $step_type, $step_custom_title );
745
+
746
+ wcf()->logger->import_log( '------------------------------------' );
747
+ wcf()->logger->import_log( 'STARTED! Importing STEP' );
748
+ wcf()->logger->import_log( '------------------------------------' );
749
+
750
+ if ( empty( $template_id ) || empty( $post_id ) ) {
751
+ /* translators: %s: template ID */
752
+ $data = sprintf( __( 'Invalid template id %1$s or post id %2$s.', 'cartflows' ), $template_id, $post_id );
753
+ wcf()->logger->import_log( $data );
754
+ wp_send_json_error( $data );
755
+ }
756
+
757
+ wcf()->logger->import_log( 'Remote Step ' . $template_id . ' for local flow "' . get_the_title( $post_id ) . '" [' . $post_id . ']' );
758
+
759
+ $response = CartFlows_API::get_instance()->get_template( $template_id );
760
+
761
+ wcf()->logger->import_log( json_encode( $response ) );
762
+
763
+ // Import Post Meta.
764
+ self::import_post_meta( $post_id, $response );
765
+
766
+ do_action( 'cartflows_import_complete' );
767
+
768
+ // Batch Process.
769
+ do_action( 'cartflows_after_template_import', $post_id, $response );
770
+
771
+ wcf()->logger->import_log( '------------------------------------' );
772
+ wcf()->logger->import_log( 'COMPLETE! Importing Step' );
773
+ wcf()->logger->import_log( '------------------------------------' );
774
+
775
+ wp_send_json_success( $post_id );
776
+ }
777
+
778
+ /**
779
+ * Import Step.
780
+ *
781
+ * @since 1.0.0
782
+ * @hook wp_ajax_cartflows_step_create_blank
783
+ *
784
+ * @return void
785
+ */
786
+ function step_create_blank() {
787
+
788
+ check_ajax_referer( 'cf-step-create-blank', 'security' );
789
+
790
+ $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
791
+ $step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( $_POST['step_type'] ) : '';
792
+ $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
793
+
794
+ if ( empty( $flow_id ) || empty( $step_type ) ) {
795
+ /* translators: %s: flow ID */
796
+ $data = sprintf( __( 'Invalid flow id %1$s or step type %2$s.', 'cartflows' ), $flow_id, $step_type );
797
+ wcf()->logger->import_log( $data );
798
+ wp_send_json_error( $data );
799
+ }
800
+
801
+ wcf()->logger->import_log( '------------------------------------' );
802
+ wcf()->logger->import_log( 'STARTED! Creating Blank STEP for Flow ' . $flow_id );
803
+
804
+ $step_type_title = str_replace( '-', ' ', $step_type );
805
+ $step_type_slug = strtolower( str_replace( '-', ' ', $step_type ) );
806
+
807
+ $new_step_id = wp_insert_post(
808
+ array(
809
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
810
+ 'post_title' => $step_title,
811
+ 'post_content' => '',
812
+ 'post_status' => 'publish',
813
+ )
814
+ );
815
+
816
+ // insert post meta.
817
+ update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
818
+
819
+ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
820
+ $term_exist = term_exists( $step_type_title, $taxonomy );
821
+
822
+ if ( empty( $term_exist ) ) {
823
+ $terms = array(
824
+ array(
825
+ 'name' => $step_type_title,
826
+ ),
827
+ );
828
+
829
+ Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
830
+ wcf()->logger->import_log( '(✓) Created new term ' . $step_type_title );
831
+ }
832
+
833
+ $current_term = term_exists( $step_type_title, $taxonomy );
834
+
835
+ // Set type object.
836
+ $data = get_term( $current_term['term_id'], $taxonomy );
837
+ $step_slug = $data->slug;
838
+ wp_set_object_terms( $new_step_id, $data->slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
839
+ wcf()->logger->import_log( '(✓) Assigned existing term ' . $step_type_title . ' to the template ' . $new_step_id );
840
+
841
+ // Set type.
842
+ update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
843
+ wcf()->logger->import_log( '(✓) Updated term ' . $data->name . ' to the post meta wcf-step-type.' );
844
+
845
+ // Set flow.
846
+ wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
847
+ wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
848
+
849
+ CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step_type_title, $step_slug );
850
+
851
+ wcf()->logger->import_log( 'COMPLETE! Creating Blank STEP for Flow ' . $flow_id );
852
+ wcf()->logger->import_log( '------------------------------------' );
853
+
854
+ wp_send_json_success( $new_step_id );
855
+ }
856
+
857
+ /**
858
+ * Import Post Meta
859
+ *
860
+ * @since 1.0.0
861
+ *
862
+ * @param integer $post_id Post ID.
863
+ * @param array $response Post meta.
864
+ * @return void
865
+ */
866
+ public static function import_post_meta( $post_id, $response ) {
867
+
868
+ $metadata = (array) $response['post_meta'];
869
+
870
+ foreach ( $metadata as $meta_key => $meta_value ) {
871
+ $meta_value = isset( $meta_value[0] ) ? $meta_value[0] : '';
872
+
873
+ if ( $meta_value ) {
874
+
875
+ if ( is_serialized( $meta_value, true ) ) {
876
+ $raw_data = maybe_unserialize( stripslashes( $meta_value ) );
877
+ } elseif ( is_array( $meta_value ) ) {
878
+ $raw_data = json_decode( stripslashes( $meta_value ), true );
879
+ } else {
880
+ $raw_data = $meta_value;
881
+ }
882
+
883
+ if ( '_elementor_data' === $meta_key ) {
884
+
885
+ if ( is_array( $raw_data ) ) {
886
+ $raw_data = wp_slash( json_encode( $raw_data ) );
887
+ } else {
888
+ $raw_data = wp_slash( $raw_data );
889
+ }
890
+ wcf()->logger->import_log( $raw_data );
891
+ }
892
+
893
+ if ( is_array( $raw_data ) ) {
894
+ wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . json_encode( $raw_data ) );
895
+ } else {
896
+ wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
897
+ }
898
+
899
+ update_post_meta( $post_id, $meta_key, $raw_data );
900
+ }
901
+ }
902
+ }
903
+
904
+ /**
905
+ * Import Template for Elementor
906
+ *
907
+ * @since 1.0.0
908
+ *
909
+ * @param integer $post_id Post ID.
910
+ * @param array $response Post meta.
911
+ * @param array $page_build_data Page build data.
912
+ * @return void
913
+ */
914
+ public static function import_template_elementor( $post_id, $response, $page_build_data ) {
915
+ if ( ! is_plugin_active( 'elementor/elementor.php' ) ) {
916
+ $data = __( 'Elementor is not activated. Please activate plugin Elementor Page Builder to import the step.', 'cartflows' );
917
+ wcf()->logger->import_log( $data );
918
+ wp_send_json_error( $data );
919
+ }
920
+
921
+ require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
922
+
923
+ wcf()->logger->import_log( '# Started "importing page builder data" for step ' . $post_id );
924
+
925
+ $obj = new \Elementor\TemplateLibrary\CartFlows_Importer_Elementor();
926
+ $obj->import_single_template( $post_id );
927
+
928
+ wcf()->logger->import_log( '# Complete "importing page builder data" for step ' . $post_id );
929
+ }
930
+
931
+ /**
932
+ * Supported post types
933
+ *
934
+ * @since 1.0.0
935
+ *
936
+ * @return array Supported post types.
937
+ */
938
+ public static function supported_post_types() {
939
+ return apply_filters(
940
+ 'cartflows_supported_post_types',
941
+ array(
942
+ CARTFLOWS_FLOW_POST_TYPE,
943
+ )
944
+ );
945
+ }
946
+
947
+ /**
948
+ * Check supported post type
949
+ *
950
+ * @since 1.0.0
951
+ *
952
+ * @param string $post_type Post type.
953
+ * @return boolean Supported post type status.
954
+ */
955
+ public static function is_supported_post( $post_type = '' ) {
956
+ if ( in_array( $post_type, self::supported_post_types() ) ) {
957
+ return true;
958
+ }
959
+
960
+ return false;
961
+ }
962
+
963
+ /**
964
+ * Set steps to the flow
965
+ *
966
+ * @param integer $flow_id Flow ID.
967
+ * @param integer $new_step_id New step ID.
968
+ * @param string $step_title Flow Type.
969
+ * @param string $step_slug Flow Type.
970
+ */
971
+ function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
972
+ // Update steps for the current flow.
973
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
974
+
975
+ if ( ! is_array( $flow_steps ) ) {
976
+ $flow_steps = array();
977
+ }
978
+
979
+ $flow_steps[] = array(
980
+ 'id' => $new_step_id,
981
+ 'title' => $step_title,
982
+ 'type' => $step_slug,
983
+ );
984
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
985
+ wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
986
+ }
987
+
988
+ /**
989
+ * Localize variables in admin
990
+ *
991
+ * @param array $vars variables.
992
+ */
993
+ function localize_vars( $vars ) {
994
+
995
+ $ajax_actions = array(
996
+ 'cf_step_import',
997
+ 'cf_load_steps',
998
+ 'cf_create_flow',
999
+ 'cf_default_flow',
1000
+ 'cf_step_create_blank',
1001
+ 'cf_import_flow_step',
1002
+ );
1003
+
1004
+ foreach ( $ajax_actions as $action ) {
1005
+
1006
+ $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
1007
+ }
1008
+
1009
+ return $vars;
1010
+ }
1011
+
1012
+ /**
1013
+ * Ajax action to activate plugin
1014
+ */
1015
+ public function activate_plugin() {
1016
+
1017
+ $plugin_slug = isset( $_POST['plugin_slug'] ) ? sanitize_text_field( $_POST['plugin_slug'] ) : '';
1018
+
1019
+ if ( ! is_plugin_active( $plugin_slug ) ) {
1020
+
1021
+ $activate = activate_plugin( $plugin_slug, '', false, true );
1022
+
1023
+ if ( is_wp_error( $activate ) ) {
1024
+ wp_send_json_error();
1025
+ }
1026
+ }
1027
+
1028
+ wp_send_json_success();
1029
+ }
1030
+
1031
+ }
1032
+
1033
+ /**
1034
+ * Initialize class object with 'get_instance()' method
1035
+ */
1036
+ CartFlows_Importer::get_instance();
1037
+
1038
+ endif;
classes/class-cartflows-loader.php CHANGED
@@ -1,416 +1,416 @@
1
- <?php
2
- /**
3
- * CartFlows Loader.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- if ( ! class_exists( 'Cartflows_Loader' ) ) {
9
-
10
- /**
11
- * Class Cartflows_Loader.
12
- */
13
- final class Cartflows_Loader {
14
-
15
- /**
16
- * Member Variable
17
- *
18
- * @var instance
19
- */
20
- private static $instance = null;
21
-
22
- /**
23
- * Member Variable
24
- *
25
- * @var utils
26
- */
27
- public $utils = null;
28
-
29
- /**
30
- * Member Variable
31
- *
32
- * @var logger
33
- */
34
- public $logger = null;
35
-
36
- /**
37
- * Member Variable
38
- *
39
- * @var session
40
- */
41
- public $session = null;
42
-
43
-
44
- /**
45
- * Member Variable
46
- *
47
- * @var options
48
- */
49
- public $options = null;
50
-
51
- /**
52
- * Member Variable
53
- *
54
- * @var meta
55
- */
56
- public $meta = null;
57
-
58
- /**
59
- * Member Variable
60
- *
61
- * @var flow
62
- */
63
- public $flow = null;
64
-
65
- /**
66
- * Initiator
67
- */
68
- public static function get_instance() {
69
-
70
- if ( is_null( self::$instance ) ) {
71
-
72
- self::$instance = new self;
73
-
74
- /**
75
- * CartFlows loaded.
76
- *
77
- * Fires when Cartflows was fully loaded and instantiated.
78
- *
79
- * @since 1.0.0
80
- */
81
- do_action( 'cartflows_loaded' );
82
- }
83
-
84
- return self::$instance;
85
- }
86
-
87
- /**
88
- * Constructor
89
- */
90
- public function __construct() {
91
-
92
- $this->define_constants();
93
-
94
- // Activation hook.
95
- register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
96
-
97
- // deActivation hook.
98
- register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
99
-
100
- add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
101
-
102
- add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
103
-
104
- // Update compatibility.
105
- require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
106
- }
107
-
108
- /**
109
- * Defines all constants
110
- *
111
- * @since 1.0.0
112
- */
113
- public function define_constants() {
114
-
115
- define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
116
- define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
117
- define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
118
- define( 'CARTFLOWS_VER', '1.0.4' );
119
- define( 'CARTFLOWS_SLUG', 'cartflows' );
120
- define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
121
-
122
- define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
123
- define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
124
-
125
- if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
126
- define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
127
- }
128
- define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
129
- define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
130
- define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
131
- define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
132
-
133
- if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
134
- define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
135
- }
136
- if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
137
- define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
138
- }
139
- }
140
-
141
- /**
142
- * Loads plugin files.
143
- *
144
- * @since 1.0.0
145
- *
146
- * @return void
147
- */
148
- function load_plugin() {
149
-
150
- if ( ! function_exists( 'WC' ) ) {
151
- add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
152
- return;
153
- }
154
-
155
- $this->load_helper_files_components();
156
- $this->load_core_files();
157
- $this->load_core_components();
158
-
159
- /**
160
- * CartFlows Init.
161
- *
162
- * Fires when Cartflows is instantiated.
163
- *
164
- * @since 1.0.0
165
- */
166
- do_action( 'cartflows_init' );
167
- }
168
-
169
- /**
170
- * Load Helper Files and Components.
171
- *
172
- * @since 1.0.0
173
- *
174
- * @return void
175
- */
176
- function load_helper_files_components() {
177
-
178
- /* Public Utils */
179
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
180
-
181
- /* Public Session */
182
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
183
-
184
- /* Public Global namespace functions */
185
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
186
-
187
- /* Admin Helper */
188
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
189
-
190
- /* Meta Default Values */
191
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
192
-
193
- $this->utils = Cartflows_Utils::get_instance();
194
- $this->session = Cartflows_Session::get_instance();
195
- $this->options = Cartflows_Default_Meta::get_instance();
196
-
197
- }
198
-
199
- /**
200
- * Load Core Files.
201
- *
202
- * @since 1.0.0
203
- *
204
- * @return void
205
- */
206
- function load_core_files() {
207
-
208
- /* Page builder compatibilty class */
209
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
210
-
211
- /* Admin Meta Fields*/
212
- include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
213
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
214
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
215
-
216
- /* Cloning */
217
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
218
-
219
- /* Admin Settings */
220
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
221
-
222
- /* Core Modules */
223
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
224
-
225
- /* Frontend Global */
226
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
227
- require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
228
-
229
- /* Modules */
230
- include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
231
- include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
232
- include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
233
- include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
234
-
235
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
236
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
237
-
238
- include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
239
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
240
- }
241
-
242
- /**
243
- * Load Core Components.
244
- *
245
- * @since 1.0.0
246
- *
247
- * @return void
248
- */
249
- function load_core_components() {
250
-
251
- $this->meta = Cartflows_Meta_Fields::get_instance();
252
- $this->logger = Cartflows_Logger::get_instance();
253
- $this->flow = Cartflows_Flow_Frontend::get_instance();
254
- }
255
-
256
- /**
257
- * Load CartFlows Pro Text Domain.
258
- * This will load the translation textdomain depending on the file priorities.
259
- * 1. Global Languages /wp-content/languages/cartflows/ folder
260
- * 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
261
- *
262
- * @since 1.0.3
263
- * @return void
264
- */
265
- public function load_cf_textdomain() {
266
-
267
- // Default languages directory for CartFlows Pro.
268
- $lang_dir = CARTFLOWS_DIR . 'languages/';
269
-
270
- /**
271
- * Filters the languages directory path to use for CartFlows Pro.
272
- *
273
- * @param string $lang_dir The languages directory path.
274
- */
275
- $lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
276
-
277
- // Traditional WordPress plugin locale filter.
278
- global $wp_version;
279
-
280
- $get_locale = get_locale();
281
-
282
- if ( $wp_version >= 4.7 ) {
283
- $get_locale = get_user_locale();
284
- }
285
-
286
- /**
287
- * Language Locale for CartFlows Pro
288
- *
289
- * @var $get_locale The locale to use.
290
- * Uses get_user_locale()` in WordPress 4.7 or greater,
291
- * otherwise uses `get_locale()`.
292
- */
293
- $locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
294
- $mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
295
-
296
- // Setup paths to current locale file.
297
- $mofile_local = $lang_dir . $mofile;
298
- $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
299
-
300
- if ( file_exists( $mofile_global ) ) {
301
- // Look in global /wp-content/languages/cartflows/ folder.
302
- load_textdomain( 'cartflows', $mofile_global );
303
- } elseif ( file_exists( $mofile_local ) ) {
304
- // Look in local /wp-content/plugins/cartflows/languages/ folder.
305
- load_textdomain( 'cartflows', $mofile_local );
306
- } else {
307
- // Load the default language files.
308
- load_plugin_textdomain( 'cartflows', false, $lang_dir );
309
- }
310
- }
311
-
312
- /**
313
- * Fires admin notice when Elementor is not installed and activated.
314
- *
315
- * @since 1.0.0
316
- *
317
- * @return void
318
- */
319
- public function fails_to_load() {
320
-
321
- $screen = get_current_screen();
322
-
323
- if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
324
- return;
325
- }
326
-
327
- $class = 'notice notice-error';
328
- /* translators: %s: html tags */
329
- $message = sprintf( __( 'The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
330
-
331
- $plugin = 'woocommerce/woocommerce.php';
332
-
333
- if ( _is_woo_installed() ) {
334
- if ( ! current_user_can( 'activate_plugins' ) ) {
335
- return;
336
- }
337
-
338
- $action_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
339
- $button_label = __( 'Activate WooCommerce', 'cartflows' );
340
-
341
- } else {
342
- if ( ! current_user_can( 'install_plugins' ) ) {
343
- return;
344
- }
345
-
346
- $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
347
- $button_label = __( 'Install WooCommerce', 'cartflows' );
348
- }
349
-
350
- $button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
351
-
352
- printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
353
- }
354
-
355
- /**
356
- * Activation Reset
357
- */
358
- function activation_reset() {
359
-
360
- include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
361
- include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
362
-
363
- Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
364
- Cartflows_Step_Post_Type::get_instance()->step_post_type();
365
- flush_rewrite_rules();
366
- }
367
-
368
- /**
369
- * Deactivation Reset
370
- */
371
- function deactivation_reset() {
372
- }
373
-
374
- /**
375
- * Logger Class Instance
376
- */
377
- function logger() {
378
- return Cartflows_Logger::get_instance();
379
- }
380
-
381
-
382
- }
383
-
384
- /**
385
- * Prepare if class 'Cartflows_Loader' exist.
386
- * Kicking this off by calling 'get_instance()' method
387
- */
388
- Cartflows_Loader::get_instance();
389
- }
390
-
391
- /**
392
- * Get global class.
393
- *
394
- * @return object
395
- */
396
- function wcf() {
397
- return Cartflows_Loader::get_instance();
398
- }
399
-
400
- if ( ! function_exists( '_is_woo_installed' ) ) {
401
-
402
- /**
403
- * Is woocommerce plugin installed.
404
- *
405
- * @since 1.0.0
406
- *
407
- * @access public
408
- */
409
- function _is_woo_installed() {
410
-
411
- $path = 'woocommerce/woocommerce.php';
412
- $plugins = get_plugins();
413
-
414
- return isset( $plugins[ $path ] );
415
- }
416
- }
1
+ <?php
2
+ /**
3
+ * CartFlows Loader.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ if ( ! class_exists( 'Cartflows_Loader' ) ) {
9
+
10
+ /**
11
+ * Class Cartflows_Loader.
12
+ */
13
+ final class Cartflows_Loader {
14
+
15
+ /**
16
+ * Member Variable
17
+ *
18
+ * @var instance
19
+ */
20
+ private static $instance = null;
21
+
22
+ /**
23
+ * Member Variable
24
+ *
25
+ * @var utils
26
+ */
27
+ public $utils = null;
28
+
29
+ /**
30
+ * Member Variable
31
+ *
32
+ * @var logger
33
+ */
34
+ public $logger = null;
35
+
36
+ /**
37
+ * Member Variable
38
+ *
39
+ * @var session
40
+ */
41
+ public $session = null;
42
+
43
+
44
+ /**
45
+ * Member Variable
46
+ *
47
+ * @var options
48
+ */
49
+ public $options = null;
50
+
51
+ /**
52
+ * Member Variable
53
+ *
54
+ * @var meta
55
+ */
56
+ public $meta = null;
57
+
58
+ /**
59
+ * Member Variable
60
+ *
61
+ * @var flow
62
+ */
63
+ public $flow = null;
64
+
65
+ /**
66
+ * Initiator
67
+ */
68
+ public static function get_instance() {
69
+
70
+ if ( is_null( self::$instance ) ) {
71
+
72
+ self::$instance = new self;
73
+
74
+ /**
75
+ * CartFlows loaded.
76
+ *
77
+ * Fires when Cartflows was fully loaded and instantiated.
78
+ *
79
+ * @since 1.0.0
80
+ */
81
+ do_action( 'cartflows_loaded' );
82
+ }
83
+
84
+ return self::$instance;
85
+ }
86
+
87
+ /**
88
+ * Constructor
89
+ */
90
+ public function __construct() {
91
+
92
+ $this->define_constants();
93
+
94
+ // Activation hook.
95
+ register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
96
+
97
+ // deActivation hook.
98
+ register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
99
+
100
+ add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
101
+
102
+ add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
103
+
104
+ // Update compatibility.
105
+ require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
106
+ }
107
+
108
+ /**
109
+ * Defines all constants
110
+ *
111
+ * @since 1.0.0
112
+ */
113
+ public function define_constants() {
114
+
115
+ define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
116
+ define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
117
+ define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
118
+ define( 'CARTFLOWS_VER', '1.1.0' );
119
+ define( 'CARTFLOWS_SLUG', 'cartflows' );
120
+ define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
121
+
122
+ define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
123
+ define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
124
+
125
+ if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
126
+ define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
127
+ }
128
+ define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
129
+ define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
130
+ define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
131
+ define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
132
+
133
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
134
+ define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
135
+ }
136
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
137
+ define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Loads plugin files.
143
+ *
144
+ * @since 1.0.0
145
+ *
146
+ * @return void
147
+ */
148
+ function load_plugin() {
149
+
150
+ if ( ! function_exists( 'WC' ) ) {
151
+ add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
152
+ return;
153
+ }
154
+
155
+ $this->load_helper_files_components();
156
+ $this->load_core_files();
157
+ $this->load_core_components();
158
+
159
+ /**
160
+ * CartFlows Init.
161
+ *
162
+ * Fires when Cartflows is instantiated.
163
+ *
164
+ * @since 1.0.0
165
+ */
166
+ do_action( 'cartflows_init' );
167
+ }
168
+
169
+ /**
170
+ * Load Helper Files and Components.
171
+ *
172
+ * @since 1.0.0
173
+ *
174
+ * @return void
175
+ */
176
+ function load_helper_files_components() {
177
+
178
+ /* Public Utils */
179
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
180
+
181
+ /* Public Session */
182
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
183
+
184
+ /* Public Global namespace functions */
185
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
186
+
187
+ /* Admin Helper */
188
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
189
+
190
+ /* Meta Default Values */
191
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
192
+
193
+ $this->utils = Cartflows_Utils::get_instance();
194
+ $this->session = Cartflows_Session::get_instance();
195
+ $this->options = Cartflows_Default_Meta::get_instance();
196
+
197
+ }
198
+
199
+ /**
200
+ * Load Core Files.
201
+ *
202
+ * @since 1.0.0
203
+ *
204
+ * @return void
205
+ */
206
+ function load_core_files() {
207
+
208
+ /* Page builder compatibilty class */
209
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
210
+
211
+ /* Admin Meta Fields*/
212
+ include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
213
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
214
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
215
+
216
+ /* Cloning */
217
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
218
+
219
+ /* Admin Settings */
220
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
221
+
222
+ /* Core Modules */
223
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
224
+
225
+ /* Frontend Global */
226
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
227
+ require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
228
+
229
+ /* Modules */
230
+ include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
231
+ include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
232
+ include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
233
+ include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
234
+
235
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
236
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
237
+
238
+ include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
239
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
240
+ }
241
+
242
+ /**
243
+ * Load Core Components.
244
+ *
245
+ * @since 1.0.0
246
+ *
247
+ * @return void
248
+ */
249
+ function load_core_components() {
250
+
251
+ $this->meta = Cartflows_Meta_Fields::get_instance();
252
+ $this->logger = Cartflows_Logger::get_instance();
253
+ $this->flow = Cartflows_Flow_Frontend::get_instance();
254
+ }
255
+
256
+ /**
257
+ * Load CartFlows Pro Text Domain.
258
+ * This will load the translation textdomain depending on the file priorities.
259
+ * 1. Global Languages /wp-content/languages/cartflows/ folder
260
+ * 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
261
+ *
262
+ * @since 1.0.3
263
+ * @return void
264
+ */
265
+ public function load_cf_textdomain() {
266
+
267
+ // Default languages directory for CartFlows Pro.
268
+ $lang_dir = CARTFLOWS_DIR . 'languages/';
269
+
270
+ /**
271
+ * Filters the languages directory path to use for CartFlows Pro.
272
+ *
273
+ * @param string $lang_dir The languages directory path.
274
+ */
275
+ $lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
276
+
277
+ // Traditional WordPress plugin locale filter.
278
+ global $wp_version;
279
+
280
+ $get_locale = get_locale();
281
+
282
+ if ( $wp_version >= 4.7 ) {
283
+ $get_locale = get_user_locale();
284
+ }
285
+
286
+ /**
287
+ * Language Locale for CartFlows Pro
288
+ *
289
+ * @var $get_locale The locale to use.
290
+ * Uses get_user_locale()` in WordPress 4.7 or greater,
291
+ * otherwise uses `get_locale()`.
292
+ */
293
+ $locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
294
+ $mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
295
+
296
+ // Setup paths to current locale file.
297
+ $mofile_local = $lang_dir . $mofile;
298
+ $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
299
+
300
+ if ( file_exists( $mofile_global ) ) {
301
+ // Look in global /wp-content/languages/cartflows/ folder.
302
+ load_textdomain( 'cartflows', $mofile_global );
303
+ } elseif ( file_exists( $mofile_local ) ) {
304
+ // Look in local /wp-content/plugins/cartflows/languages/ folder.
305
+ load_textdomain( 'cartflows', $mofile_local );
306
+ } else {
307
+ // Load the default language files.
308
+ load_plugin_textdomain( 'cartflows', false, $lang_dir );
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Fires admin notice when Elementor is not installed and activated.
314
+ *
315
+ * @since 1.0.0
316
+ *
317
+ * @return void
318
+ */
319
+ public function fails_to_load() {
320
+
321
+ $screen = get_current_screen();
322
+
323
+ if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
324
+ return;
325
+ }
326
+
327
+ $class = 'notice notice-error';
328
+ /* translators: %s: html tags */
329
+ $message = sprintf( __( 'The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
330
+
331
+ $plugin = 'woocommerce/woocommerce.php';
332
+
333
+ if ( _is_woo_installed() ) {
334
+ if ( ! current_user_can( 'activate_plugins' ) ) {
335
+ return;
336
+ }
337
+
338
+ $action_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
339
+ $button_label = __( 'Activate WooCommerce', 'cartflows' );
340
+
341
+ } else {
342
+ if ( ! current_user_can( 'install_plugins' ) ) {
343
+ return;
344
+ }
345
+
346
+ $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
347
+ $button_label = __( 'Install WooCommerce', 'cartflows' );
348
+ }
349
+
350
+ $button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
351
+
352
+ printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
353
+ }
354
+
355
+ /**
356
+ * Activation Reset
357
+ */
358
+ function activation_reset() {
359
+
360
+ include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
361
+ include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
362
+
363
+ Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
364
+ Cartflows_Step_Post_Type::get_instance()->step_post_type();
365
+ flush_rewrite_rules();
366
+ }
367
+
368
+ /**
369
+ * Deactivation Reset
370
+ */
371
+ function deactivation_reset() {
372
+ }
373
+
374
+ /**
375
+ * Logger Class Instance
376
+ */
377
+ function logger() {
378
+ return Cartflows_Logger::get_instance();
379
+ }
380
+
381
+
382
+ }
383
+
384
+ /**
385
+ * Prepare if class 'Cartflows_Loader' exist.
386
+ * Kicking this off by calling 'get_instance()' method
387
+ */
388
+ Cartflows_Loader::get_instance();
389
+ }
390
+
391
+ /**
392
+ * Get global class.
393
+ *
394
+ * @return object
395
+ */
396
+ function wcf() {
397
+ return Cartflows_Loader::get_instance();
398
+ }
399
+
400
+ if ( ! function_exists( '_is_woo_installed' ) ) {
401
+
402
+ /**
403
+ * Is woocommerce plugin installed.
404
+ *
405
+ * @since 1.0.0
406
+ *
407
+ * @access public
408
+ */
409
+ function _is_woo_installed() {
410
+
411
+ $path = 'woocommerce/woocommerce.php';
412
+ $plugins = get_plugins();
413
+
414
+ return isset( $plugins[ $path ] );
415
+ }
416
+ }
classes/class-cartflows-meta-fields.php CHANGED
@@ -1,940 +1,962 @@
1
- <?php
2
- // @codingStandardsIgnoreStart
3
- /**
4
- * Meta Fields.
5
- *
6
- * @package CartFlows
7
- */
8
-
9
- /**
10
- * Class Cartflows_Meta_Fields.
11
- */
12
- class Cartflows_Meta_Fields {
13
-
14
- /**
15
- * Instance
16
- *
17
- * @var $instance
18
- */
19
- private static $instance;
20
-
21
- /**
22
- * Initiator
23
- */
24
- public static function get_instance() {
25
- if ( ! isset( self::$instance ) ) {
26
- self::$instance = new self;
27
- }
28
-
29
- return self::$instance;
30
- }
31
-
32
- /**
33
- * Constructor
34
- */
35
- public function __construct() {
36
-
37
- /* Add Scripts */
38
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_meta_scripts' ), 20 );
39
-
40
- add_action( 'wp_ajax_wcf_json_search_coupons', array( $this, 'json_search_coupons' ) );
41
-
42
- add_action( 'wp_ajax_wcf_add_checkout_custom_field', array( $this, 'add_checkout_custom_field' ) );
43
- add_action( 'wp_ajax_wcf_delete_checkout_custom_field', array( $this, 'delete_checkout_custom_field' ) );
44
-
45
- add_action( 'wp_ajax_wcf_json_search_pages', array( $this, 'json_search_pages' ) );
46
-
47
- add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
48
- }
49
-
50
- public function admin_meta_scripts() {
51
-
52
- global $pagenow;
53
- global $post;
54
-
55
- $screen = get_current_screen();
56
-
57
- if (
58
- ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) &&
59
- wcf()->utils->is_step_post_type( $screen->post_type )
60
- ) {
61
-
62
- wp_enqueue_style( 'woocommerce_admin_styles' );
63
-
64
- wp_enqueue_script( 'select2' );
65
- wp_enqueue_script( 'wc-enhanced-select' );
66
-
67
- wp_enqueue_script(
68
- 'wcf-admin-meta',
69
- CARTFLOWS_URL . 'admin/meta-assets/js/admin-edit.js',
70
- array( 'jquery', 'select2', 'wp-color-picker' ),
71
- CARTFLOWS_VER,
72
- true
73
- );
74
-
75
- wp_enqueue_style( 'wcf-admin-meta', CARTFLOWS_URL . 'admin/meta-assets/css/admin-edit.css', array( 'wp-color-picker' ), CARTFLOWS_VER );
76
- wp_style_add_data( 'wcf-admin-meta', 'rtl', 'replace' );
77
-
78
- $localize = array(
79
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
80
- 'google_fonts' => CartFlows_Font_Families::get_google_fonts(),
81
- 'system_fonts' => CartFlows_Font_Families::get_system_fonts(),
82
- 'font_weights' => array(
83
- '100' => __( 'Thin 100', 'cartflows' ),
84
- '200' => __( 'Extra-Light 200', 'cartflows' ),
85
- '300' => __( 'Light 300', 'cartflows' ),
86
- '400' => __( 'Normal 400', 'cartflows' ),
87
- '500' => __( 'Medium 500', 'cartflows' ),
88
- '600' => __( 'Semi-Bold 600', 'cartflows' ),
89
- '700' => __( 'Bold 700', 'cartflows' ),
90
- '800' => __( 'Extra-Bold 800', 'cartflows' ),
91
- '900' => __( 'Ultra-Bold 900', 'cartflows' ),
92
- )
93
- );
94
-
95
- wp_localize_script( 'jquery', 'wcf', apply_filters( 'wcf_js_localize', $localize ) );
96
-
97
- do_action( 'cartflows_admin_meta_scripts' );
98
- }
99
- }
100
-
101
- /**
102
- * Function to search coupons
103
- */
104
- public function json_search_coupons() {
105
-
106
- check_admin_referer( 'wcf-json-search-coupons', 'security' );
107
-
108
- global $wpdb;
109
-
110
- $term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
111
-
112
- if ( empty( $term ) ) {
113
- die();
114
- }
115
-
116
- $posts = wp_cache_get( 'wcf_search_coupons', 'wcf_funnel_Cart' );
117
-
118
- if ( false === $posts ) {
119
- $posts = $wpdb->get_results( // phpcs:ignore
120
- $wpdb->prepare(
121
- "SELECT *
122
- FROM {$wpdb->prefix}posts
123
- WHERE post_type = %s
124
- AND post_title LIKE %s
125
- AND post_status = %s",
126
- 'shop_coupon',
127
- $wpdb->esc_like( $term ) . '%',
128
- 'publish'
129
- )
130
- );
131
- wp_cache_set( 'wcf_search_coupons', $posts, 'wcf_funnel_Cart' );
132
- }
133
-
134
- $coupons_found = array();
135
- $all_discount_types = wc_get_coupon_types();
136
-
137
- if ( $posts ) {
138
- foreach ( $posts as $post ) {
139
-
140
- $discount_type = get_post_meta( $post->ID, 'discount_type', true );
141
-
142
- if ( ! empty( $all_discount_types[ $discount_type ] ) ) {
143
- $coupons_found[ get_the_title( $post->ID ) ] = get_the_title( $post->ID ) . ' (Type: ' . $all_discount_types[ $discount_type ] . ')';
144
- }
145
- }
146
- }
147
-
148
- wp_send_json( $coupons_found );
149
- }
150
-
151
- /**
152
- * [add_checkout_custom_field description]
153
- *
154
- * @hook wcf_add_checkout_custom_field
155
- */
156
- public function add_checkout_custom_field() {
157
-
158
- check_ajax_referer( 'wcf-add-checkout-custom-field', 'security' );
159
-
160
- $post_id = intval( $_POST['post_id'] );
161
- $add_to = sanitize_text_field( wp_unslash( $_POST['add_to'] ) );
162
- $type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
163
- $label = sanitize_text_field( wp_unslash( $_POST['label'] ) );
164
- $name = sanitize_text_field( wp_unslash( $_POST['name'] ) );
165
-
166
- if ( '' !== $name ) {
167
-
168
- $fields = Cartflows_Helper::get_checkout_fields( $add_to, $post_id );
169
- $field_keys = array_keys($fields);
170
-
171
- $name = $add_to . '_' . sanitize_key( $name );
172
- if( in_array($name, $field_keys) ) {
173
- $name = $name . '_' . rand( 0000, 9999 );
174
- }
175
-
176
- $field_data = array(
177
- 'type' => $type,
178
- 'label' => $label,
179
- 'placeholder' => '',
180
- 'options' => array(),
181
- 'class' => array( 'form-row-wide' ),
182
- 'label_class' => array(),
183
- 'required' => true,
184
- 'custom' => true,
185
- );
186
-
187
- Cartflows_Helper::add_checkout_field( $add_to, $name, $field_data, $post_id );
188
-
189
- $key = sanitize_key( $name );
190
- $name = 'wcf-' . $key;
191
-
192
- $field_args = array(
193
- 'label' => $label,
194
- 'name' => $name,
195
- 'value' => 'yes',
196
- 'after' => 'Enable',
197
- );
198
-
199
- $field_args['after_html'] = '<span class="wcf-cpf-actions" data-type="billing" data-key="' . $key . '"> | ';
200
- $field_args['after_html'] .= '<a class="wcf-cpf-action-remove">' . __( 'Remove', 'cartflows' ) . '</a>';
201
- $field_args['after_html'] .= '</span>';
202
-
203
- $field_markup = wcf()->meta->get_checkbox_field( $field_args );
204
-
205
- if( 'billing' === $add_to ) {
206
- $add_to_class = 'wcf-cb-fields';
207
- } else if( 'shipping' === $add_to ) {
208
- $add_to_class = 'wcf-sb-fields';
209
- }
210
-
211
- $data = array(
212
- 'field_data' => $field_data,
213
- 'field_args' => $field_args,
214
- 'add_to_class' => $add_to_class,
215
- 'markup' => $field_markup,
216
- );
217
-
218
- wp_send_json( $data );
219
- }
220
-
221
- wp_send_json( false );
222
-
223
- }
224
-
225
- /**
226
- * [delete_checkout_custom_field description]
227
- *
228
- * @hook wcf_delete_checkout_custom_field
229
- * @return [type] [description]
230
- */
231
- public function delete_checkout_custom_field() {
232
-
233
- check_ajax_referer( 'wcf-delete-checkout-custom-field', 'security' );
234
-
235
- $post_id = intval( $_POST['post_id'] );
236
- $type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
237
- $key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
238
-
239
- if ( '' !== $key ) {
240
-
241
- Cartflows_Helper::delete_checkout_field( $type, $key, $post_id );
242
-
243
- wp_send_json( true );
244
-
245
- }
246
-
247
- wp_send_json( false );
248
-
249
- }
250
-
251
- /**
252
- * Function to search coupons
253
- */
254
- public function json_search_pages() {
255
-
256
- check_ajax_referer( 'wcf-json-search-pages', 'security' );
257
-
258
- $term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
259
-
260
- if ( empty( $term ) ) {
261
- die( 'not found' );
262
- }
263
-
264
- $search_string = $term;
265
- $data = array();
266
- $result = array();
267
-
268
- add_filter( 'posts_search', array( $this, 'search_only_titles' ), 10, 2 );
269
-
270
- $query = new WP_Query(
271
- array(
272
- 's' => $search_string,
273
- 'post_type' => 'page',
274
- 'posts_per_page' => - 1,
275
- )
276
- );
277
-
278
- if ( $query->have_posts() ) {
279
- while ( $query->have_posts() ) {
280
- $query->the_post();
281
- $title = get_the_title();
282
- $title .= ( 0 != $query->post->post_parent ) ? ' (' . get_the_title( $query->post->post_parent ) . ')' : '';
283
- $id = get_the_id();
284
- $data[] = array(
285
- 'id' => $id,
286
- 'text' => $title,
287
- );
288
- }
289
- }
290
-
291
- if ( is_array( $data ) && ! empty( $data ) ) {
292
- $result[] = array(
293
- 'text' => '',
294
- 'children' => $data,
295
- );
296
- }
297
-
298
- wp_reset_postdata();
299
-
300
- // return the result in json.
301
- wp_send_json( $result );
302
- }
303
-
304
- public function search_only_titles( $search, $wp_query ) {
305
- if ( ! empty( $search ) && ! empty( $wp_query->query_vars['search_terms'] ) ) {
306
- global $wpdb;
307
-
308
- $q = $wp_query->query_vars;
309
- $n = ! empty( $q['exact'] ) ? '' : '%';
310
-
311
- $search = array();
312
-
313
- foreach ( (array) $q['search_terms'] as $term ) {
314
- $search[] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like( $term ) . $n );
315
- }
316
-
317
- if ( ! is_user_logged_in() ) {
318
- $search[] = "$wpdb->posts.post_password = ''";
319
- }
320
-
321
- $search = ' AND ' . implode( ' AND ', $search );
322
- }
323
-
324
- return $search;
325
- }
326
-
327
- function get_field( $field_data, $field_content ) {
328
-
329
- $label = isset( $field_data['label'] ) ? $field_data['label'] : '';
330
- $help = isset( $field_data['help'] ) ? $field_data['help'] : '';
331
- $after_html = isset( $field_data['after_html'] ) ? $field_data['after_html'] : '';
332
-
333
- $name_class = 'field-' . $field_data['name'];
334
-
335
- $field_html = '<div class="wcf-field-row ' . $name_class . '">';
336
-
337
- if( ! empty( $label ) || ! empty( $help ) ) {
338
- $field_html .= '<div class="wcf-field-row-heading">';
339
- if( ! empty( $label ) ) {
340
- $field_html .= '<label>' . esc_html( $label ) . '</label>';
341
- }
342
- if ( ! empty( $help ) ) {
343
- $field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help">';
344
- // $field_html .= '<span class="wcf-tooltip" data-tooltip= "'. esc_attr( $help ) .'"></span>';
345
- $field_html .= '</i>';
346
- $field_html .= '<span class="wcf-tooltip-text">';
347
- $field_html .= $help;
348
- $field_html .= '</span>';
349
- }
350
- $field_html .= '</div>';
351
- }
352
-
353
- $field_html .= '<div class="wcf-field-row-content">';
354
- $field_html .= $field_content;
355
-
356
- if ( ! empty( $after_html ) ) {
357
- $field_html .= $after_html;
358
- }
359
-
360
- $field_html .= '</div>';
361
- $field_html .= '</div>';
362
-
363
- return $field_html;
364
- }
365
-
366
- function get_text_field( $field_data ) {
367
-
368
- $value = $field_data['value'];
369
-
370
- $attr = '';
371
-
372
- if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
373
-
374
- foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
375
- $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
376
- }
377
- }
378
-
379
- $field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
380
-
381
- return $this->get_field( $field_data, $field_content );
382
- }
383
-
384
- function get_shortcode_field( $field_data ) {
385
-
386
- $attr = '';
387
-
388
- $attr_fields = array(
389
- 'readonly' => 'readonly',
390
- 'onfocus' => 'this.select()',
391
- 'onmouseup' => 'return false',
392
- );
393
-
394
- if ( $attr_fields && is_array( $attr_fields ) ) {
395
-
396
- foreach ( $attr_fields as $attr_key => $attr_value ) {
397
- $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
398
- }
399
- }
400
-
401
- $field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $field_data['content'] . '" ' . $attr . '>';
402
-
403
- return $this->get_field( $field_data, $field_content );
404
- }
405
-
406
- function get_display_field( $field_data ) {
407
-
408
- $field_content = $field_data['content'];
409
-
410
- return $this->get_field( $field_data, $field_content );
411
- }
412
-
413
- function get_number_field( $field_data ) {
414
-
415
- $value = $field_data['value'];
416
-
417
- $attr = '';
418
-
419
- if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
420
-
421
- foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
422
- $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
423
- }
424
- }
425
-
426
- $field_content = '<input type="number" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
427
-
428
- return $this->get_field( $field_data, $field_content );
429
- }
430
-
431
- function get_hidden_field( $field_data ) {
432
-
433
- $value = $field_data['value'];
434
-
435
- $attr = '';
436
-
437
- if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
438
-
439
- foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
440
- $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
441
- }
442
- }
443
-
444
- $field_content = '<input type="hidden" id="' . $field_data['name'] . '" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
445
-
446
- return $this->get_field( $field_data, $field_content );
447
- }
448
-
449
- function get_area_field( $field_data ) {
450
-
451
- $value = $field_data['value'];
452
-
453
- $field_content = '<textarea name="' . $field_data['name'] . '" rows="10" cols="50">';
454
- $field_content .= $value;
455
- $field_content .= '</textarea>';
456
-
457
- return $this->get_field( $field_data, $field_content );
458
- }
459
-
460
- function get_checkbox_field( $field_data ) {
461
-
462
- $value = $field_data['value'];
463
-
464
- $field_content = '';
465
- if ( isset( $field_data['before'] ) ) {
466
- $field_content .= '<span>' . $field_data['before'] . '</span>';
467
- }
468
- $field_content .= '<input type="hidden" name="' . $field_data['name'] . '" value="no">';
469
- $field_content .= '<input type="checkbox" name="' . $field_data['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
470
-
471
- if ( isset( $field_data['after'] ) ) {
472
- $field_content .= '<span>' . $field_data['after'] . '</span>';
473
- }
474
-
475
- return $this->get_field( $field_data, $field_content );
476
- }
477
-
478
- function get_font_family_field( $field_data ) {
479
-
480
- $value = $field_data['value'];
481
-
482
- $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
483
-
484
- $field_content = '<select class="wcf-field-font-family" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
485
-
486
- $field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
487
-
488
- $field_content .= '<optgroup label="Other System Fonts">';
489
- foreach ( CartFlows_Font_Families::get_system_fonts() as $name => $variants ) {
490
- $field_content .= '<option value="' . esc_attr( $name ) . '" ' . selected( $name, $value, false ) . '>' . esc_attr( $name ) . '</option>';
491
- }
492
- $field_content .= '</optgroup>';
493
- $field_content .= '<optgroup label="Google">';
494
- foreach ( CartFlows_Font_Families::get_google_fonts() as $name => $single_font ) {
495
- $variants = wcf_get_prop( $single_font, '0' );
496
- $category = wcf_get_prop( $single_font, '1' );
497
- $font_value = '\'' . esc_attr( $name ) . '\', ' . esc_attr( $category );
498
- $field_content .= '<option value="' . esc_attr( $font_value ) . '" ' . selected( $font_value, $value, false ) . '>' . esc_attr( $name ) . '</option>';
499
- }
500
- $field_content .= '</optgroup>';
501
-
502
- $field_content .= '</select>';
503
-
504
- return $this->get_field( $field_data, $field_content );
505
- }
506
-
507
- function get_font_weight_field( $field_data ) {
508
-
509
- $value = $field_data['value'];
510
-
511
- $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
512
-
513
- $field_content = '<select data-selected="'.esc_attr( $value ).'" class="wcf-field-font-weight" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
514
-
515
- $field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
516
-
517
- $field_content .= '</select>';
518
-
519
- return $this->get_field( $field_data, $field_content );
520
- }
521
-
522
- function get_select_field( $field_data ) {
523
-
524
- $value = $field_data['value'];
525
- $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
526
-
527
- $field_content = '<select name="' . $field_data['name'] . '">';
528
-
529
-
530
- if ( is_array( $field_data['options'] ) && ! empty( $field_data['options'] ) ) {
531
-
532
- foreach ( $field_data['options'] as $data_key => $data_value ) {
533
-
534
- $disabled = '';
535
-
536
- if ( array_key_exists( $data_key, $pro_options ) ) {
537
- $disabled = 'disabled ';
538
- $data_value = $pro_options[ $data_key ];
539
- }
540
-
541
- $field_content .= '<option value="' . $data_key . '" ' . selected( $value, $data_key, false ) . ' ' . $disabled .'>' . $data_value . '</option>';
542
- }
543
- }
544
-
545
- $field_content .= '</select>';
546
-
547
- if ( isset( $field_data['after'] ) ) {
548
- $field_content .= '<span>' . $field_data['after'] . '</span>';
549
- }
550
-
551
- return $this->get_field( $field_data, $field_content );
552
- }
553
-
554
- function get_color_picker_field( $field_data ) {
555
-
556
- $value = $field_data['value'];
557
-
558
- $field_content = '<input class="wcf-color-picker" type="text" name="' . $field_data['name'] . '" value="' . $value . '">';
559
-
560
- return $this->get_field( $field_data, $field_content );
561
- }
562
-
563
- function get_product_selection_field( $field_data ) {
564
-
565
- $value = $field_data['value'];
566
-
567
- $multiple = '';
568
-
569
- if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
570
- $multiple = ' multiple="multiple"';
571
- }
572
-
573
- $allow_clear = '';
574
-
575
- if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
576
- $allow_clear = ' data-allow_clear="allow_clear"';
577
- }
578
-
579
- $field_content = '<select
580
- name="' . $field_data['name'] . '[]"
581
- class="wcf-product-search" ' . $multiple . $allow_clear . '
582
- data-placeholder="' . __( 'Search for a product&hellip;', 'cartflows' ) . '"
583
- data-action="woocommerce_json_search_products_and_variations">';
584
-
585
- if ( is_array( $value ) && ! empty( $value ) ) {
586
-
587
- foreach ( $value as $data_key => $product_id ) {
588
-
589
- $product = wc_get_product( $product_id );
590
-
591
- // posts.
592
- if ( ! empty( $product ) ) {
593
- $post_title = $product->get_name() . ' (#' . $product_id . ')';
594
-
595
- $field_content .= '<option value="' . $product_id . '" selected="selected" >' . $post_title . '</option>';
596
- }
597
- }
598
- }
599
- $field_content .= '</select>';
600
-
601
- return $this->get_field( $field_data, $field_content );
602
- }
603
-
604
- function get_coupon_selection_field( $field_data ) {
605
-
606
- $value = $field_data['value'];
607
-
608
- $multiple = '';
609
-
610
- if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
611
- $multiple = ' multiple="multiple"';
612
- }
613
-
614
- $allow_clear = '';
615
-
616
- if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
617
- $allow_clear = ' data-allow_clear="allow_clear"';
618
- }
619
-
620
- $field_content = '<select
621
- name="' . $field_data['name'] . '[]"
622
- class="wc-coupon-search wcf-coupon-search" ' . $multiple . $allow_clear . '
623
- data-placeholder="' . __( 'Search for a coupon&hellip;', 'cartflows' ) . '"
624
- data-action="wcf_json_search_coupons">';
625
-
626
- if ( is_array( $value ) && ! empty( $value ) ) {
627
-
628
- $all_discount_types = wc_get_coupon_types();
629
-
630
- foreach ( $value as $coupon_title ) {
631
-
632
- $coupon = new WC_Coupon( $coupon_title );
633
-
634
- $discount_type = $coupon->get_discount_type();
635
-
636
- if ( isset( $discount_type ) && $discount_type ) {
637
- $discount_type = ' ( Type: ' . $all_discount_types[ $discount_type ] . ' )';
638
- }
639
-
640
- $field_content .= '<option value="' . $coupon_title . '" selected="selected">' . $coupon_title . $discount_type . '</option>';
641
- }
642
- }
643
-
644
- $field_content .= '</select>';
645
-
646
- return $this->get_field( $field_data, $field_content );
647
- }
648
-
649
- function get_page_selection_field( $field_data ) {
650
-
651
- $value = $field_data['value'];
652
-
653
- $multiple = '';
654
-
655
- if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
656
- $multiple = 'multiple="multiple"';
657
- }
658
-
659
- $field_content = '<select
660
- name="' . $field_data['name'] . '[]"
661
- class="wcf-search-pages" ' . $multiple . '"
662
- data-action="wcf_json_search_pages">';
663
-
664
- if ( is_array( $value ) && ! empty( $value ) ) {
665
-
666
- foreach ( $value as $data_key => $data_value ) {
667
-
668
- $field_content .= '<option value="' . $data_value . '">' . get_the_title( $data_value ) . '</option>';
669
- }
670
- }
671
-
672
- $field_content .= '</select>';
673
-
674
- return $this->get_field( $field_data, $field_content );
675
- }
676
-
677
- function get_section( $field_data ) {
678
- $field_html = '<div class="wcf-field-row wcf-field-section">';
679
- $field_html .= '<div class="wcf-field-section-heading" colspan="2">';
680
- $field_html .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
681
-
682
- if ( isset( $field_data['help'] ) ) {
683
- $field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help" title="' . esc_attr( $field_data['help'] ) . '"></i>';
684
- }
685
- $field_html .= '</div>';
686
- $field_html .= '</div>';
687
- return $field_html;
688
- }
689
-
690
- function get_description_field( $field_data ) {
691
-
692
- $field_html = '<div class="wcf-field-row wcf-field-desc ' . $field_data['name'] . '">';
693
- $field_html .= '<div class="wcf-field-desc-content">';
694
- $field_html .= $field_data['content'];
695
- $field_html .= '</div>';
696
- $field_html .= '</div>';
697
-
698
- return $field_html;
699
- }
700
-
701
- function get_checkout_field_repeater( $field_data ) {
702
-
703
- $value = array();
704
-
705
- $value[0] = array(
706
- 'add_to' => '',
707
- 'type' => '',
708
- 'label' => '',
709
- 'name' => '',
710
- );
711
-
712
- $field_content = '';
713
-
714
- $field_content .= '<div class="wcf-field-row">';
715
- // $field_content .= '<div class="wcf-field-row-heading">';
716
- // $field_content .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
717
- // $field_content .= '</div>';
718
- $field_content .= '<div class="wcf-field-row-content">';
719
- $field_content .= '<div class="wcf-cpf-wrap">';
720
-
721
- foreach ( $value as $p_key => $p_data ) {
722
- $field_content .= '<div class="wcf-cpf-row" data-key="' . $p_key . '">';
723
- $field_content .= '<div class="wcf-cpf-row-header">';
724
- $field_content .= '<span class="wcf-cpf-row-title">Add New Custom Field</span>';
725
- $field_content .= '</div>';
726
-
727
- $field_content .= '<div class="wcf-cpf-row-standard-fields">';
728
-
729
- /* Add To */
730
- $field_content .= '<div class="wcf-cpf-fields wcf-cpf-add_to">';
731
- $field_content .= '<span class="wcf-cpf-row-setting-label">Add to</span>';
732
- $field_content .= '<span class="wcf-cpf-row-setting-field">';
733
- $field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][add_to]" class="wcf-cpf-add_to">';
734
- $field_content .= '<option value="billing">Billing</option>';
735
- $field_content .= '<option value="shipping">Shipping</option>';
736
- $field_content .= '</select>';
737
- $field_content .= '</span>';
738
- $field_content .= '</div>';
739
-
740
- /* Type */
741
- $field_content .= '<div class="wcf-cpf-fields wcf-cpf-type">';
742
- $field_content .= '<span class="wcf-cpf-row-setting-label">Type</span>';
743
- $field_content .= '<span class="wcf-cpf-row-setting-field">';
744
- $field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][type]" class="wcf-cpf-type">';
745
- $field_content .= '<option value="text">Text</option>';
746
- $field_content .= '<option value="textarea">Textarea</option>';
747
- $field_content .= '<option value="select">Select</option>';
748
- $field_content .= '<option value="checkbox">Checkbox</option>';
749
- $field_content .= '</select>';
750
- $field_content .= '</span>';
751
- $field_content .= '</div>';
752
-
753
- /* Label */
754
- $field_content .= '<div class="wcf-cpf-fields wcf-cpf-label">';
755
- $field_content .= '<span class="wcf-cpf-row-setting-label">Label *</span>';
756
- $field_content .= '<span class="wcf-cpf-row-setting-field">';
757
- $field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-label">';
758
- $field_content .= '</span>';
759
- $field_content .= '</div>';
760
-
761
- /* Name */
762
- $field_content .= '<div class="wcf-cpf-fields wcf-cpf-name">';
763
- $field_content .= '<span class="wcf-cpf-row-setting-label">Name *</span>';
764
- $field_content .= '<span class="wcf-cpf-row-setting-field">';
765
- $field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][name]" class="wcf-cpf-name">';
766
- $field_content .= '</span>';
767
- $field_content .= '</div>';
768
-
769
- $field_content .= '</div>';
770
- $field_content .= '</div>';
771
- }
772
-
773
- /* Add New Custom Field */
774
- $field_content .= '<div class="wcf-cpf-add-row">';
775
- $field_content .= '<div class="wcf-cpf-add-wrap">';
776
- $field_content .= '<button class="button button-secondary wcf-cpf-add" data-name="wcf-checkout-custom-fields">Add New Field</button>';
777
- $field_content .= '</div>';
778
- $field_content .= '</div>';
779
- /* End Add new custom field */
780
-
781
- $field_content .= '</div>';
782
- $field_content .= '</div>';
783
- $field_content .= '</div>';
784
-
785
- return $field_content;
786
- }
787
-
788
- function get_product_selection_repeater( $field_data ) {
789
-
790
- $value = $field_data['value'];
791
-
792
- if ( ! is_array( $value ) ) {
793
-
794
- $value[0] = array(
795
- 'product' => '',
796
- );
797
- } else {
798
-
799
- if ( ! isset( $value[0] ) ) {
800
-
801
- $value[0] = array(
802
- 'product' => '',
803
- );
804
- }
805
- }
806
-
807
- $field_html = '';
808
-
809
- $field_html .= '<script type="text/html" id="tmpl-wcf-product-repeater">';
810
- $field_html .= $this->generate_product_repeater_html( '{{id}}' );
811
- $field_html .= '</script>';
812
-
813
- $field_html .= '<div class="wcf-field-row">';
814
- $field_html .= '<div class="wcf-field-row-content">';
815
- $field_html .= '<div class="wcf-repeatables-wrap">';
816
-
817
- if ( is_array( $value ) ) {
818
-
819
- foreach ( $value as $p_key => $p_data ) {
820
-
821
- $selected_options = '';
822
-
823
- if ( isset( $p_data['product'] ) ) {
824
-
825
- $product = wc_get_product( $p_data['product'] );
826
-
827
- // posts.
828
- if ( ! empty( $product ) ) {
829
- $post_title = $product->get_name() . ' (#' . $p_data['product'] . ')';
830
-
831
- $selected_options = '<option value="' . $p_data['product'] . '" selected="selected" >' . $post_title . '</option>';
832
- }
833
- }
834
-
835
- $field_html .= $this->generate_product_repeater_html( $p_key, $selected_options );
836
- }
837
- }
838
-
839
- $field_html .= '<div class="wcf-add-repeatable-row">';
840
- $field_html .= '<div class="submit wcf-add-repeatable-wrap">';
841
- $field_html .= '<button class="button-primary wcf-add-repeatable" data-name="wcf-checkout-products">Add New Product</button>';
842
- $field_html .= '</div>';
843
- $field_html .= '</div>';
844
- $field_html .= '</div>';
845
- $field_html .= '</div>';
846
- $field_html .= '</div>';
847
-
848
- $field_html .= '<div class="wcf-field-row wcf-repeat-notice">';
849
- $field_html .= '<p><i>The selected products will be automatically added in the cart for this checkout.</i></p>';
850
- $field_html .= '</div>';
851
-
852
- return $field_html;
853
- }
854
-
855
- function generate_product_repeater_html( $id, $options = '' ) {
856
-
857
- $field_html = '<div class="wcf-repeatable-row" data-key="' . $id . '">';
858
-
859
- $field_html .= '<div class="wcf-repeatable-row-standard-fields">';
860
-
861
- /* Product Name */
862
- $field_html .= '<div class="wcf-repeatable-fields wcf-sel-product">';
863
- $field_html .= '<span class="wcf-repeatable-row-setting-field">';
864
- $field_html .= '<select
865
- name="wcf-checkout-products[' . $id . '][product]"
866
- class="wcf-product-search"
867
- data-allow_clear="allow_clear"
868
- data-placeholder="' . __( 'Search for a product&hellip;', 'cartflows' ) . '"
869
- data-action="woocommerce_json_search_products_and_variations">';
870
- $field_html .= $options;
871
- $field_html .= '</select>';
872
- $field_html .= '</span>';
873
- $field_html .= '<span class="wcf-repeatable-row-actions">';
874
- $field_html .= '<a class="wcf-remove-row wcf-repeatable-remove button" data-type="product">';
875
- $field_html .= '<span class="dashicons dashicons-trash"></span>';
876
- $field_html .= '<span class="wcf-repeatable-remove-button">'. __( 'Remove', 'cartflows' ).'</span>';
877
- $field_html .= '</a>';
878
- $field_html .= '</span>';
879
- $field_html .= '</div>';
880
- $field_html .= '</div>';
881
- $field_html .= '</div>';
882
-
883
- return $field_html;
884
- }
885
-
886
- function get_image_field( $field_data ) {
887
-
888
- $value = $field_data['value'];
889
-
890
- $attr = '';
891
-
892
- if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
893
-
894
- foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
895
- $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
896
- }
897
- }
898
-
899
- $display_preview_box = ( isset( $value ) && '' != $value ) ? 'display:block;' : 'display:none';
900
-
901
- $field_content = '<div id="wcf-image-preview" style="'.$display_preview_box.'">';
902
- if( isset( $value ) ){
903
- $field_content .= '<img src="'. $value .'" class="saved-image" name="'. $field_data['name'] .'" width="150">';
904
- }
905
- $field_content .= '</div>';
906
- // $field_content .= '<input type="hidden" id="wcf-image-id" class="wcf-image-id" name="wcf-image-id[image-id]" value="">';
907
- $field_content .= '<input type="hidden" id="wcf-image-value" class="wcf-image" name="' . $field_data['name'] . '" value="'.$value.'">';
908
-
909
- $field_content .= '<button type="button" ' . $attr . ' class="wcf-select-image button-secondary">Select Image</button>';
910
-
911
- $display_remove_button = ( isset( $value ) && '' != $value ) ? 'display:inline-block; margin-left: 5px;' : 'display:none';
912
-
913
- $field_content .= '<button type="button" class="wcf-remove-image button-secondary" style="'.$display_remove_button.'">Remove Image</button>';
914
-
915
- return $this->get_field( $field_data, $field_content );
916
- }
917
-
918
- /**
919
- * Localize variables in admin
920
- *
921
- * @param array $vars variables.
922
- */
923
- function localize_vars( $vars ) {
924
-
925
- $ajax_actions = array(
926
- 'wcf_add_checkout_custom_field',
927
- 'wcf_delete_checkout_custom_field',
928
- 'wcf_json_search_pages',
929
- 'wcf_json_search_coupons'
930
- );
931
-
932
- foreach ( $ajax_actions as $action ) {
933
-
934
- $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
935
- }
936
-
937
- return $vars;
938
- }
939
- }
940
- // @codingStandardsIgnoreEnd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // @codingStandardsIgnoreStart
3
+ /**
4
+ * Meta Fields.
5
+ *
6
+ * @package CartFlows
7
+ */
8
+
9
+ /**
10
+ * Class Cartflows_Meta_Fields.
11
+ */
12
+ class Cartflows_Meta_Fields {
13
+
14
+ /**
15
+ * Instance
16
+ *
17
+ * @var $instance
18
+ */
19
+ private static $instance;
20
+
21
+ /**
22
+ * Initiator
23
+ */
24
+ public static function get_instance() {
25
+ if ( ! isset( self::$instance ) ) {
26
+ self::$instance = new self;
27
+ }
28
+
29
+ return self::$instance;
30
+ }
31
+
32
+ /**
33
+ * Constructor
34
+ */
35
+ public function __construct() {
36
+
37
+ /* Add Scripts */
38
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_meta_scripts' ), 20 );
39
+
40
+ add_action( 'wp_ajax_wcf_json_search_coupons', array( $this, 'json_search_coupons' ) );
41
+
42
+ add_action( 'wp_ajax_wcf_add_checkout_custom_field', array( $this, 'add_checkout_custom_field' ) );
43
+ add_action( 'wp_ajax_wcf_delete_checkout_custom_field', array( $this, 'delete_checkout_custom_field' ) );
44
+
45
+ add_action( 'wp_ajax_wcf_json_search_pages', array( $this, 'json_search_pages' ) );
46
+
47
+ add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
48
+ }
49
+
50
+ public function admin_meta_scripts() {
51
+
52
+ global $pagenow;
53
+ global $post;
54
+
55
+ $screen = get_current_screen();
56
+
57
+ if (
58
+ ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) &&
59
+ wcf()->utils->is_step_post_type( $screen->post_type )
60
+ ) {
61
+
62
+ wp_enqueue_style( 'woocommerce_admin_styles' );
63
+
64
+ wp_enqueue_script( 'select2' );
65
+ wp_enqueue_script( 'wc-enhanced-select' );
66
+
67
+ wp_enqueue_script(
68
+ 'wcf-admin-meta',
69
+ CARTFLOWS_URL . 'admin/meta-assets/js/admin-edit.js',
70
+ array( 'jquery', 'select2', 'wp-color-picker' ),
71
+ CARTFLOWS_VER,
72
+ true
73
+ );
74
+
75
+ wp_enqueue_style( 'wcf-admin-meta', CARTFLOWS_URL . 'admin/meta-assets/css/admin-edit.css', array( 'wp-color-picker' ), CARTFLOWS_VER );
76
+ wp_style_add_data( 'wcf-admin-meta', 'rtl', 'replace' );
77
+
78
+ $localize = array(
79
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
80
+ 'google_fonts' => CartFlows_Font_Families::get_google_fonts(),
81
+ 'system_fonts' => CartFlows_Font_Families::get_system_fonts(),
82
+ 'font_weights' => array(
83
+ '100' => __( 'Thin 100', 'cartflows' ),
84
+ '200' => __( 'Extra-Light 200', 'cartflows' ),
85
+ '300' => __( 'Light 300', 'cartflows' ),
86
+ '400' => __( 'Normal 400', 'cartflows' ),
87
+ '500' => __( 'Medium 500', 'cartflows' ),
88
+ '600' => __( 'Semi-Bold 600', 'cartflows' ),
89
+ '700' => __( 'Bold 700', 'cartflows' ),
90
+ '800' => __( 'Extra-Bold 800', 'cartflows' ),
91
+ '900' => __( 'Ultra-Bold 900', 'cartflows' ),
92
+ )
93
+ );
94
+
95
+ wp_localize_script( 'jquery', 'wcf', apply_filters( 'wcf_js_localize', $localize ) );
96
+
97
+ do_action( 'cartflows_admin_meta_scripts' );
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Function to search coupons
103
+ */
104
+ public function json_search_coupons() {
105
+
106
+ check_admin_referer( 'wcf-json-search-coupons', 'security' );
107
+
108
+ global $wpdb;
109
+
110
+ $term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
111
+
112
+ if ( empty( $term ) ) {
113
+ die();
114
+ }
115
+
116
+ $posts = wp_cache_get( 'wcf_search_coupons', 'wcf_funnel_Cart' );
117
+
118
+ if ( false === $posts ) {
119
+ $posts = $wpdb->get_results( // phpcs:ignore
120
+ $wpdb->prepare(
121
+ "SELECT *
122
+ FROM {$wpdb->prefix}posts
123
+ WHERE post_type = %s
124
+ AND post_title LIKE %s
125
+ AND post_status = %s",
126
+ 'shop_coupon',
127
+ $wpdb->esc_like( $term ) . '%',
128
+ 'publish'
129
+ )
130
+ );
131
+ wp_cache_set( 'wcf_search_coupons', $posts, 'wcf_funnel_Cart' );
132
+ }
133
+
134
+ $coupons_found = array();
135
+ $all_discount_types = wc_get_coupon_types();
136
+
137
+ if ( $posts ) {
138
+ foreach ( $posts as $post ) {
139
+
140
+ $discount_type = get_post_meta( $post->ID, 'discount_type', true );
141
+
142
+ if ( ! empty( $all_discount_types[ $discount_type ] ) ) {
143
+ $coupons_found[ get_the_title( $post->ID ) ] = get_the_title( $post->ID ) . ' (Type: ' . $all_discount_types[ $discount_type ] . ')';
144
+ }
145
+ }
146
+ }
147
+
148
+ wp_send_json( $coupons_found );
149
+ }
150
+
151
+ /**
152
+ * [add_checkout_custom_field description]
153
+ *
154
+ * @hook wcf_add_checkout_custom_field
155
+ */
156
+ public function add_checkout_custom_field() {
157
+
158
+ check_ajax_referer( 'wcf-add-checkout-custom-field', 'security' );
159
+
160
+ $post_id = intval( $_POST['post_id'] );
161
+ $add_to = sanitize_text_field( wp_unslash( $_POST['add_to'] ) );
162
+ $type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
163
+ $options = sanitize_text_field( wp_unslash( $_POST['options'] ) );
164
+ $label = sanitize_text_field( wp_unslash( $_POST['label'] ) );
165
+ $name = sanitize_text_field( wp_unslash( $_POST['name'] ) );
166
+
167
+ if ( '' !== $name ) {
168
+
169
+ $fields = Cartflows_Helper::get_checkout_fields( $add_to, $post_id );
170
+ $field_keys = array_keys($fields);
171
+
172
+ $name = $add_to . '_' . sanitize_key( $name );
173
+ if( in_array($name, $field_keys) ) {
174
+ $name = $name . '_' . rand( 0000, 9999 );
175
+ }
176
+
177
+ $field_data = array(
178
+ 'type' => $type,
179
+ 'label' => $label,
180
+ 'placeholder' => '',
181
+ 'class' => array( 'form-row-wide' ),
182
+ 'label_class' => array(),
183
+ 'required' => true,
184
+ 'custom' => true,
185
+ );
186
+
187
+ if ( 'select' === $type ) {
188
+
189
+ $options = explode( ',', $options );
190
+ $field_data['options'] = array();
191
+
192
+ if ( is_array( $options ) && ! empty( $options ) ) {
193
+
194
+ foreach ( $options as $key => $value ) {
195
+
196
+ $field_data['options'][ $value ] = $value;
197
+ }
198
+ }
199
+ }
200
+
201
+ Cartflows_Helper::add_checkout_field( $add_to, $name, $field_data, $post_id );
202
+
203
+ $key = sanitize_key( $name );
204
+ $name = 'wcf-' . $key;
205
+
206
+ $field_args = array(
207
+ 'label' => $label,
208
+ 'name' => $name,
209
+ 'value' => 'yes',
210
+ 'after' => 'Enable',
211
+ );
212
+
213
+ $field_args['after_html'] = '<span class="wcf-cpf-actions" data-type="billing" data-key="' . $key . '"> | ';
214
+ $field_args['after_html'] .= '<a class="wcf-cpf-action-remove">' . __( 'Remove', 'cartflows' ) . '</a>';
215
+ $field_args['after_html'] .= '</span>';
216
+
217
+ $field_markup = wcf()->meta->get_checkbox_field( $field_args );
218
+
219
+ if( 'billing' === $add_to ) {
220
+ $add_to_class = 'wcf-cb-fields';
221
+ } else if( 'shipping' === $add_to ) {
222
+ $add_to_class = 'wcf-sb-fields';
223
+ }
224
+
225
+ $data = array(
226
+ 'field_data' => $field_data,
227
+ 'field_args' => $field_args,
228
+ 'add_to_class' => $add_to_class,
229
+ 'markup' => $field_markup,
230
+ );
231
+
232
+ wp_send_json( $data );
233
+ }
234
+
235
+ wp_send_json( false );
236
+
237
+ }
238
+
239
+ /**
240
+ * [delete_checkout_custom_field description]
241
+ *
242
+ * @hook wcf_delete_checkout_custom_field
243
+ * @return [type] [description]
244
+ */
245
+ public function delete_checkout_custom_field() {
246
+
247
+ check_ajax_referer( 'wcf-delete-checkout-custom-field', 'security' );
248
+
249
+ $post_id = intval( $_POST['post_id'] );
250
+ $type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
251
+ $key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
252
+
253
+ if ( '' !== $key ) {
254
+
255
+ Cartflows_Helper::delete_checkout_field( $type, $key, $post_id );
256
+
257
+ wp_send_json( true );
258
+
259
+ }
260
+
261
+ wp_send_json( false );
262
+
263
+ }
264
+
265
+ /**
266
+ * Function to search coupons
267
+ */
268
+ public function json_search_pages() {
269
+
270
+ check_ajax_referer( 'wcf-json-search-pages', 'security' );
271
+
272
+ $term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
273
+
274
+ if ( empty( $term ) ) {
275
+ die( 'not found' );
276
+ }
277
+
278
+ $search_string = $term;
279
+ $data = array();
280
+ $result = array();
281
+
282
+ add_filter( 'posts_search', array( $this, 'search_only_titles' ), 10, 2 );
283
+
284
+ $query = new WP_Query(
285
+ array(
286
+ 's' => $search_string,
287
+ 'post_type' => 'page',
288
+ 'posts_per_page' => - 1,
289
+ )
290
+ );
291
+
292
+ if ( $query->have_posts() ) {
293
+ while ( $query->have_posts() ) {
294
+ $query->the_post();
295
+ $title = get_the_title();
296
+ $title .= ( 0 != $query->post->post_parent ) ? ' (' . get_the_title( $query->post->post_parent ) . ')' : '';
297
+ $id = get_the_id();
298
+ $data[] = array(
299
+ 'id' => $id,
300
+ 'text' => $title,
301
+ );
302
+ }
303
+ }
304
+
305
+ if ( is_array( $data ) && ! empty( $data ) ) {
306
+ $result[] = array(
307
+ 'text' => '',
308
+ 'children' => $data,
309
+ );
310
+ }
311
+
312
+ wp_reset_postdata();
313
+
314
+ // return the result in json.
315
+ wp_send_json( $result );
316
+ }
317
+
318
+ public function search_only_titles( $search, $wp_query ) {
319
+ if ( ! empty( $search ) && ! empty( $wp_query->query_vars['search_terms'] ) ) {
320
+ global $wpdb;
321
+
322
+ $q = $wp_query->query_vars;
323
+ $n = ! empty( $q['exact'] ) ? '' : '%';
324
+
325
+ $search = array();
326
+
327
+ foreach ( (array) $q['search_terms'] as $term ) {
328
+ $search[] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like( $term ) . $n );
329
+ }
330
+
331
+ if ( ! is_user_logged_in() ) {
332
+ $search[] = "$wpdb->posts.post_password = ''";
333
+ }
334
+
335
+ $search = ' AND ' . implode( ' AND ', $search );
336
+ }
337
+
338
+ return $search;
339
+ }
340
+
341
+ function get_field( $field_data, $field_content ) {
342
+
343
+ $label = isset( $field_data['label'] ) ? $field_data['label'] : '';
344
+ $help = isset( $field_data['help'] ) ? $field_data['help'] : '';
345
+ $after_html = isset( $field_data['after_html'] ) ? $field_data['after_html'] : '';
346
+
347
+ $name_class = 'field-' . $field_data['name'];
348
+
349
+ $field_html = '<div class="wcf-field-row ' . $name_class . '">';
350
+
351
+ if( ! empty( $label ) || ! empty( $help ) ) {
352
+ $field_html .= '<div class="wcf-field-row-heading">';
353
+ if( ! empty( $label ) ) {
354
+ $field_html .= '<label>' . esc_html( $label ) . '</label>';
355
+ }
356
+ if ( ! empty( $help ) ) {
357
+ $field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help">';
358
+ // $field_html .= '<span class="wcf-tooltip" data-tooltip= "'. esc_attr( $help ) .'"></span>';
359
+ $field_html .= '</i>';
360
+ $field_html .= '<span class="wcf-tooltip-text">';
361
+ $field_html .= $help;
362
+ $field_html .= '</span>';
363
+ }
364
+ $field_html .= '</div>';
365
+ }
366
+
367
+ $field_html .= '<div class="wcf-field-row-content">';
368
+ $field_html .= $field_content;
369
+
370
+ if ( ! empty( $after_html ) ) {
371
+ $field_html .= $after_html;
372
+ }
373
+
374
+ $field_html .= '</div>';
375
+ $field_html .= '</div>';
376
+
377
+ return $field_html;
378
+ }
379
+
380
+ function get_text_field( $field_data ) {
381
+
382
+ $value = $field_data['value'];
383
+
384
+ $attr = '';
385
+
386
+ if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
387
+
388
+ foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
389
+ $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
390
+ }
391
+ }
392
+
393
+ $field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
394
+
395
+ return $this->get_field( $field_data, $field_content );
396
+ }
397
+
398
+ function get_shortcode_field( $field_data ) {
399
+
400
+ $attr = '';
401
+
402
+ $attr_fields = array(
403
+ 'readonly' => 'readonly',
404
+ 'onfocus' => 'this.select()',
405
+ 'onmouseup' => 'return false',
406
+ );
407
+
408
+ if ( $attr_fields && is_array( $attr_fields ) ) {
409
+
410
+ foreach ( $attr_fields as $attr_key => $attr_value ) {
411
+ $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
412
+ }
413
+ }
414
+
415
+ $field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $field_data['content'] . '" ' . $attr . '>';
416
+
417
+ return $this->get_field( $field_data, $field_content );
418
+ }
419
+
420
+ function get_display_field( $field_data ) {
421
+
422
+ $field_content = $field_data['content'];
423
+
424
+ return $this->get_field( $field_data, $field_content );
425
+ }
426
+
427
+ function get_number_field( $field_data ) {
428
+
429
+ $value = $field_data['value'];
430
+
431
+ $attr = '';
432
+
433
+ if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
434
+
435
+ foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
436
+ $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
437
+ }
438
+ }
439
+
440
+ $field_content = '<input type="number" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
441
+
442
+ return $this->get_field( $field_data, $field_content );
443
+ }
444
+
445
+ function get_hidden_field( $field_data ) {
446
+
447
+ $value = $field_data['value'];
448
+
449
+ $attr = '';
450
+
451
+ if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
452
+
453
+ foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
454
+ $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
455
+ }
456
+ }
457
+
458
+ $field_content = '<input type="hidden" id="' . $field_data['name'] . '" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
459
+
460
+ return $this->get_field( $field_data, $field_content );
461
+ }
462
+
463
+ function get_area_field( $field_data ) {
464
+
465
+ $value = $field_data['value'];
466
+
467
+ $field_content = '<textarea name="' . $field_data['name'] . '" rows="10" cols="50">';
468
+ $field_content .= $value;
469
+ $field_content .= '</textarea>';
470
+
471
+ return $this->get_field( $field_data, $field_content );
472
+ }
473
+
474
+ function get_checkbox_field( $field_data ) {
475
+
476
+ $value = $field_data['value'];
477
+
478
+ $field_content = '';
479
+ if ( isset( $field_data['before'] ) ) {
480
+ $field_content .= '<span>' . $field_data['before'] . '</span>';
481
+ }
482
+ $field_content .= '<input type="hidden" name="' . $field_data['name'] . '" value="no">';
483
+ $field_content .= '<input type="checkbox" name="' . $field_data['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
484
+
485
+ if ( isset( $field_data['after'] ) ) {
486
+ $field_content .= '<span>' . $field_data['after'] . '</span>';
487
+ }
488
+
489
+ return $this->get_field( $field_data, $field_content );
490
+ }
491
+
492
+ function get_font_family_field( $field_data ) {
493
+
494
+ $value = $field_data['value'];
495
+
496
+ $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
497
+
498
+ $field_content = '<select class="wcf-field-font-family" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
499
+
500
+ $field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
501
+
502
+ $field_content .= '<optgroup label="Other System Fonts">';
503
+ foreach ( CartFlows_Font_Families::get_system_fonts() as $name => $variants ) {
504
+ $field_content .= '<option value="' . esc_attr( $name ) . '" ' . selected( $name, $value, false ) . '>' . esc_attr( $name ) . '</option>';
505
+ }
506
+ $field_content .= '</optgroup>';
507
+ $field_content .= '<optgroup label="Google">';
508
+ foreach ( CartFlows_Font_Families::get_google_fonts() as $name => $single_font ) {
509
+ $variants = wcf_get_prop( $single_font, '0' );
510
+ $category = wcf_get_prop( $single_font, '1' );
511
+ $font_value = '\'' . esc_attr( $name ) . '\', ' . esc_attr( $category );
512
+ $field_content .= '<option value="' . esc_attr( $font_value ) . '" ' . selected( $font_value, $value, false ) . '>' . esc_attr( $name ) . '</option>';
513
+ }
514
+ $field_content .= '</optgroup>';
515
+
516
+ $field_content .= '</select>';
517
+
518
+ return $this->get_field( $field_data, $field_content );
519
+ }
520
+
521
+ function get_font_weight_field( $field_data ) {
522
+
523
+ $value = $field_data['value'];
524
+
525
+ $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
526
+
527
+ $field_content = '<select data-selected="'.esc_attr( $value ).'" class="wcf-field-font-weight" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
528
+
529
+ $field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
530
+
531
+ $field_content .= '</select>';
532
+
533
+ return $this->get_field( $field_data, $field_content );
534
+ }
535
+
536
+ function get_select_field( $field_data ) {
537
+
538
+ $value = $field_data['value'];
539
+ $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
540
+
541
+ $field_content = '<select name="' . $field_data['name'] . '">';
542
+
543
+
544
+ if ( is_array( $field_data['options'] ) && ! empty( $field_data['options'] ) ) {
545
+
546
+ foreach ( $field_data['options'] as $data_key => $data_value ) {
547
+
548
+ $disabled = '';
549
+
550
+ if ( array_key_exists( $data_key, $pro_options ) ) {
551
+ $disabled = 'disabled ';
552
+ $data_value = $pro_options[ $data_key ];
553
+ }
554
+
555
+ $field_content .= '<option value="' . $data_key . '" ' . selected( $value, $data_key, false ) . ' ' . $disabled .'>' . $data_value . '</option>';
556
+ }
557
+ }
558
+
559
+ $field_content .= '</select>';
560
+
561
+ if ( isset( $field_data['after'] ) ) {
562
+ $field_content .= '<span>' . $field_data['after'] . '</span>';
563
+ }
564
+
565
+ return $this->get_field( $field_data, $field_content );
566
+ }
567
+
568
+ function get_color_picker_field( $field_data ) {
569
+
570
+ $value = $field_data['value'];
571
+
572
+ $field_content = '<input class="wcf-color-picker" type="text" name="' . $field_data['name'] . '" value="' . $value . '">';
573
+
574
+ return $this->get_field( $field_data, $field_content );
575
+ }
576
+
577
+ function get_product_selection_field( $field_data ) {
578
+
579
+ $value = $field_data['value'];
580
+
581
+ $multiple = '';
582
+
583
+ if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
584
+ $multiple = ' multiple="multiple"';
585
+ }
586
+
587
+ $allow_clear = '';
588
+
589
+ if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
590
+ $allow_clear = ' data-allow_clear="allow_clear"';
591
+ }
592
+
593
+ $field_content = '<select
594
+ name="' . $field_data['name'] . '[]"
595
+ class="wcf-product-search" ' . $multiple . $allow_clear . '
596
+ data-placeholder="' . __( 'Search for a product&hellip;', 'cartflows' ) . '"
597
+ data-action="woocommerce_json_search_products_and_variations">';
598
+
599
+ if ( is_array( $value ) && ! empty( $value ) ) {
600
+
601
+ foreach ( $value as $data_key => $product_id ) {
602
+
603
+ $product = wc_get_product( $product_id );
604
+
605
+ // posts.
606
+ if ( ! empty( $product ) ) {
607
+ $post_title = $product->get_name() . ' (#' . $product_id . ')';
608
+
609
+ $field_content .= '<option value="' . $product_id . '" selected="selected" >' . $post_title . '</option>';
610
+ }
611
+ }
612
+ }
613
+ $field_content .= '</select>';
614
+
615
+ return $this->get_field( $field_data, $field_content );
616
+ }
617
+
618
+ function get_coupon_selection_field( $field_data ) {
619
+
620
+ $value = $field_data['value'];
621
+
622
+ $multiple = '';
623
+
624
+ if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
625
+ $multiple = ' multiple="multiple"';
626
+ }
627
+
628
+ $allow_clear = '';
629
+
630
+ if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
631
+ $allow_clear = ' data-allow_clear="allow_clear"';
632
+ }
633
+
634
+ $field_content = '<select
635
+ name="' . $field_data['name'] . '[]"
636
+ class="wc-coupon-search wcf-coupon-search" ' . $multiple . $allow_clear . '
637
+ data-placeholder="' . __( 'Search for a coupon&hellip;', 'cartflows' ) . '"
638
+ data-action="wcf_json_search_coupons">';
639
+
640
+ if ( is_array( $value ) && ! empty( $value ) ) {
641
+
642
+ $all_discount_types = wc_get_coupon_types();
643
+
644
+ foreach ( $value as $coupon_title ) {
645
+
646
+ $coupon = new WC_Coupon( $coupon_title );
647
+
648
+ $discount_type = $coupon->get_discount_type();
649
+
650
+ if ( isset( $discount_type ) && $discount_type ) {
651
+ $discount_type = ' ( Type: ' . $all_discount_types[ $discount_type ] . ' )';
652
+ }
653
+
654
+ $field_content .= '<option value="' . $coupon_title . '" selected="selected">' . $coupon_title . $discount_type . '</option>';
655
+ }
656
+ }
657
+
658
+ $field_content .= '</select>';
659
+
660
+ return $this->get_field( $field_data, $field_content );
661
+ }
662
+
663
+ function get_page_selection_field( $field_data ) {
664
+
665
+ $value = $field_data['value'];
666
+
667
+ $multiple = '';
668
+
669
+ if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
670
+ $multiple = 'multiple="multiple"';
671
+ }
672
+
673
+ $field_content = '<select
674
+ name="' . $field_data['name'] . '[]"
675
+ class="wcf-search-pages" ' . $multiple . '"
676
+ data-action="wcf_json_search_pages">';
677
+
678
+ if ( is_array( $value ) && ! empty( $value ) ) {
679
+
680
+ foreach ( $value as $data_key => $data_value ) {
681
+
682
+ $field_content .= '<option value="' . $data_value . '">' . get_the_title( $data_value ) . '</option>';
683
+ }
684
+ }
685
+
686
+ $field_content .= '</select>';
687
+
688
+ return $this->get_field( $field_data, $field_content );
689
+ }
690
+
691
+ function get_section( $field_data ) {
692
+ $field_html = '<div class="wcf-field-row wcf-field-section">';
693
+ $field_html .= '<div class="wcf-field-section-heading" colspan="2">';
694
+ $field_html .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
695
+
696
+ if ( isset( $field_data['help'] ) ) {
697
+ $field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help" title="' . esc_attr( $field_data['help'] ) . '"></i>';
698
+ }
699
+ $field_html .= '</div>';
700
+ $field_html .= '</div>';
701
+ return $field_html;
702
+ }
703
+
704
+ function get_description_field( $field_data ) {
705
+
706
+ $field_html = '<div class="wcf-field-row wcf-field-desc ' . $field_data['name'] . '">';
707
+ $field_html .= '<div class="wcf-field-desc-content">';
708
+ $field_html .= $field_data['content'];
709
+ $field_html .= '</div>';
710
+ $field_html .= '</div>';
711
+
712
+ return $field_html;
713
+ }
714
+
715
+ function get_checkout_field_repeater( $field_data ) {
716
+
717
+ $value = array();
718
+
719
+ $value[0] = array(
720
+ 'add_to' => '',
721
+ 'type' => '',
722
+ 'label' => '',
723
+ 'name' => '',
724
+ );
725
+
726
+ $field_content = '';
727
+
728
+ $field_content .= '<div class="wcf-field-row">';
729
+ // $field_content .= '<div class="wcf-field-row-heading">';
730
+ // $field_content .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
731
+ // $field_content .= '</div>';
732
+ $field_content .= '<div class="wcf-field-row-content">';
733
+ $field_content .= '<div class="wcf-cpf-wrap">';
734
+
735
+ foreach ( $value as $p_key => $p_data ) {
736
+ $field_content .= '<div class="wcf-cpf-row" data-key="' . $p_key . '">';
737
+ $field_content .= '<div class="wcf-cpf-row-header">';
738
+ $field_content .= '<span class="wcf-cpf-row-title">Add New Custom Field</span>';
739
+ $field_content .= '</div>';
740
+
741
+ $field_content .= '<div class="wcf-cpf-row-standard-fields">';
742
+
743
+ /* Add To */
744
+ $field_content .= '<div class="wcf-cpf-fields wcf-cpf-add_to">';
745
+ $field_content .= '<span class="wcf-cpf-row-setting-label">Add to</span>';
746
+ $field_content .= '<span class="wcf-cpf-row-setting-field">';
747
+ $field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][add_to]" class="wcf-cpf-add_to">';
748
+ $field_content .= '<option value="billing">Billing</option>';
749
+ $field_content .= '<option value="shipping">Shipping</option>';
750
+ $field_content .= '</select>';
751
+ $field_content .= '</span>';
752
+ $field_content .= '</div>';
753
+
754
+ /* Type */
755
+ $field_content .= '<div class="wcf-cpf-fields wcf-cpf-type">';
756
+ $field_content .= '<span class="wcf-cpf-row-setting-label">Type</span>';
757
+ $field_content .= '<span class="wcf-cpf-row-setting-field">';
758
+ $field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][type]" class="wcf-cpf-type">';
759
+ $field_content .= '<option value="text">Text</option>';
760
+ $field_content .= '<option value="textarea">Textarea</option>';
761
+ $field_content .= '<option value="select">Select</option>';
762
+ $field_content .= '<option value="checkbox">Checkbox</option>';
763
+ $field_content .= '</select>';
764
+ $field_content .= '</span>';
765
+ $field_content .= '</div>';
766
+
767
+ /* Textarea */
768
+ $field_content .= '<div class="wcf-cpf-fields wcf-cpf-options">';
769
+ $field_content .= '<span class="wcf-cpf-row-setting-label">Options *</span>';
770
+ $field_content .= '<span class="wcf-cpf-row-setting-field">';
771
+ $field_content .= '<textarea value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-options" placeholder="Enter your options separated by comma."></textarea>';
772
+ $field_content .= '</span>';
773
+ $field_content .= '</div>';
774
+
775
+ /* Label */
776
+ $field_content .= '<div class="wcf-cpf-fields wcf-cpf-label">';
777
+ $field_content .= '<span class="wcf-cpf-row-setting-label">Label *</span>';
778
+ $field_content .= '<span class="wcf-cpf-row-setting-field">';
779
+ $field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-label">';
780
+ $field_content .= '</span>';
781
+ $field_content .= '</div>';
782
+
783
+ /* Name */
784
+ $field_content .= '<div class="wcf-cpf-fields wcf-cpf-name">';
785
+ $field_content .= '<span class="wcf-cpf-row-setting-label">Name *</span>';
786
+ $field_content .= '<span class="wcf-cpf-row-setting-field">';
787
+ $field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][name]" class="wcf-cpf-name">';
788
+ $field_content .= '</span>';
789
+ $field_content .= '</div>';
790
+
791
+ $field_content .= '</div>';
792
+ $field_content .= '</div>';
793
+ }
794
+
795
+ /* Add New Custom Field */
796
+ $field_content .= '<div class="wcf-cpf-add-row">';
797
+ $field_content .= '<div class="wcf-cpf-add-wrap">';
798
+ $field_content .= '<button class="button button-secondary wcf-cpf-add" data-name="wcf-checkout-custom-fields">Add New Field</button>';
799
+ $field_content .= '</div>';
800
+ $field_content .= '</div>';
801
+ /* End Add new custom field */
802
+
803
+ $field_content .= '</div>';
804
+ $field_content .= '</div>';
805
+ $field_content .= '</div>';
806
+
807
+ return $field_content;
808
+ }
809
+
810
+ function get_product_selection_repeater( $field_data ) {
811
+
812
+ $value = $field_data['value'];
813
+
814
+ if ( ! is_array( $value ) ) {
815
+
816
+ $value[0] = array(
817
+ 'product' => '',
818
+ );
819
+ } else {
820
+
821
+ if ( ! isset( $value[0] ) ) {
822
+
823
+ $value[0] = array(
824
+ 'product' => '',
825
+ );
826
+ }
827
+ }
828
+
829
+ $field_html = '';
830
+
831
+ $field_html .= '<script type="text/html" id="tmpl-wcf-product-repeater">';
832
+ $field_html .= $this->generate_product_repeater_html( '{{id}}' );
833
+ $field_html .= '</script>';
834
+
835
+ $field_html .= '<div class="wcf-field-row">';
836
+ $field_html .= '<div class="wcf-field-row-content">';
837
+ $field_html .= '<div class="wcf-repeatables-wrap">';
838
+
839
+ if ( is_array( $value ) ) {
840
+
841
+ foreach ( $value as $p_key => $p_data ) {
842
+
843
+ $selected_options = '';
844
+
845
+ if ( isset( $p_data['product'] ) ) {
846
+
847
+ $product = wc_get_product( $p_data['product'] );
848
+
849
+ // posts.
850
+ if ( ! empty( $product ) ) {
851
+ $post_title = $product->get_name() . ' (#' . $p_data['product'] . ')';
852
+
853
+ $selected_options = '<option value="' . $p_data['product'] . '" selected="selected" >' . $post_title . '</option>';
854
+ }
855
+ }
856
+
857
+ $field_html .= $this->generate_product_repeater_html( $p_key, $selected_options );
858
+ }
859
+ }
860
+
861
+ $field_html .= '<div class="wcf-add-repeatable-row">';
862
+ $field_html .= '<div class="submit wcf-add-repeatable-wrap">';
863
+ $field_html .= '<button class="button-primary wcf-add-repeatable" data-name="wcf-checkout-products">Add New Product</button>';
864
+ $field_html .= '</div>';
865
+ $field_html .= '</div>';
866
+ $field_html .= '</div>';
867
+ $field_html .= '</div>';
868
+ $field_html .= '</div>';
869
+
870
+ $field_html .= '<div class="wcf-field-row wcf-repeat-notice">';
871
+ $field_html .= '<p><i>The selected products will be automatically added in the cart for this checkout.</i></p>';
872
+ $field_html .= '</div>';
873
+
874
+ return $field_html;
875
+ }
876
+
877
+ function generate_product_repeater_html( $id, $options = '' ) {
878
+
879
+ $field_html = '<div class="wcf-repeatable-row" data-key="' . $id . '">';
880
+
881
+ $field_html .= '<div class="wcf-repeatable-row-standard-fields">';
882
+
883
+ /* Product Name */
884
+ $field_html .= '<div class="wcf-repeatable-fields wcf-sel-product">';
885
+ $field_html .= '<span class="wcf-repeatable-row-setting-field">';
886
+ $field_html .= '<select
887
+ name="wcf-checkout-products[' . $id . '][product]"
888
+ class="wcf-product-search"
889
+ data-allow_clear="allow_clear"
890
+ data-placeholder="' . __( 'Search for a product&hellip;', 'cartflows' ) . '"
891
+ data-action="woocommerce_json_search_products_and_variations">';
892
+ $field_html .= $options;
893
+ $field_html .= '</select>';
894
+ $field_html .= '</span>';
895
+ $field_html .= '<span class="wcf-repeatable-row-actions">';
896
+ $field_html .= '<a class="wcf-remove-row wcf-repeatable-remove button" data-type="product">';
897
+ $field_html .= '<span class="dashicons dashicons-trash"></span>';
898
+ $field_html .= '<span class="wcf-repeatable-remove-button">'. __( 'Remove', 'cartflows' ).'</span>';
899
+ $field_html .= '</a>';
900
+ $field_html .= '</span>';
901
+ $field_html .= '</div>';
902
+ $field_html .= '</div>';
903
+ $field_html .= '</div>';
904
+
905
+ return $field_html;
906
+ }
907
+
908
+ function get_image_field( $field_data ) {
909
+
910
+ $value = $field_data['value'];
911
+
912
+ $attr = '';
913
+
914
+ if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
915
+
916
+ foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
917
+ $attr .= ' ' . $attr_key . '="' . $attr_value . '"';
918
+ }
919
+ }
920
+
921
+ $display_preview_box = ( isset( $value ) && '' != $value ) ? 'display:block;' : 'display:none';
922
+
923
+ $field_content = '<div id="wcf-image-preview" style="'.$display_preview_box.'">';
924
+ if( isset( $value ) ){
925
+ $field_content .= '<img src="'. $value .'" class="saved-image" name="'. $field_data['name'] .'" width="150">';
926
+ }
927
+ $field_content .= '</div>';
928
+ // $field_content .= '<input type="hidden" id="wcf-image-id" class="wcf-image-id" name="wcf-image-id[image-id]" value="">';
929
+ $field_content .= '<input type="hidden" id="wcf-image-value" class="wcf-image" name="' . $field_data['name'] . '" value="'.$value.'">';
930
+
931
+ $field_content .= '<button type="button" ' . $attr . ' class="wcf-select-image button-secondary">Select Image</button>';
932
+
933
+ $display_remove_button = ( isset( $value ) && '' != $value ) ? 'display:inline-block; margin-left: 5px;' : 'display:none';
934
+
935
+ $field_content .= '<button type="button" class="wcf-remove-image button-secondary" style="'.$display_remove_button.'">Remove Image</button>';
936
+
937
+ return $this->get_field( $field_data, $field_content );
938
+ }
939
+
940
+ /**
941
+ * Localize variables in admin
942
+ *
943
+ * @param array $vars variables.
944
+ */
945
+ function localize_vars( $vars ) {
946
+
947
+ $ajax_actions = array(
948
+ 'wcf_add_checkout_custom_field',
949
+ 'wcf_delete_checkout_custom_field',
950
+ 'wcf_json_search_pages',
951
+ 'wcf_json_search_coupons'
952
+ );
953
+
954
+ foreach ( $ajax_actions as $action ) {
955
+
956
+ $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
957
+ }
958
+
959
+ return $vars;
960
+ }
961
+ }
962
+ // @codingStandardsIgnoreEnd
languages/cartflows.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the CartFlows package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: CartFlows 1.0.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
- "POT-Creation-Date: 2018-11-23 07:25:22+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -44,10 +44,11 @@ msgstr ""
44
  msgid "No Checkout Steps"
45
  msgstr ""
46
 
47
- #: classes/class-cartflows-admin-fields.php:149
 
48
  msgid ""
49
- "Be sure not to add any products in the Global checkout page you select "
50
- "above."
51
  msgstr ""
52
 
53
  #: classes/class-cartflows-admin.php:106 classes/class-cartflows-admin.php:107
@@ -60,27 +61,27 @@ msgid "Flows Library"
60
  msgstr ""
61
 
62
  #: classes/class-cartflows-admin.php:306 classes/class-cartflows-wizard.php:273
63
- #: modules/flow/view/meta-flow-steps.php:120
64
  msgid "Elementor"
65
  msgstr ""
66
 
67
  #: classes/class-cartflows-admin.php:307
68
- #: modules/flow/view/meta-flow-steps.php:121
69
  msgid "Divi"
70
  msgstr ""
71
 
72
  #: classes/class-cartflows-admin.php:308
73
- #: modules/flow/view/meta-flow-steps.php:122
74
  msgid "Beaver Builder"
75
  msgstr ""
76
 
77
  #: classes/class-cartflows-admin.php:320
78
- #: modules/flow/view/meta-flow-steps.php:132
79
  msgid "Search Sites"
80
  msgstr ""
81
 
82
  #: classes/class-cartflows-admin.php:321
83
- #: modules/flow/view/meta-flow-steps.php:133
84
  msgid "Search Flow..."
85
  msgstr ""
86
 
@@ -152,85 +153,92 @@ msgstr ""
152
  msgid "Redirecting to the Elementor edit window."
153
  msgstr ""
154
 
155
- #: classes/class-cartflows-importer.php:185
156
- msgid "Import"
157
  msgstr ""
158
 
159
  #: classes/class-cartflows-importer.php:195
 
 
 
 
 
 
 
 
160
  msgid "Activate Elementor & Import"
161
  msgstr ""
162
 
163
- #: classes/class-cartflows-importer.php:197
164
  msgid "Install Elementor & Import"
165
  msgstr ""
166
 
167
- #: classes/class-cartflows-importer.php:241
168
- #: classes/class-cartflows-importer.php:309
169
  msgid "Pro"
170
  msgstr ""
171
 
172
- #: classes/class-cartflows-importer.php:251
173
- #: classes/class-cartflows-importer.php:318
174
  msgid "Activate License"
175
  msgstr ""
176
 
177
- #: classes/class-cartflows-importer.php:253
178
- #: classes/class-cartflows-importer.php:279
179
- #: classes/class-cartflows-importer.php:320
180
  msgid "Get Pro"
181
  msgstr ""
182
 
183
- #: classes/class-cartflows-importer.php:281
184
  msgid "Create"
185
  msgstr ""
186
 
187
- #: classes/class-cartflows-importer.php:378
188
  msgid "Import from Cloud"
189
  msgstr ""
190
 
191
- #: classes/class-cartflows-importer.php:636
192
  #: modules/flow/classes/class-cartflows-flow-meta.php:224
193
  msgid "Landing Page"
194
  msgstr ""
195
 
196
- #: classes/class-cartflows-importer.php:637
197
  #: modules/flow/classes/class-cartflows-flow-meta.php:225
198
  msgid "Checkout Page"
199
  msgstr ""
200
 
201
- #: classes/class-cartflows-importer.php:638
202
  #: modules/flow/classes/class-cartflows-flow-meta.php:226
203
  msgid "Thank You Page"
204
  msgstr ""
205
 
206
- #: classes/class-cartflows-importer.php:743
207
  #. translators: %s: template ID
208
  msgid "Invalid template id %1$s or post id %2$s."
209
  msgstr ""
210
 
211
- #: classes/class-cartflows-importer.php:787
212
  #. translators: %s: flow ID
213
  msgid "Invalid flow id %1$s or step type %2$s."
214
  msgstr ""
215
 
216
- #: classes/class-cartflows-importer.php:907
217
  msgid ""
218
  "Elementor is not activated. Please activate plugin Elementor Page Builder "
219
  "to import the step."
220
  msgstr ""
221
 
222
- #: classes/class-cartflows-loader.php:334
223
  #. translators: %s: html tags
224
  msgid ""
225
  "The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed "
226
  "& activated."
227
  msgstr ""
228
 
229
- #: classes/class-cartflows-loader.php:344
230
  msgid "Activate WooCommerce"
231
  msgstr ""
232
 
233
- #: classes/class-cartflows-loader.php:352
234
  msgid "Install WooCommerce"
235
  msgstr ""
236
 
@@ -270,17 +278,17 @@ msgstr ""
270
  msgid "Ultra-Bold 900"
271
  msgstr ""
272
 
273
- #: classes/class-cartflows-meta-fields.php:200
274
- #: classes/class-cartflows-meta-fields.php:876
275
  msgid "Remove"
276
  msgstr ""
277
 
278
- #: classes/class-cartflows-meta-fields.php:582
279
- #: classes/class-cartflows-meta-fields.php:868
280
  msgid "Search for a product&hellip;"
281
  msgstr ""
282
 
283
- #: classes/class-cartflows-meta-fields.php:623
284
  msgid "Search for a coupon&hellip;"
285
  msgstr ""
286
 
@@ -402,6 +410,7 @@ msgid "Disallow search engines from indexing flows"
402
  msgstr ""
403
 
404
  #: includes/admin/cartflows-general.php:58
 
405
  msgid "Global Checkout"
406
  msgstr ""
407
 
@@ -459,6 +468,14 @@ msgstr ""
459
  msgid "This product can't be purcahsed"
460
  msgstr ""
461
 
 
 
 
 
 
 
 
 
462
  #: modules/checkout/classes/class-cartflows-checkout-meta.php:68
463
  msgid "Checkout Layout"
464
  msgstr ""
@@ -493,179 +510,181 @@ msgstr ""
493
  msgid "Add this shortcode to your checkout page"
494
  msgstr ""
495
 
496
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:290
497
- msgid "Upgrade to <a href=\"#\">CartFlows Pro</a> for Order Bump feature"
 
498
  msgstr ""
499
 
500
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:317
501
- msgid "Upgrade to <a href=\"#\">CartFlows Pro</a> for Custom Fields feature"
 
502
  msgstr ""
503
 
504
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:345
505
  msgid "One Column (Available in CartFlows Pro) "
506
  msgstr ""
507
 
508
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:351
509
  msgid "Checkout Skin"
510
  msgstr ""
511
 
512
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:355
513
  msgid "One Column"
514
  msgstr ""
515
 
516
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:356
517
  msgid "Two Column"
518
  msgstr ""
519
 
520
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:365
521
  msgid "Primary Color"
522
  msgstr ""
523
 
524
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:374
525
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:409
526
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:455
527
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:547
528
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:197
529
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:220
530
  msgid "Font Family"
531
  msgstr ""
532
 
533
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:382
534
  msgid "Advance Options"
535
  msgstr ""
536
 
537
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:394
538
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:205
539
  msgid "Heading"
540
  msgstr ""
541
 
542
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:400
543
  msgid "Heading Color"
544
  msgstr ""
545
 
546
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:418
547
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:464
548
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:556
549
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:229
550
  msgid "Font Weight"
551
  msgstr ""
552
 
553
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:426
554
  msgid "Input Fields"
555
  msgstr ""
556
 
557
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:434
558
- msgid "Style 1 (Available in CartFlows Pro)"
559
  msgstr ""
560
 
561
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:440
562
  msgid "Style"
563
  msgstr ""
564
 
565
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:444
566
  msgid "Default"
567
  msgstr ""
568
 
569
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:445
570
- msgid "Style 1"
571
  msgstr ""
572
 
573
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:472
574
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:564
575
  msgid "Size"
576
  msgstr ""
577
 
578
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:476
579
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:568
580
  msgid "Extra Small"
581
  msgstr ""
582
 
583
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:477
584
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:569
585
  msgid "Small"
586
  msgstr ""
587
 
588
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:478
589
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:570
590
  msgid "Medium"
591
  msgstr ""
592
 
593
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:479
594
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:571
595
  msgid "Large"
596
  msgstr ""
597
 
598
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:480
599
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:572
600
  msgid "Extra Large"
601
  msgstr ""
602
 
603
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:481
604
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:573
605
  msgid "Custom"
606
  msgstr ""
607
 
608
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:488
609
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:580
610
  msgid "Top Bottom Spacing"
611
  msgstr ""
612
 
613
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:496
614
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:588
615
  msgid "Left Right Spacing"
616
  msgstr ""
617
 
618
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:504
619
  msgid "Text / Placeholder Color"
620
  msgstr ""
621
 
622
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:512
623
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:612
624
  msgid "Background Color"
625
  msgstr ""
626
 
627
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:520
628
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:628
629
  msgid "Border Color"
630
  msgstr ""
631
 
632
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:527
633
  msgid "Label Color"
634
  msgstr ""
635
 
636
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:540
637
  msgid "Buttons"
638
  msgstr ""
639
 
640
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:596
641
  msgid "Text Color"
642
  msgstr ""
643
 
644
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:604
645
  msgid "Text Hover Color"
646
  msgstr ""
647
 
648
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:620
649
  msgid "Background Hover Color"
650
  msgstr ""
651
 
652
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:636
653
  msgid "Border Hover Color"
654
  msgstr ""
655
 
656
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:649
657
  msgid "Sections"
658
  msgstr ""
659
 
660
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:655
661
  msgid "Highlight Area Background Color"
662
  msgstr ""
663
 
664
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:694
665
  msgid "Header Logo"
666
  msgstr ""
667
 
668
- #: modules/checkout/classes/class-cartflows-checkout-meta.php:702
669
  msgid "Logo Width (In px)"
670
  msgstr ""
671
 
@@ -772,57 +791,57 @@ msgstr ""
772
 
773
  #: modules/flow/classes/class-cartflows-flow-post-type.php:252
774
  #: modules/flow/classes/class-cartflows-flow-post-type.php:258
775
- #: modules/flow/classes/class-cartflows-step-post-type.php:371
776
- #: modules/flow/classes/class-cartflows-step-post-type.php:377
777
  #. translators: %s: singular custom post type name
778
  msgid "%s updated."
779
  msgstr ""
780
 
781
  #: modules/flow/classes/class-cartflows-flow-post-type.php:254
782
- #: modules/flow/classes/class-cartflows-step-post-type.php:373
783
  #. translators: %s: singular custom post type name
784
  msgid "Custom %s updated."
785
  msgstr ""
786
 
787
  #: modules/flow/classes/class-cartflows-flow-post-type.php:256
788
- #: modules/flow/classes/class-cartflows-step-post-type.php:375
789
  #. translators: %s: singular custom post type name
790
  msgid "Custom %s deleted."
791
  msgstr ""
792
 
793
  #: modules/flow/classes/class-cartflows-flow-post-type.php:260
794
- #: modules/flow/classes/class-cartflows-step-post-type.php:379
795
  #. translators: %1$s: singular custom post type name ,%2$s: date and time of
796
  #. the revision
797
  msgid "%1$s restored to revision from %2$s"
798
  msgstr ""
799
 
800
  #: modules/flow/classes/class-cartflows-flow-post-type.php:262
801
- #: modules/flow/classes/class-cartflows-step-post-type.php:381
802
  #. translators: %s: singular custom post type name
803
  msgid "%s published."
804
  msgstr ""
805
 
806
  #: modules/flow/classes/class-cartflows-flow-post-type.php:264
807
- #: modules/flow/classes/class-cartflows-step-post-type.php:383
808
  #. translators: %s: singular custom post type name
809
  msgid "%s saved."
810
  msgstr ""
811
 
812
  #: modules/flow/classes/class-cartflows-flow-post-type.php:266
813
- #: modules/flow/classes/class-cartflows-step-post-type.php:385
814
  #. translators: %s: singular custom post type name
815
  msgid "%s submitted."
816
  msgstr ""
817
 
818
  #: modules/flow/classes/class-cartflows-flow-post-type.php:268
819
- #: modules/flow/classes/class-cartflows-step-post-type.php:387
820
  #. translators: %s: singular custom post type name
821
  msgid "%s scheduled for."
822
  msgstr ""
823
 
824
  #: modules/flow/classes/class-cartflows-flow-post-type.php:270
825
- #: modules/flow/classes/class-cartflows-step-post-type.php:389
826
  #. translators: %s: singular custom post type name
827
  msgid "%s draft updated."
828
  msgstr ""
@@ -841,12 +860,12 @@ msgid "All Steps"
841
  msgstr ""
842
 
843
  #: modules/flow/classes/class-cartflows-step-post-type.php:141
844
- #: modules/flow/view/meta-flow-steps.php:76
845
  msgid "Edit Step"
846
  msgstr ""
847
 
848
  #: modules/flow/classes/class-cartflows-step-post-type.php:142
849
- #: modules/flow/view/meta-flow-steps.php:72
850
  msgid "View Step"
851
  msgstr ""
852
 
@@ -891,27 +910,31 @@ msgstr ""
891
  msgid "Downsell"
892
  msgstr ""
893
 
894
- #: modules/flow/view/meta-flow-steps.php:64
895
  msgid "No Product Assigned"
896
  msgstr ""
897
 
898
- #: modules/flow/view/meta-flow-steps.php:80
 
 
 
 
899
  msgid "Clone Step"
900
  msgstr ""
901
 
902
- #: modules/flow/view/meta-flow-steps.php:84
903
  msgid "Delete Step"
904
  msgstr ""
905
 
906
- #: modules/flow/view/meta-flow-steps.php:99
907
  msgid "Add New Step"
908
  msgstr ""
909
 
910
- #: modules/flow/view/meta-flow-steps.php:115
911
  msgid "Templates"
912
  msgstr ""
913
 
914
- #: modules/flow/view/meta-flow-steps.php:136
915
  msgid "You need a Cartflows Pro version to import Upsell / Downsell"
916
  msgstr ""
917
 
@@ -923,7 +946,7 @@ msgstr ""
923
  msgid "Next Step Link"
924
  msgstr ""
925
 
926
- #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:59
927
  msgid ""
928
  "WooCommerce functions not exists. If you are in iframe, please reload the "
929
  "iframe"
2
  # This file is distributed under the same license as the CartFlows package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: CartFlows 1.1.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
+ "POT-Creation-Date: 2018-12-05 10:58:39+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
44
  msgid "No Checkout Steps"
45
  msgstr ""
46
 
47
+ #: classes/class-cartflows-admin-fields.php:150
48
+ #. translators: %s: link
49
  msgid ""
50
+ "Be sure not to add any product in above selected Global Checkout step. "
51
+ "Please read information about how to set up Global Checkout %1$shere%2$s."
52
  msgstr ""
53
 
54
  #: classes/class-cartflows-admin.php:106 classes/class-cartflows-admin.php:107
61
  msgstr ""
62
 
63
  #: classes/class-cartflows-admin.php:306 classes/class-cartflows-wizard.php:273
64
+ #: modules/flow/view/meta-flow-steps.php:141
65
  msgid "Elementor"
66
  msgstr ""
67
 
68
  #: classes/class-cartflows-admin.php:307
69
+ #: modules/flow/view/meta-flow-steps.php:142
70
  msgid "Divi"
71
  msgstr ""
72
 
73
  #: classes/class-cartflows-admin.php:308
74
+ #: modules/flow/view/meta-flow-steps.php:143
75
  msgid "Beaver Builder"
76
  msgstr ""
77
 
78
  #: classes/class-cartflows-admin.php:320
79
+ #: modules/flow/view/meta-flow-steps.php:153
80
  msgid "Search Sites"
81
  msgstr ""
82
 
83
  #: classes/class-cartflows-admin.php:321
84
+ #: modules/flow/view/meta-flow-steps.php:154
85
  msgid "Search Flow..."
86
  msgstr ""
87
 
153
  msgid "Redirecting to the Elementor edit window."
154
  msgstr ""
155
 
156
+ #: classes/class-cartflows-importer.php:193
157
+ msgid "Canvas"
158
  msgstr ""
159
 
160
  #: classes/class-cartflows-importer.php:195
161
+ msgid "Create Flow"
162
+ msgstr ""
163
+
164
+ #: classes/class-cartflows-importer.php:206
165
+ msgid "Import"
166
+ msgstr ""
167
+
168
+ #: classes/class-cartflows-importer.php:216
169
  msgid "Activate Elementor & Import"
170
  msgstr ""
171
 
172
+ #: classes/class-cartflows-importer.php:218
173
  msgid "Install Elementor & Import"
174
  msgstr ""
175
 
176
+ #: classes/class-cartflows-importer.php:246
177
+ #: classes/class-cartflows-importer.php:317
178
  msgid "Pro"
179
  msgstr ""
180
 
181
+ #: classes/class-cartflows-importer.php:256
182
+ #: classes/class-cartflows-importer.php:326
183
  msgid "Activate License"
184
  msgstr ""
185
 
186
+ #: classes/class-cartflows-importer.php:258
187
+ #: classes/class-cartflows-importer.php:328
 
188
  msgid "Get Pro"
189
  msgstr ""
190
 
191
+ #: classes/class-cartflows-importer.php:283
192
  msgid "Create"
193
  msgstr ""
194
 
195
+ #: classes/class-cartflows-importer.php:386
196
  msgid "Import from Cloud"
197
  msgstr ""
198
 
199
+ #: classes/class-cartflows-importer.php:645
200
  #: modules/flow/classes/class-cartflows-flow-meta.php:224
201
  msgid "Landing Page"
202
  msgstr ""
203
 
204
+ #: classes/class-cartflows-importer.php:646
205
  #: modules/flow/classes/class-cartflows-flow-meta.php:225
206
  msgid "Checkout Page"
207
  msgstr ""
208
 
209
+ #: classes/class-cartflows-importer.php:647
210
  #: modules/flow/classes/class-cartflows-flow-meta.php:226
211
  msgid "Thank You Page"
212
  msgstr ""
213
 
214
+ #: classes/class-cartflows-importer.php:752
215
  #. translators: %s: template ID
216
  msgid "Invalid template id %1$s or post id %2$s."
217
  msgstr ""
218
 
219
+ #: classes/class-cartflows-importer.php:796
220
  #. translators: %s: flow ID
221
  msgid "Invalid flow id %1$s or step type %2$s."
222
  msgstr ""
223
 
224
+ #: classes/class-cartflows-importer.php:916
225
  msgid ""
226
  "Elementor is not activated. Please activate plugin Elementor Page Builder "
227
  "to import the step."
228
  msgstr ""
229
 
230
+ #: classes/class-cartflows-loader.php:329
231
  #. translators: %s: html tags
232
  msgid ""
233
  "The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed "
234
  "& activated."
235
  msgstr ""
236
 
237
+ #: classes/class-cartflows-loader.php:339
238
  msgid "Activate WooCommerce"
239
  msgstr ""
240
 
241
+ #: classes/class-cartflows-loader.php:347
242
  msgid "Install WooCommerce"
243
  msgstr ""
244
 
278
  msgid "Ultra-Bold 900"
279
  msgstr ""
280
 
281
+ #: classes/class-cartflows-meta-fields.php:214
282
+ #: classes/class-cartflows-meta-fields.php:898
283
  msgid "Remove"
284
  msgstr ""
285
 
286
+ #: classes/class-cartflows-meta-fields.php:596
287
+ #: classes/class-cartflows-meta-fields.php:890
288
  msgid "Search for a product&hellip;"
289
  msgstr ""
290
 
291
+ #: classes/class-cartflows-meta-fields.php:637
292
  msgid "Search for a coupon&hellip;"
293
  msgstr ""
294
 
410
  msgstr ""
411
 
412
  #: includes/admin/cartflows-general.php:58
413
+ #: modules/flow/view/meta-flow-steps.php:85
414
  msgid "Global Checkout"
415
  msgstr ""
416
 
468
  msgid "This product can't be purcahsed"
469
  msgstr ""
470
 
471
+ #: modules/checkout/classes/class-cartflows-checkout-markup.php:858
472
+ msgid "Coupon Code"
473
+ msgstr ""
474
+
475
+ #: modules/checkout/classes/class-cartflows-checkout-markup.php:863
476
+ msgid "Apply"
477
+ msgstr ""
478
+
479
  #: modules/checkout/classes/class-cartflows-checkout-meta.php:68
480
  msgid "Checkout Layout"
481
  msgstr ""
510
  msgid "Add this shortcode to your checkout page"
511
  msgstr ""
512
 
513
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:291
514
+ #. translators: %s: link
515
+ msgid "Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature"
516
  msgstr ""
517
 
518
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:319
519
+ #. translators: %s: link
520
+ msgid "Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature"
521
  msgstr ""
522
 
523
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:347
524
  msgid "One Column (Available in CartFlows Pro) "
525
  msgstr ""
526
 
527
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:353
528
  msgid "Checkout Skin"
529
  msgstr ""
530
 
531
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:357
532
  msgid "One Column"
533
  msgstr ""
534
 
535
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:358
536
  msgid "Two Column"
537
  msgstr ""
538
 
539
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:367
540
  msgid "Primary Color"
541
  msgstr ""
542
 
543
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:376
544
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:411
545
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:457
546
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:549
547
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:197
548
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:220
549
  msgid "Font Family"
550
  msgstr ""
551
 
552
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:384
553
  msgid "Advance Options"
554
  msgstr ""
555
 
556
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:396
557
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:205
558
  msgid "Heading"
559
  msgstr ""
560
 
561
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:402
562
  msgid "Heading Color"
563
  msgstr ""
564
 
565
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:420
566
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:466
567
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:558
568
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:229
569
  msgid "Font Weight"
570
  msgstr ""
571
 
572
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:428
573
  msgid "Input Fields"
574
  msgstr ""
575
 
576
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:436
577
+ msgid "Floating Labels (Available in CartFlows Pro)"
578
  msgstr ""
579
 
580
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:442
581
  msgid "Style"
582
  msgstr ""
583
 
584
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:446
585
  msgid "Default"
586
  msgstr ""
587
 
588
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:447
589
+ msgid "Floating Labels"
590
  msgstr ""
591
 
592
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:474
593
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:566
594
  msgid "Size"
595
  msgstr ""
596
 
597
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:478
598
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:570
599
  msgid "Extra Small"
600
  msgstr ""
601
 
602
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:479
603
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:571
604
  msgid "Small"
605
  msgstr ""
606
 
607
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:480
608
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:572
609
  msgid "Medium"
610
  msgstr ""
611
 
612
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:481
613
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:573
614
  msgid "Large"
615
  msgstr ""
616
 
617
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:482
618
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:574
619
  msgid "Extra Large"
620
  msgstr ""
621
 
622
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:483
623
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:575
624
  msgid "Custom"
625
  msgstr ""
626
 
627
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:490
628
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:582
629
  msgid "Top Bottom Spacing"
630
  msgstr ""
631
 
632
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:498
633
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:590
634
  msgid "Left Right Spacing"
635
  msgstr ""
636
 
637
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:506
638
  msgid "Text / Placeholder Color"
639
  msgstr ""
640
 
641
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:514
642
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:614
643
  msgid "Background Color"
644
  msgstr ""
645
 
646
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:522
647
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:630
648
  msgid "Border Color"
649
  msgstr ""
650
 
651
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:529
652
  msgid "Label Color"
653
  msgstr ""
654
 
655
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:542
656
  msgid "Buttons"
657
  msgstr ""
658
 
659
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:598
660
  msgid "Text Color"
661
  msgstr ""
662
 
663
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:606
664
  msgid "Text Hover Color"
665
  msgstr ""
666
 
667
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:622
668
  msgid "Background Hover Color"
669
  msgstr ""
670
 
671
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:638
672
  msgid "Border Hover Color"
673
  msgstr ""
674
 
675
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:651
676
  msgid "Sections"
677
  msgstr ""
678
 
679
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:657
680
  msgid "Highlight Area Background Color"
681
  msgstr ""
682
 
683
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:696
684
  msgid "Header Logo"
685
  msgstr ""
686
 
687
+ #: modules/checkout/classes/class-cartflows-checkout-meta.php:704
688
  msgid "Logo Width (In px)"
689
  msgstr ""
690
 
791
 
792
  #: modules/flow/classes/class-cartflows-flow-post-type.php:252
793
  #: modules/flow/classes/class-cartflows-flow-post-type.php:258
794
+ #: modules/flow/classes/class-cartflows-step-post-type.php:376
795
+ #: modules/flow/classes/class-cartflows-step-post-type.php:382
796
  #. translators: %s: singular custom post type name
797
  msgid "%s updated."
798
  msgstr ""
799
 
800
  #: modules/flow/classes/class-cartflows-flow-post-type.php:254
801
+ #: modules/flow/classes/class-cartflows-step-post-type.php:378
802
  #. translators: %s: singular custom post type name
803
  msgid "Custom %s updated."
804
  msgstr ""
805
 
806
  #: modules/flow/classes/class-cartflows-flow-post-type.php:256
807
+ #: modules/flow/classes/class-cartflows-step-post-type.php:380
808
  #. translators: %s: singular custom post type name
809
  msgid "Custom %s deleted."
810
  msgstr ""
811
 
812
  #: modules/flow/classes/class-cartflows-flow-post-type.php:260
813
+ #: modules/flow/classes/class-cartflows-step-post-type.php:384
814
  #. translators: %1$s: singular custom post type name ,%2$s: date and time of
815
  #. the revision
816
  msgid "%1$s restored to revision from %2$s"
817
  msgstr ""
818
 
819
  #: modules/flow/classes/class-cartflows-flow-post-type.php:262
820
+ #: modules/flow/classes/class-cartflows-step-post-type.php:386
821
  #. translators: %s: singular custom post type name
822
  msgid "%s published."
823
  msgstr ""
824
 
825
  #: modules/flow/classes/class-cartflows-flow-post-type.php:264
826
+ #: modules/flow/classes/class-cartflows-step-post-type.php:388
827
  #. translators: %s: singular custom post type name
828
  msgid "%s saved."
829
  msgstr ""
830
 
831
  #: modules/flow/classes/class-cartflows-flow-post-type.php:266
832
+ #: modules/flow/classes/class-cartflows-step-post-type.php:390
833
  #. translators: %s: singular custom post type name
834
  msgid "%s submitted."
835
  msgstr ""
836
 
837
  #: modules/flow/classes/class-cartflows-flow-post-type.php:268
838
+ #: modules/flow/classes/class-cartflows-step-post-type.php:392
839
  #. translators: %s: singular custom post type name
840
  msgid "%s scheduled for."
841
  msgstr ""
842
 
843
  #: modules/flow/classes/class-cartflows-flow-post-type.php:270
844
+ #: modules/flow/classes/class-cartflows-step-post-type.php:394
845
  #. translators: %s: singular custom post type name
846
  msgid "%s draft updated."
847
  msgstr ""
860
  msgstr ""
861
 
862
  #: modules/flow/classes/class-cartflows-step-post-type.php:141
863
+ #: modules/flow/view/meta-flow-steps.php:97
864
  msgid "Edit Step"
865
  msgstr ""
866
 
867
  #: modules/flow/classes/class-cartflows-step-post-type.php:142
868
+ #: modules/flow/view/meta-flow-steps.php:93
869
  msgid "View Step"
870
  msgstr ""
871
 
910
  msgid "Downsell"
911
  msgstr ""
912
 
913
+ #: modules/flow/view/meta-flow-steps.php:77
914
  msgid "No Product Assigned"
915
  msgstr ""
916
 
917
+ #: modules/flow/view/meta-flow-steps.php:81
918
+ msgid "Global Checkout - Remove selected checkout product"
919
+ msgstr ""
920
+
921
+ #: modules/flow/view/meta-flow-steps.php:101
922
  msgid "Clone Step"
923
  msgstr ""
924
 
925
+ #: modules/flow/view/meta-flow-steps.php:105
926
  msgid "Delete Step"
927
  msgstr ""
928
 
929
+ #: modules/flow/view/meta-flow-steps.php:120
930
  msgid "Add New Step"
931
  msgstr ""
932
 
933
+ #: modules/flow/view/meta-flow-steps.php:136
934
  msgid "Templates"
935
  msgstr ""
936
 
937
+ #: modules/flow/view/meta-flow-steps.php:157
938
  msgid "You need a Cartflows Pro version to import Upsell / Downsell"
939
  msgstr ""
940
 
946
  msgid "Next Step Link"
947
  msgstr ""
948
 
949
+ #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:62
950
  msgid ""
951
  "WooCommerce functions not exists. If you are in iframe, please reload the "
952
  "iframe"
modules/checkout/classes/class-cartflows-checkout-markup.php CHANGED
@@ -1,942 +1,942 @@
1
- <?php
2
- /**
3
- * Checkout markup.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Checkout Markup
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Checkout_Markup {
14
-
15
- /**
16
- * Member Variable
17
- *
18
- * @var object instance
19
- */
20
- private static $instance;
21
-
22
- /**
23
- * Initiator
24
- */
25
- public static function get_instance() {
26
- if ( ! isset( self::$instance ) ) {
27
- self::$instance = new self;
28
- }
29
- return self::$instance;
30
- }
31
-
32
- /**
33
- * Constructor
34
- */
35
- public function __construct() {
36
-
37
- /* Set is checkout flag */
38
- add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
39
-
40
- add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_checkout_fields' ), 10, 2 );
41
-
42
- /* Checkout Shortcode */
43
- add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );
44
-
45
- /* Preconfigured cart data */
46
- add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 );
47
-
48
- /* Embed Checkout */
49
- add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 );
50
-
51
- /* Ajax Endpoint */
52
- add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ) );
53
-
54
- add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) );
55
-
56
- add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) );
57
-
58
- add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 );
59
-
60
- add_action( 'wp_ajax_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
61
- add_action( 'wp_ajax_nopriv_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
62
-
63
- add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
64
-
65
- /* Global Checkout */
66
- add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
67
- }
68
-
69
- /**
70
- * Redirect from default to the global checkout page
71
- *
72
- * @since 1.0.0
73
- */
74
- function global_checkout_template_redirect() {
75
-
76
- if ( ! is_checkout() ) {
77
- return;
78
- }
79
-
80
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
81
- return;
82
- }
83
-
84
- // redirect only from any non HC checkout pages.
85
- $order_pay_endpoint = get_option( 'woocommerce_checkout_order_pay_endpoint', 'order-pay' );
86
- $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
87
-
88
- $common = Cartflows_Helper::get_common_settings();
89
-
90
- $global_checkout = $common['global_checkout'];
91
-
92
- if (
93
- // ignore on order-pay.
94
- false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
95
- // ignore on TY page.
96
- false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
97
- ) {
98
-
99
- if ( '' !== $global_checkout ) {
100
-
101
- $link = get_permalink( $global_checkout );
102
-
103
- if ( ! empty( $link ) ) {
104
-
105
- wp_redirect( $link );
106
- die();
107
- }
108
- }
109
- }
110
- }
111
-
112
- /**
113
- * Check for checkout flag
114
- *
115
- * @param bool $is_checkout is checkout.
116
- *
117
- * @return bool
118
- */
119
- function woo_checkout_flag( $is_checkout ) {
120
-
121
- if ( ! is_admin() ) {
122
-
123
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
124
-
125
- $is_checkout = true;
126
- }
127
- }
128
-
129
- return $is_checkout;
130
- }
131
-
132
- /**
133
- * Render checkout shortcode markup.
134
- *
135
- * @param array $atts attributes.
136
- * @return string
137
- */
138
- function checkout_shortcode_markup( $atts ) {
139
-
140
- $atts = shortcode_atts(
141
- array(
142
- 'id' => 0,
143
- ),
144
- $atts
145
- );
146
-
147
- $checkout_id = intval( $atts['id'] );
148
-
149
- if ( empty( $checkout_id ) ) {
150
-
151
- if ( ! _is_wcf_checkout_type() ) {
152
-
153
- return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
154
- }
155
-
156
- global $post;
157
-
158
- $checkout_id = intval( $post->ID );
159
- }
160
-
161
- $output = '';
162
-
163
- ob_start();
164
-
165
- do_action( 'cartflows_checkout_form_before', $checkout_id );
166
-
167
- $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
168
-
169
- $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
170
-
171
- $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
172
-
173
- if ( file_exists( $template_layout ) ) {
174
- include $template_layout;
175
- } else {
176
- include $template_default;
177
- }
178
-
179
- $output .= ob_get_clean();
180
-
181
- return $output;
182
- }
183
-
184
- /**
185
- * Configure Cart Data.
186
- *
187
- * @since 1.0.0
188
- *
189
- * @return void
190
- */
191
- function preconfigured_cart_data() {
192
-
193
- if ( is_admin() ) {
194
- return;
195
- }
196
-
197
- global $post;
198
-
199
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
200
-
201
- if ( wp_doing_ajax() ) {
202
-
203
- return;
204
- } else {
205
-
206
- if ( _is_wcf_checkout_type() ) {
207
- $checkout_id = $post->ID;
208
- } else {
209
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
210
- }
211
-
212
- $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
213
-
214
- if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
215
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
216
- } else {
217
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
218
- }
219
-
220
- if ( ! is_array( $products ) ) {
221
-
222
- if ( 'dummy' === $products ) {
223
-
224
- $args = array(
225
- 'posts_per_page' => 1,
226
- 'orderby' => 'rand',
227
- 'post_type' => 'product',
228
- 'meta_query' => array(
229
- // Exclude out of stock products.
230
- array(
231
- 'key' => '_stock_status',
232
- 'value' => 'outofstock',
233
- 'compare' => 'NOT IN',
234
- ),
235
- ),
236
- 'tax_query' => array(
237
- array(
238
- 'taxonomy' => 'product_type',
239
- 'field' => 'slug',
240
- 'terms' => 'simple',
241
- ),
242
- ),
243
- );
244
-
245
- $random_product = get_posts( $args );
246
-
247
- if ( isset( $random_product[0]->ID ) ) {
248
- $products = array(
249
- array(
250
- 'product' => $random_product[0]->ID,
251
- ),
252
- );
253
- } else {
254
- return;
255
- }
256
- } else {
257
- return;
258
- }
259
- }
260
-
261
- if ( is_array( $products ) && count( $products ) < 1 ) {
262
-
263
- return;
264
- }
265
- /* Empty the current cart */
266
- WC()->cart->empty_cart();
267
-
268
- /* Set customer session if not set */
269
- if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
270
- WC()->session->set_customer_session_cookie( true );
271
- }
272
-
273
- foreach ( $products as $index => $data ) {
274
-
275
- if ( ! isset( $data['product'] ) ) {
276
- return;
277
- }
278
-
279
- $product_id = $data['product'];
280
- $_product = wc_get_product( $product_id );
281
-
282
- if ( ! empty( $_product ) ) {
283
-
284
- $quantity = 1;
285
-
286
- if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
287
-
288
- if ( $_product->is_type( 'variable' ) ) {
289
-
290
- $default_attributes = $_product->get_default_attributes();
291
-
292
- if ( ! empty( $default_attributes ) ) {
293
-
294
- foreach ( $_product->get_children() as $variation_id ) {
295
-
296
- $single_variation = new WC_Product_Variation( $variation_id );
297
-
298
- if ( $default_attributes == $single_variation->get_attributes() ) {
299
- WC()->cart->add_to_cart( $variation_id, $quantity );
300
- }
301
- }
302
- } else {
303
-
304
- $product_childrens = $_product->get_children();
305
-
306
- if ( isset( $product_childrens[0] ) ) {
307
- WC()->cart->add_to_cart( $product_childrens[0], $quantity );
308
- } else {
309
- echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
310
- }
311
- }
312
- } else {
313
- WC()->cart->add_to_cart( $product_id, $quantity );
314
- }
315
- } else {
316
-
317
- echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
318
- // WC()->cart->add_to_cart( $product_id, $quantity );.
319
- }
320
- }
321
- }
322
-
323
- do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
324
- }
325
- }
326
- }
327
-
328
- /**
329
- * Load shortcode data.
330
- *
331
- * @return void
332
- */
333
- function shortcode_load_data() {
334
-
335
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
336
-
337
- add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
338
-
339
- // Outputting the hidden field in checkout page.
340
- add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
341
- add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
342
-
343
- remove_all_actions( 'woocommerce_checkout_billing' );
344
- remove_all_actions( 'woocommerce_checkout_shipping' );
345
-
346
- // Hook in actions once.
347
- add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
348
- add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
349
-
350
- remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
351
-
352
- add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
353
-
354
- add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
355
-
356
- global $post;
357
-
358
- if ( _is_wcf_checkout_type() ) {
359
- $checkout_id = $post->ID;
360
- } else {
361
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
362
- }
363
-
364
- do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
365
- }
366
- }
367
-
368
- /**
369
- * Render checkout ID hidden field.
370
- *
371
- * @param array $checkout checkout session data.
372
- * @return void
373
- */
374
- function checkout_shortcode_post_id( $checkout ) {
375
-
376
- global $post;
377
-
378
- if ( _is_wcf_checkout_type() ) {
379
- $checkout_id = $post->ID;
380
- } else {
381
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
382
- }
383
-
384
- $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
385
-
386
- echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
387
- echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
388
- }
389
-
390
- /**
391
- * Load shortcode scripts.
392
- *
393
- * @return void
394
- */
395
- function shortcode_scripts() {
396
-
397
- wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
398
- wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
399
-
400
- if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
401
- wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
402
- wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
403
- }
404
-
405
- wp_enqueue_script(
406
- 'wcf-checkout-template',
407
- CARTFLOWS_URL . 'assets/js/checkout-template.js',
408
- array( 'jquery' ),
409
- CARTFLOWS_VER,
410
- true
411
- );
412
-
413
- do_action( 'cartflows_checkout_scripts' );
414
-
415
- $style = $this->generate_style();
416
-
417
- wp_add_inline_style( 'wcf-checkout-template', $style );
418
-
419
- }
420
-
421
- /**
422
- * Generate styles.
423
- *
424
- * @return string
425
- */
426
- function generate_style() {
427
-
428
- global $post;
429
-
430
- if ( _is_wcf_checkout_type() ) {
431
- $checkout_id = $post->ID;
432
- } else {
433
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
434
- }
435
-
436
- CartFlows_Font_Families::render_fonts( $checkout_id );
437
-
438
- $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
439
-
440
- $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
441
-
442
- $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
443
-
444
- /*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
445
-
446
- $field_tb_padding = '';
447
- $field_lr_padding = '';
448
-
449
- $field_heading_color = '';
450
- $field_color = '';
451
- $field_bg_color = '';
452
- $field_border_color = '';
453
- $field_label_color = '';
454
- $submit_tb_padding = '';
455
- $submit_lr_padding = '';
456
- $hl_bg_color = '';
457
- $field_input_size = '';
458
- $box_border_color = '';
459
- $section_bg_color = '';
460
- $submit_button_height = '';
461
- $submit_color = '';
462
- $submit_bg_color = $primary_color;
463
- $submit_border_color = $primary_color;
464
-
465
- $submit_hover_color = '';
466
- $submit_bg_hover_color = $primary_color;
467
- $submit_border_hover_color = $primary_color;
468
-
469
- $section_heading_color = '';
470
-
471
- $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
472
-
473
- $button_font_family = '';
474
- $button_font_weight = '';
475
- $input_font_family = '';
476
- $input_font_weight = '';
477
- $heading_font_family = '';
478
- $heading_font_weight = '';
479
- $base_font_family = $base_font_family;
480
- /*$base_font_weight = $base_font_weight;*/
481
-
482
- if ( 'yes' == $is_advance_option ) {
483
-
484
- /**
485
- * Get Font Family and Font Weight weight values
486
- */
487
- $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
488
-
489
- $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
490
- $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
491
- $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
492
- $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
493
- $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
494
- $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
495
- $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
496
- $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
497
- $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
498
- $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
499
-
500
- $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
501
-
502
- $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
503
-
504
- $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
505
-
506
- $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
507
-
508
- $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
509
-
510
- $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
511
-
512
- $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
513
-
514
- $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
515
-
516
- $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
517
-
518
- $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
519
-
520
- $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
521
-
522
- $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
523
-
524
- $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
525
-
526
- $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
527
-
528
- $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
529
-
530
- $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
531
-
532
- /**
533
- * Get font values
534
- */
535
-
536
- if ( 'custom' == $submit_button_height ) {
537
- $submit_button_height = '38px';
538
- }
539
-
540
- if ( 'custom' == $field_input_size ) {
541
- $field_input_size = '38px';
542
- }
543
- }
544
-
545
- $output = "
546
- .wcf-embed-checkout-form .wcf-checkout-header-image img{
547
- width: {$header_logo_width}px;
548
- }
549
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:after,
550
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:not(:checked):after,
551
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label:after,
552
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label:after {
553
- background: {$primary_color};
554
- }
555
-
556
- .wcf-embed-checkout-form .woocommerce-checkout label{
557
- color: {$field_label_color};
558
- }
559
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
560
- background-color: {$hl_bg_color};
561
- font-family: {$input_font_family};
562
- font-weight: {$input_font_weight};
563
- }
564
-
565
- .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
566
- .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
567
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
568
- {
569
- border-color: {$hl_bg_color};
570
- border-right-color: transparent;
571
- border-left-color: transparent;
572
- border-top-color: transparent;
573
- position: absolute;
574
- }
575
-
576
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
577
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
578
- font-family: {$input_font_family};
579
- font-weight: {$input_font_weight};
580
- }
581
-
582
- .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
583
- .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
584
- .wcf-embed-checkout-form .woocommerce form .form-row textarea,
585
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
586
- color: {$field_color};
587
- background: {$field_bg_color};
588
- border-color: {$field_border_color};
589
- padding-top: {$field_tb_padding}px;
590
- padding-bottom: {$field_tb_padding}px;
591
- padding-left: {$field_lr_padding}px;
592
- padding-right: {$field_lr_padding}px;
593
- min-height: {$field_input_size};
594
- font-family: {$input_font_family};
595
- font-weight: {$input_font_weight};
596
- }
597
-
598
- .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
599
- .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
600
- .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
601
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
602
- .wcf-embed-checkout-form .woocommerce-checkout #payment,
603
- .wcf-embed-checkout-form .woocommerce form.checkout_coupon
604
- {
605
- background-color: {$section_bg_color};
606
- border-color: {$box_border_color};
607
- font-family: {$input_font_family};
608
- font-weight: {$input_font_weight};
609
- }
610
-
611
- .woocommerce table.shop_table th{
612
- color: {$field_label_color};
613
- }
614
- .wcf-embed-checkout-form .woocommerce .woocommerce-info,
615
- .wcf-embed-checkout-form .woocommerce-message{
616
- border-top-color: {$primary_color};
617
- background-color: {$hl_bg_color};
618
- }
619
- .wcf-embed-checkout-form .woocommerce a{
620
- color: {$primary_color};
621
- }
622
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
623
- color: {$field_color};
624
- }
625
- .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
626
- color: {$field_color};
627
- }
628
- .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
629
- color: {$field_color};
630
- }
631
- .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
632
- color: {$field_color};
633
- }
634
- .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
635
- color: {$field_color};
636
- }
637
- .wcf-embed-checkout-form .woocommerce form p.form-row label {
638
- color: {$field_label_color};
639
- font-family: {$input_font_family};
640
- font-weight: {$input_font_weight};
641
- }
642
- .wcf-embed-checkout-form .woocommerce #order_review button {
643
- color: {$submit_color};
644
- background: {$submit_bg_color};
645
- padding-top: {$submit_tb_padding}px;
646
- padding-bottom: {$submit_tb_padding}px;
647
- padding-left: {$submit_lr_padding}px;
648
- padding-right: {$submit_lr_padding}px;
649
- border-color: {$submit_border_color};
650
- min-height: {$submit_button_height};
651
- font-family: {$button_font_family};
652
- font-weight: {$button_font_weight};
653
- }
654
- .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
655
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
656
- background: {$submit_bg_color};
657
- border: 1px {$submit_border_color} solid;
658
- color: {$submit_color};
659
- min-height: {$submit_button_height};
660
- font-family: {$button_font_family};
661
- font-weight: {$button_font_weight};
662
- }
663
- .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
664
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
665
- .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
666
- .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
667
- color: {$submit_hover_color};
668
- background-color: {$submit_bg_hover_color};
669
- border-color: {$submit_border_hover_color};
670
- }
671
- .wcf-embed-checkout-form .woocommerce h3,
672
- .wcf-embed-checkout-form .woocommerce h3 span,
673
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
674
- color: {$section_heading_color};
675
- font-family: {$heading_font_family};
676
- font-weight: {$heading_font_weight};
677
- }
678
- .wcf-embed-checkout-form .woocommerce-info::before,
679
- .wcf-embed-checkout-form .woocommerce-message::before{
680
- color: {$primary_color};
681
- }
682
- .wcf-embed-checkout-form{
683
- font-family: {$base_font_family};
684
- }";
685
-
686
- return $output;
687
- }
688
-
689
- /**
690
- * Get ajax end points.
691
- *
692
- * @param string $endpoint_url end point URL.
693
- * @return string
694
- */
695
- function get_ajax_endpoint( $endpoint_url ) {
696
-
697
- global $post;
698
-
699
- if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
700
-
701
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
702
-
703
- if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
704
-
705
- $query_args = array(
706
- 'wc-ajax' => '%%endpoint%%',
707
- );
708
-
709
- $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
710
- $uri = $uri[0];
711
-
712
- $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
713
- }
714
- }
715
- }
716
-
717
- return $endpoint_url;
718
- }
719
-
720
-
721
- /**
722
- * Save checkout fields.
723
- *
724
- * @param int $order_id order id.
725
- * @param array $posted posted data.
726
- * @return void
727
- */
728
- function save_checkout_fields( $order_id, $posted ) {
729
-
730
- if ( isset( $_POST['_wcf_checkout_id'] ) ) {
731
-
732
- $checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
733
-
734
- update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
735
-
736
- /*
737
- Custom Field To Do
738
- $custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
739
-
740
- if ( 'yes' === $custom_fields ) {
741
-
742
- $billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
743
-
744
- foreach ( $billing_fields as $field => $data ) {
745
-
746
- if ( isset( $data['custom'] ) && $data['custom'] ) {
747
-
748
- if ( isset( $_POST[ $field ] ) ) {
749
- update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
750
- }
751
- }
752
- }
753
-
754
- $shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
755
-
756
- foreach ( $shipping_fields as $field => $data ) {
757
-
758
- if ( isset( $data['custom'] ) && $data['custom'] ) {
759
-
760
- if ( isset( $_POST[ $field ] ) ) {
761
- update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
762
- }
763
- }
764
- }
765
- }
766
- */
767
- if ( isset( $_POST['_wcf_flow_id'] ) ) {
768
-
769
- $checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
770
-
771
- update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
772
- }
773
- }
774
-
775
- }
776
-
777
- /**
778
- * Enable Logo In Header Of Checkout Page
779
- *
780
- * @return void
781
- */
782
- function enable_logo_in_header() {
783
- global $post;
784
-
785
- if ( _is_wcf_checkout_type() ) {
786
- $checkout_id = $post->ID;
787
- } else {
788
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
789
- }
790
-
791
- $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
792
- $add_image_markup = '';
793
-
794
- if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
795
- $add_image_markup = '<div class="wcf-checkout-header-image">';
796
- $add_image_markup .= '<img src="' . $header_logo_image . '" />';
797
- $add_image_markup .= '</div>';
798
- }
799
-
800
- echo $add_image_markup;
801
- }
802
-
803
- /**
804
- * Add text to the bootom of the checkout page.
805
- *
806
- * @return void
807
- */
808
- function show_cartflows_copyright_message() {
809
- $output_string = '';
810
-
811
- $output_string .= '<div class="wcf-footer-primary">';
812
- $output_string .= '<div class="wcf-footer-content">';
813
- $output_string .= '<p class="wcf-footer-message">';
814
- $output_string .= 'Checkout powered by CartFlows';
815
- $output_string .= '</p>';
816
- $output_string .= '</div>';
817
- $output_string .= '</div>';
818
-
819
- echo $output_string;
820
- }
821
-
822
- /**
823
- * Redirect users to our checkout if hidden param
824
- *
825
- * @param string $redirect redirect url.
826
- * @param object $user user.
827
- * @return string
828
- */
829
- function after_login_redirect( $redirect, $user ) {
830
-
831
- if ( isset( $_POST['_wcf_checkout_id'] ) ) {
832
-
833
- $checkout_id = intval( $_POST['_wcf_checkout_id'] );
834
-
835
- $redirect = get_permalink( $checkout_id );
836
- }
837
-
838
- return $redirect;
839
- }
840
-
841
- /**
842
- * Display coupon code field after review order fields.
843
- */
844
- function display_custom_coupon_field() {
845
-
846
- $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
847
-
848
- if ( ! $coupon_enabled ) {
849
- return;
850
- }
851
-
852
- ob_start();
853
-
854
- ?>
855
- <div class="wcf-custom-coupon-field">
856
- <div class="wcf-coupon-col-1">
857
- <span>
858
- <input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="Coupon code" id="coupon_code" value="">
859
- </span>
860
- </div>
861
- <div class="wcf-coupon-col-2">
862
- <span>
863
- <button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply">Apply</button>
864
- </span>
865
- </div>
866
- </div>
867
-
868
- <?php
869
-
870
- echo ob_get_clean();
871
- }
872
-
873
- /**
874
- * Apply coupon on submit of custom coupon form.
875
- */
876
- function apply_coupon() {
877
-
878
- check_ajax_referer( 'cf-apply-coupon', 'security' );
879
-
880
- $result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
881
-
882
- echo json_encode( $result );
883
- die();
884
- }
885
-
886
- /**
887
- * Added ajax nonce to localize variable.
888
- *
889
- * @param array $vars localize variables.
890
- */
891
- function add_localize_vars( $vars ) {
892
-
893
- $vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
894
-
895
- return $vars;
896
- }
897
-
898
- /**
899
- * Add custom class to the fields to change the UI to three column.
900
- *
901
- * @param array $fields fields.
902
- */
903
- function add_three_column_layout_fields( $fields ) {
904
-
905
- if ( empty( $fields['billing']['billing_address_2'] ) ) {
906
-
907
- if ( isset( $fields['billing']['billing_address_1'] ) ) {
908
- $fields['billing']['billing_address_1']['class'] = array( 'form-row-full' );
909
- }
910
- }
911
-
912
- if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
913
-
914
- if ( isset( $fields['shipping']['shipping_address_1'] ) ) {
915
- $fields['shipping']['shipping_address_1']['class'] = array( 'form-row-full' );
916
- }
917
- }
918
-
919
- if ( isset( $fields['billing']['billing_city'] ) &&
920
- isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
921
-
922
- $fields['billing']['billing_city']['class'] = array( 'wcf-form-col-3' );
923
- $fields['billing']['billing_state']['class'] = array( 'wcf-form-col-3' );
924
- $fields['billing']['billing_postcode']['class'] = array( 'wcf-form-col-3' );
925
- }
926
-
927
- if ( isset( $fields['shipping']['shipping_city'] ) &&
928
- isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
929
-
930
- $fields['shipping']['shipping_city']['class'] = array( 'wcf-form-col-3' );
931
- $fields['shipping']['shipping_state']['class'] = array( 'wcf-form-col-3' );
932
- $fields['shipping']['shipping_postcode']['class'] = array( 'wcf-form-col-3' );
933
- }
934
-
935
- return $fields;
936
- }
937
- }
938
-
939
- /**
940
- * Kicking this off by calling 'get_instance()' method
941
- */
942
- Cartflows_Checkout_Markup::get_instance();
1
+ <?php
2
+ /**
3
+ * Checkout markup.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Checkout Markup
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Checkout_Markup {
14
+
15
+ /**
16
+ * Member Variable
17
+ *
18
+ * @var object instance
19
+ */
20
+ private static $instance;
21
+
22
+ /**
23
+ * Initiator
24
+ */
25
+ public static function get_instance() {
26
+ if ( ! isset( self::$instance ) ) {
27
+ self::$instance = new self;
28
+ }
29
+ return self::$instance;
30
+ }
31
+
32
+ /**
33
+ * Constructor
34
+ */
35
+ public function __construct() {
36
+
37
+ /* Set is checkout flag */
38
+ add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
39
+
40
+ add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_checkout_fields' ), 10, 2 );
41
+
42
+ /* Checkout Shortcode */
43
+ add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );
44
+
45
+ /* Preconfigured cart data */
46
+ add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 );
47
+
48
+ /* Embed Checkout */
49
+ add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 );
50
+
51
+ /* Ajax Endpoint */
52
+ add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ) );
53
+
54
+ add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) );
55
+
56
+ add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) );
57
+
58
+ add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 );
59
+
60
+ add_action( 'wp_ajax_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
61
+ add_action( 'wp_ajax_nopriv_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
62
+
63
+ add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
64
+
65
+ /* Global Checkout */
66
+ add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
67
+ }
68
+
69
+ /**
70
+ * Redirect from default to the global checkout page
71
+ *
72
+ * @since 1.0.0
73
+ */
74
+ function global_checkout_template_redirect() {
75
+
76
+ if ( ! is_checkout() ) {
77
+ return;
78
+ }
79
+
80
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
81
+ return;
82
+ }
83
+
84
+ // redirect only from any non HC checkout pages.
85
+ $order_pay_endpoint = get_option( 'woocommerce_checkout_order_pay_endpoint', 'order-pay' );
86
+ $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
87
+
88
+ $common = Cartflows_Helper::get_common_settings();
89
+
90
+ $global_checkout = $common['global_checkout'];
91
+
92
+ if (
93
+ // ignore on order-pay.
94
+ false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
95
+ // ignore on TY page.
96
+ false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
97
+ ) {
98
+
99
+ if ( '' !== $global_checkout ) {
100
+
101
+ $link = get_permalink( $global_checkout );
102
+
103
+ if ( ! empty( $link ) ) {
104
+
105
+ wp_redirect( $link );
106
+ die();
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Check for checkout flag
114
+ *
115
+ * @param bool $is_checkout is checkout.
116
+ *
117
+ * @return bool
118
+ */
119
+ function woo_checkout_flag( $is_checkout ) {
120
+
121
+ if ( ! is_admin() ) {
122
+
123
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
124
+
125
+ $is_checkout = true;
126
+ }
127
+ }
128
+
129
+ return $is_checkout;
130
+ }
131
+
132
+ /**
133
+ * Render checkout shortcode markup.
134
+ *
135
+ * @param array $atts attributes.
136
+ * @return string
137
+ */
138
+ function checkout_shortcode_markup( $atts ) {
139
+
140
+ $atts = shortcode_atts(
141
+ array(
142
+ 'id' => 0,
143
+ ),
144
+ $atts
145
+ );
146
+
147
+ $checkout_id = intval( $atts['id'] );
148
+
149
+ if ( empty( $checkout_id ) ) {
150
+
151
+ if ( ! _is_wcf_checkout_type() ) {
152
+
153
+ return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
154
+ }
155
+
156
+ global $post;
157
+
158
+ $checkout_id = intval( $post->ID );
159
+ }
160
+
161
+ $output = '';
162
+
163
+ ob_start();
164
+
165
+ do_action( 'cartflows_checkout_form_before', $checkout_id );
166
+
167
+ $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
168
+
169
+ $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
170
+
171
+ $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
172
+
173
+ if ( file_exists( $template_layout ) ) {
174
+ include $template_layout;
175
+ } else {
176
+ include $template_default;
177
+ }
178
+
179
+ $output .= ob_get_clean();
180
+
181
+ return $output;
182
+ }
183
+
184
+ /**
185
+ * Configure Cart Data.
186
+ *
187
+ * @since 1.0.0
188
+ *
189
+ * @return void
190
+ */
191
+ function preconfigured_cart_data() {
192
+
193
+ if ( is_admin() ) {
194
+ return;
195
+ }
196
+
197
+ global $post;
198
+
199
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
200
+
201
+ if ( wp_doing_ajax() ) {
202
+
203
+ return;
204
+ } else {
205
+
206
+ if ( _is_wcf_checkout_type() ) {
207
+ $checkout_id = $post->ID;
208
+ } else {
209
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
210
+ }
211
+
212
+ $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
213
+
214
+ if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
215
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
216
+ } else {
217
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
218
+ }
219
+
220
+ if ( ! is_array( $products ) ) {
221
+
222
+ if ( 'dummy' === $products ) {
223
+
224
+ $args = array(
225
+ 'posts_per_page' => 1,
226
+ 'orderby' => 'rand',
227
+ 'post_type' => 'product',
228
+ 'meta_query' => array(
229
+ // Exclude out of stock products.
230
+ array(
231
+ 'key' => '_stock_status',
232
+ 'value' => 'outofstock',
233
+ 'compare' => 'NOT IN',
234
+ ),
235
+ ),
236
+ 'tax_query' => array(
237
+ array(
238
+ 'taxonomy' => 'product_type',
239
+ 'field' => 'slug',
240
+ 'terms' => 'simple',
241
+ ),
242
+ ),
243
+ );
244
+
245
+ $random_product = get_posts( $args );
246
+
247
+ if ( isset( $random_product[0]->ID ) ) {
248
+ $products = array(
249
+ array(
250
+ 'product' => $random_product[0]->ID,
251
+ ),
252
+ );
253
+ } else {
254
+ return;
255
+ }
256
+ } else {
257
+ return;
258
+ }
259
+ }
260
+
261
+ if ( is_array( $products ) && count( $products ) < 1 ) {
262
+
263
+ return;
264
+ }
265
+ /* Empty the current cart */
266
+ WC()->cart->empty_cart();
267
+
268
+ /* Set customer session if not set */
269
+ if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
270
+ WC()->session->set_customer_session_cookie( true );
271
+ }
272
+
273
+ foreach ( $products as $index => $data ) {
274
+
275
+ if ( ! isset( $data['product'] ) ) {
276
+ return;
277
+ }
278
+
279
+ $product_id = $data['product'];
280
+ $_product = wc_get_product( $product_id );
281
+
282
+ if ( ! empty( $_product ) ) {
283
+
284
+ $quantity = 1;
285
+
286
+ if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
287
+
288
+ if ( $_product->is_type( 'variable' ) ) {
289
+
290
+ $default_attributes = $_product->get_default_attributes();
291
+
292
+ if ( ! empty( $default_attributes ) ) {
293
+
294
+ foreach ( $_product->get_children() as $variation_id ) {
295
+
296
+ $single_variation = new WC_Product_Variation( $variation_id );
297
+
298
+ if ( $default_attributes == $single_variation->get_attributes() ) {
299
+ WC()->cart->add_to_cart( $variation_id, $quantity );
300
+ }
301
+ }
302
+ } else {
303
+
304
+ $product_childrens = $_product->get_children();
305
+
306
+ if ( isset( $product_childrens[0] ) ) {
307
+ WC()->cart->add_to_cart( $product_childrens[0], $quantity );
308
+ } else {
309
+ echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
310
+ }
311
+ }
312
+ } else {
313
+ WC()->cart->add_to_cart( $product_id, $quantity );
314
+ }
315
+ } else {
316
+
317
+ echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
318
+ // WC()->cart->add_to_cart( $product_id, $quantity );.
319
+ }
320
+ }
321
+ }
322
+
323
+ do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
324
+ }
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Load shortcode data.
330
+ *
331
+ * @return void
332
+ */
333
+ function shortcode_load_data() {
334
+
335
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
336
+
337
+ add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
338
+
339
+ // Outputting the hidden field in checkout page.
340
+ add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
341
+ add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
342
+
343
+ remove_all_actions( 'woocommerce_checkout_billing' );
344
+ remove_all_actions( 'woocommerce_checkout_shipping' );
345
+
346
+ // Hook in actions once.
347
+ add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
348
+ add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
349
+
350
+ remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
351
+
352
+ add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
353
+
354
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
355
+
356
+ global $post;
357
+
358
+ if ( _is_wcf_checkout_type() ) {
359
+ $checkout_id = $post->ID;
360
+ } else {
361
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
362
+ }
363
+
364
+ do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
365
+ }
366
+ }
367
+
368
+ /**
369
+ * Render checkout ID hidden field.
370
+ *
371
+ * @param array $checkout checkout session data.
372
+ * @return void
373
+ */
374
+ function checkout_shortcode_post_id( $checkout ) {
375
+
376
+ global $post;
377
+
378
+ if ( _is_wcf_checkout_type() ) {
379
+ $checkout_id = $post->ID;
380
+ } else {
381
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
382
+ }
383
+
384
+ $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
385
+
386
+ echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
387
+ echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
388
+ }
389
+
390
+ /**
391
+ * Load shortcode scripts.
392
+ *
393
+ * @return void
394
+ */
395
+ function shortcode_scripts() {
396
+
397
+ wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
398
+ wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
399
+
400
+ if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
401
+ wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
402
+ wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
403
+ }
404
+
405
+ wp_enqueue_script(
406
+ 'wcf-checkout-template',
407
+ CARTFLOWS_URL . 'assets/js/checkout-template.js',
408
+ array( 'jquery' ),
409
+ CARTFLOWS_VER,
410
+ true
411
+ );
412
+
413
+ do_action( 'cartflows_checkout_scripts' );
414
+
415
+ $style = $this->generate_style();
416
+
417
+ wp_add_inline_style( 'wcf-checkout-template', $style );
418
+
419
+ }
420
+
421
+ /**
422
+ * Generate styles.
423
+ *
424
+ * @return string
425
+ */
426
+ function generate_style() {
427
+
428
+ global $post;
429
+
430
+ if ( _is_wcf_checkout_type() ) {
431
+ $checkout_id = $post->ID;
432
+ } else {
433
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
434
+ }
435
+
436
+ CartFlows_Font_Families::render_fonts( $checkout_id );
437
+
438
+ $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
439
+
440
+ $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
441
+
442
+ $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
443
+
444
+ /*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
445
+
446
+ $field_tb_padding = '';
447
+ $field_lr_padding = '';
448
+
449
+ $field_heading_color = '';
450
+ $field_color = '';
451
+ $field_bg_color = '';
452
+ $field_border_color = '';
453
+ $field_label_color = '';
454
+ $submit_tb_padding = '';
455
+ $submit_lr_padding = '';
456
+ $hl_bg_color = '';
457
+ $field_input_size = '';
458
+ $box_border_color = '';
459
+ $section_bg_color = '';
460
+ $submit_button_height = '';
461
+ $submit_color = '';
462
+ $submit_bg_color = $primary_color;
463
+ $submit_border_color = $primary_color;
464
+
465
+ $submit_hover_color = '';
466
+ $submit_bg_hover_color = $primary_color;
467
+ $submit_border_hover_color = $primary_color;
468
+
469
+ $section_heading_color = '';
470
+
471
+ $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
472
+
473
+ $button_font_family = '';
474
+ $button_font_weight = '';
475
+ $input_font_family = '';
476
+ $input_font_weight = '';
477
+ $heading_font_family = '';
478
+ $heading_font_weight = '';
479
+ $base_font_family = $base_font_family;
480
+ /*$base_font_weight = $base_font_weight;*/
481
+
482
+ if ( 'yes' == $is_advance_option ) {
483
+
484
+ /**
485
+ * Get Font Family and Font Weight weight values
486
+ */
487
+ $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
488
+
489
+ $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
490
+ $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
491
+ $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
492
+ $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
493
+ $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
494
+ $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
495
+ $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
496
+ $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
497
+ $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
498
+ $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
499
+
500
+ $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
501
+
502
+ $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
503
+
504
+ $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
505
+
506
+ $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
507
+
508
+ $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
509
+
510
+ $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
511
+
512
+ $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
513
+
514
+ $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
515
+
516
+ $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
517
+
518
+ $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
519
+
520
+ $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
521
+
522
+ $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
523
+
524
+ $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
525
+
526
+ $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
527
+
528
+ $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
529
+
530
+ $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
531
+
532
+ /**
533
+ * Get font values
534
+ */
535
+
536
+ if ( 'custom' == $submit_button_height ) {
537
+ $submit_button_height = '38px';
538
+ }
539
+
540
+ if ( 'custom' == $field_input_size ) {
541
+ $field_input_size = '38px';
542
+ }
543
+ }
544
+
545
+ $output = "
546
+ .wcf-embed-checkout-form .wcf-checkout-header-image img{
547
+ width: {$header_logo_width}px;
548
+ }
549
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:after,
550
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:not(:checked):after,
551
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label:after,
552
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label:after {
553
+ background: {$primary_color};
554
+ }
555
+
556
+ .wcf-embed-checkout-form .woocommerce-checkout label{
557
+ color: {$field_label_color};
558
+ }
559
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
560
+ background-color: {$hl_bg_color};
561
+ font-family: {$input_font_family};
562
+ font-weight: {$input_font_weight};
563
+ }
564
+
565
+ .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
566
+ .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
567
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
568
+ {
569
+ border-color: {$hl_bg_color};
570
+ border-right-color: transparent;
571
+ border-left-color: transparent;
572
+ border-top-color: transparent;
573
+ position: absolute;
574
+ }
575
+
576
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
577
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
578
+ font-family: {$input_font_family};
579
+ font-weight: {$input_font_weight};
580
+ }
581
+
582
+ .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
583
+ .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
584
+ .wcf-embed-checkout-form .woocommerce form .form-row textarea,
585
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
586
+ color: {$field_color};
587
+ background: {$field_bg_color};
588
+ border-color: {$field_border_color};
589
+ padding-top: {$field_tb_padding}px;
590
+ padding-bottom: {$field_tb_padding}px;
591
+ padding-left: {$field_lr_padding}px;
592
+ padding-right: {$field_lr_padding}px;
593
+ min-height: {$field_input_size};
594
+ font-family: {$input_font_family};
595
+ font-weight: {$input_font_weight};
596
+ }
597
+
598
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
599
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
600
+ .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
601
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
602
+ .wcf-embed-checkout-form .woocommerce-checkout #payment,
603
+ .wcf-embed-checkout-form .woocommerce form.checkout_coupon
604
+ {
605
+ background-color: {$section_bg_color};
606
+ border-color: {$box_border_color};
607
+ font-family: {$input_font_family};
608
+ font-weight: {$input_font_weight};
609
+ }
610
+
611
+ .woocommerce table.shop_table th{
612
+ color: {$field_label_color};
613
+ }
614
+ .wcf-embed-checkout-form .woocommerce .woocommerce-info,
615
+ .wcf-embed-checkout-form .woocommerce-message{
616
+ border-top-color: {$primary_color};
617
+ background-color: {$hl_bg_color};
618
+ }
619
+ .wcf-embed-checkout-form .woocommerce a{
620
+ color: {$primary_color};
621
+ }
622
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
623
+ color: {$field_color};
624
+ }
625
+ .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
626
+ color: {$field_color};
627
+ }
628
+ .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
629
+ color: {$field_color};
630
+ }
631
+ .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
632
+ color: {$field_color};
633
+ }
634
+ .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
635
+ color: {$field_color};
636
+ }
637
+ .wcf-embed-checkout-form .woocommerce form p.form-row label {
638
+ color: {$field_label_color};
639
+ font-family: {$input_font_family};
640
+ font-weight: {$input_font_weight};
641
+ }
642
+ .wcf-embed-checkout-form .woocommerce #order_review button {
643
+ color: {$submit_color};
644
+ background: {$submit_bg_color};
645
+ padding-top: {$submit_tb_padding}px;
646
+ padding-bottom: {$submit_tb_padding}px;
647
+ padding-left: {$submit_lr_padding}px;
648
+ padding-right: {$submit_lr_padding}px;
649
+ border-color: {$submit_border_color};
650
+ min-height: {$submit_button_height};
651
+ font-family: {$button_font_family};
652
+ font-weight: {$button_font_weight};
653
+ }
654
+ .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
655
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
656
+ background: {$submit_bg_color};
657
+ border: 1px {$submit_border_color} solid;
658
+ color: {$submit_color};
659
+ min-height: {$submit_button_height};
660
+ font-family: {$button_font_family};
661
+ font-weight: {$button_font_weight};
662
+ }
663
+ .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
664
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
665
+ .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
666
+ .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
667
+ color: {$submit_hover_color};
668
+ background-color: {$submit_bg_hover_color};
669
+ border-color: {$submit_border_hover_color};
670
+ }
671
+ .wcf-embed-checkout-form .woocommerce h3,
672
+ .wcf-embed-checkout-form .woocommerce h3 span,
673
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
674
+ color: {$section_heading_color};
675
+ font-family: {$heading_font_family};
676
+ font-weight: {$heading_font_weight};
677
+ }
678
+ .wcf-embed-checkout-form .woocommerce-info::before,
679
+ .wcf-embed-checkout-form .woocommerce-message::before{
680
+ color: {$primary_color};
681
+ }
682
+ .wcf-embed-checkout-form{
683
+ font-family: {$base_font_family};
684
+ }";
685
+
686
+ return $output;
687
+ }
688
+
689
+ /**
690
+ * Get ajax end points.
691
+ *
692
+ * @param string $endpoint_url end point URL.
693
+ * @return string
694
+ */
695
+ function get_ajax_endpoint( $endpoint_url ) {
696
+
697
+ global $post;
698
+
699
+ if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
700
+
701
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
702
+
703
+ if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
704
+
705
+ $query_args = array(
706
+ 'wc-ajax' => '%%endpoint%%',
707
+ );
708
+
709
+ $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
710
+ $uri = $uri[0];
711
+
712
+ $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
713
+ }
714
+ }
715
+ }
716
+
717
+ return $endpoint_url;
718
+ }
719
+
720
+
721
+ /**
722
+ * Save checkout fields.
723
+ *
724
+ * @param int $order_id order id.
725
+ * @param array $posted posted data.
726
+ * @return void
727
+ */
728
+ function save_checkout_fields( $order_id, $posted ) {
729
+
730
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) {
731
+
732
+ $checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
733
+
734
+ update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
735
+
736
+ /*
737
+ Custom Field To Do
738
+ $custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
739
+
740
+ if ( 'yes' === $custom_fields ) {
741
+
742
+ $billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
743
+
744
+ foreach ( $billing_fields as $field => $data ) {
745
+
746
+ if ( isset( $data['custom'] ) && $data['custom'] ) {
747
+
748
+ if ( isset( $_POST[ $field ] ) ) {
749
+ update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
750
+ }
751
+ }
752
+ }
753
+
754
+ $shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
755
+
756
+ foreach ( $shipping_fields as $field => $data ) {
757
+
758
+ if ( isset( $data['custom'] ) && $data['custom'] ) {
759
+
760
+ if ( isset( $_POST[ $field ] ) ) {
761
+ update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
762
+ }
763
+ }
764
+ }
765
+ }
766
+ */
767
+ if ( isset( $_POST['_wcf_flow_id'] ) ) {
768
+
769
+ $checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
770
+
771
+ update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
772
+ }
773
+ }
774
+
775
+ }
776
+
777
+ /**
778
+ * Enable Logo In Header Of Checkout Page
779
+ *
780
+ * @return void
781
+ */
782
+ function enable_logo_in_header() {
783
+ global $post;
784
+
785
+ if ( _is_wcf_checkout_type() ) {
786
+ $checkout_id = $post->ID;
787
+ } else {
788
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
789
+ }
790
+
791
+ $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
792
+ $add_image_markup = '';
793
+
794
+ if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
795
+ $add_image_markup = '<div class="wcf-checkout-header-image">';
796
+ $add_image_markup .= '<img src="' . $header_logo_image . '" />';
797
+ $add_image_markup .= '</div>';
798
+ }
799
+
800
+ echo $add_image_markup;
801
+ }
802
+
803
+ /**
804
+ * Add text to the bootom of the checkout page.
805
+ *
806
+ * @return void
807
+ */
808
+ function show_cartflows_copyright_message() {
809
+ $output_string = '';
810
+
811
+ $output_string .= '<div class="wcf-footer-primary">';
812
+ $output_string .= '<div class="wcf-footer-content">';
813
+ $output_string .= '<p class="wcf-footer-message">';
814
+ $output_string .= 'Checkout powered by CartFlows';
815
+ $output_string .= '</p>';
816
+ $output_string .= '</div>';
817
+ $output_string .= '</div>';
818
+
819
+ echo $output_string;
820
+ }
821
+
822
+ /**
823
+ * Redirect users to our checkout if hidden param
824
+ *
825
+ * @param string $redirect redirect url.
826
+ * @param object $user user.
827
+ * @return string
828
+ */
829
+ function after_login_redirect( $redirect, $user ) {
830
+
831
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) {
832
+
833
+ $checkout_id = intval( $_POST['_wcf_checkout_id'] );
834
+
835
+ $redirect = get_permalink( $checkout_id );
836
+ }
837
+
838
+ return $redirect;
839
+ }
840
+
841
+ /**
842
+ * Display coupon code field after review order fields.
843
+ */
844
+ function display_custom_coupon_field() {
845
+
846
+ $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
847
+
848
+ if ( ! $coupon_enabled ) {
849
+ return;
850
+ }
851
+
852
+ ob_start();
853
+
854
+ ?>
855
+ <div class="wcf-custom-coupon-field">
856
+ <div class="wcf-coupon-col-1">
857
+ <span>
858
+ <input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="<?php _e( 'Coupon Code', 'cartflows' ); ?>" id="coupon_code" value="">
859
+ </span>
860
+ </div>
861
+ <div class="wcf-coupon-col-2">
862
+ <span>
863
+ <button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php _e( 'Apply', 'cartflows' ); ?></button>
864
+ </span>
865
+ </div>
866
+ </div>
867
+
868
+ <?php
869
+
870
+ echo ob_get_clean();
871
+ }
872
+
873
+ /**
874
+ * Apply coupon on submit of custom coupon form.
875
+ */
876
+ function apply_coupon() {
877
+
878
+ check_ajax_referer( 'cf-apply-coupon', 'security' );
879
+
880
+ $result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
881
+
882
+ echo json_encode( $result );
883
+ die();
884
+ }
885
+
886
+ /**
887
+ * Added ajax nonce to localize variable.
888
+ *
889
+ * @param array $vars localize variables.
890
+ */
891
+ function add_localize_vars( $vars ) {
892
+
893
+ $vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
894
+
895
+ return $vars;
896
+ }
897
+
898
+ /**
899
+ * Add custom class to the fields to change the UI to three column.
900
+ *
901
+ * @param array $fields fields.
902
+ */
903
+ function add_three_column_layout_fields( $fields ) {
904
+
905
+ if ( empty( $fields['billing']['billing_address_2'] ) ) {
906
+
907
+ if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
908
+ $fields['billing']['billing_address_1']['class'][] = 'form-row-full';
909
+ }
910
+ }
911
+
912
+ if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
913
+
914
+ if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
915
+ $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
916
+ }
917
+ }
918
+
919
+ if ( isset( $fields['billing']['billing_city'] ) &&
920
+ isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
921
+
922
+ $fields['billing']['billing_city']['class'] = array( 'wcf-form-col-3' );
923
+ $fields['billing']['billing_state']['class'] = array( 'wcf-form-col-3' );
924
+ $fields['billing']['billing_postcode']['class'] = array( 'wcf-form-col-3' );
925
+ }
926
+
927
+ if ( isset( $fields['shipping']['shipping_city'] ) &&
928
+ isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
929
+
930
+ $fields['shipping']['shipping_city']['class'] = array( 'wcf-form-col-3' );
931
+ $fields['shipping']['shipping_state']['class'] = array( 'wcf-form-col-3' );
932
+ $fields['shipping']['shipping_postcode']['class'] = array( 'wcf-form-col-3' );
933
+ }
934
+
935
+ return $fields;
936
+ }
937
+ }
938
+
939
+ /**
940
+ * Kicking this off by calling 'get_instance()' method
941
+ */
942
+ Cartflows_Checkout_Markup::get_instance();
modules/checkout/classes/class-cartflows-checkout-meta.php CHANGED
@@ -1,757 +1,759 @@
1
- <?php
2
- /**
3
- * Checkout post meta
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Meta Boxes setup
10
- */
11
- class Cartflows_Checkout_Meta extends Cartflows_Meta {
12
-
13
- /**
14
- * Instance
15
- *
16
- * @var $instance
17
- */
18
- private static $instance;
19
-
20
- /**
21
- * Meta Option
22
- *
23
- * @var $meta_option
24
- */
25
- private static $meta_option = null;
26
-
27
- /**
28
- * Initiator
29
- */
30
- public static function get_instance() {
31
- if ( ! isset( self::$instance ) ) {
32
- self::$instance = new self;
33
- }
34
-
35
- return self::$instance;
36
- }
37
-
38
- /**
39
- * Constructor
40
- */
41
- public function __construct() {
42
-
43
- /* Init Metabox */
44
- add_action( 'load-post.php', array( $this, 'init_metabox' ) );
45
- add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
46
- }
47
-
48
- /**
49
- * Init Metabox
50
- */
51
- public function init_metabox() {
52
-
53
- add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
54
- add_action( 'save_post', array( $this, 'save_meta_box' ) );
55
- }
56
-
57
- /**
58
- * Setup Metabox
59
- */
60
- function setup_meta_box() {
61
-
62
- // Get all posts.
63
- $post_types = get_post_types();
64
-
65
- if ( _is_wcf_checkout_type() ) {
66
- add_meta_box(
67
- 'wcf-checkout-settings', // Id.
68
- __( 'Checkout Layout', 'cartflows' ), // Title.
69
- array( $this, 'markup_meta_box' ), // Callback.
70
- wcf()->utils->get_step_post_type(), // Post_type.
71
- 'normal', // Context.
72
- 'high' // Priority.
73
- );
74
- }
75
- }
76
-
77
- /**
78
- * Metabox Markup
79
- *
80
- * @param object $post Post object.
81
- * @return void
82
- */
83
- function markup_meta_box( $post ) {
84
-
85
- wp_nonce_field( 'save-nonce-checkout-step-meta', 'nonce-checkout-step-meta' );
86
-
87
- $stored = get_post_meta( $post->ID );
88
-
89
- $checkout_meta = self::get_meta_option( $post->ID );
90
-
91
- // Set stored and override defaults.
92
- foreach ( $stored as $key => $value ) {
93
- if ( array_key_exists( $key, $checkout_meta ) ) {
94
- self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
95
- } else {
96
- self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
97
- }
98
- }
99
-
100
- // Get defaults.
101
- $meta = self::get_meta_option( $post->ID );
102
- $checkout_data = array();
103
-
104
- foreach ( $meta as $key => $value ) {
105
-
106
- $checkout_data[ $key ] = $meta[ $key ]['default'];
107
- }
108
-
109
- /*
110
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post->ID );
111
-
112
- foreach ( $billing_fields as $key => $value ) {
113
-
114
- $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
115
- }
116
-
117
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post->ID );
118
-
119
- foreach ( $shipping_fields as $key => $value ) {
120
-
121
- $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
122
- }
123
-
124
- $additional_fields = Cartflows_Helper::get_checkout_fields( 'additional', $post->ID );
125
-
126
- foreach ( $additional_fields as $key => $value ) {
127
-
128
- $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
129
- }
130
- */
131
-
132
- do_action( 'wcf_checkout_settings_markup_before' );
133
- $this->tabs_markup( $checkout_data, $post->ID );
134
- do_action( 'wcf_checkout_settings_markup_after' );
135
- }
136
-
137
- /**
138
- * Page Header Tabs
139
- *
140
- * @param array $options options.
141
- * @param int $post_id post ID.
142
- */
143
- function tabs_markup( $options, $post_id ) {
144
-
145
- $active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
146
-
147
- if ( empty( $active_tab ) ) {
148
- $active_tab = 'wcf-checkout-shortcodes';
149
- }
150
-
151
- $tabs = array(
152
- array(
153
- 'title' => __( 'Shortcodes', 'cartflows' ),
154
- 'id' => 'wcf-checkout-shortcodes',
155
- 'class' => 'wcf-checkout-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
156
- 'icon' => 'dashicons-editor-code',
157
- 'help_text' => 'Help Helpppp...',
158
- ),
159
- array(
160
- 'title' => __( 'Select Product', 'cartflows' ),
161
- 'id' => 'wcf-checkout-general',
162
- 'class' => 'wcf-checkout-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
163
- 'icon' => 'dashicons-info',
164
- ),
165
- array(
166
- 'title' => __( 'Order Bump', 'cartflows' ),
167
- 'id' => 'wcf-product-order-bump',
168
- 'class' => 'wcf-product-order-bump' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
169
- 'icon' => 'dashicons-cart',
170
- ),
171
- array(
172
- 'title' => __( 'Checkout Design', 'cartflows' ),
173
- 'id' => 'wcf-checkout-style',
174
- 'class' => 'wcf-checkout-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
175
- 'icon' => 'dashicons-admin-customizer',
176
- ),
177
- array(
178
- 'title' => __( 'Checkout Fields', 'cartflows' ),
179
- 'id' => 'wcf-checkout-custom-fields',
180
- 'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
181
- 'icon' => 'dashicons-welcome-widgets-menus',
182
- ),
183
- array(
184
- 'title' => __( 'Logo ( Optional )', 'cartflows' ),
185
- 'id' => 'wcf-checkout-header',
186
- 'class' => 'wcf-checkout-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
187
- 'icon' => 'dashicons-format-image',
188
- ),
189
- );
190
-
191
- ?>
192
- <div class="wcf-checkout-table wcf-metabox-wrap widefat">
193
- <div class="wcf-table-container">
194
- <div class="wcf-column-left">
195
- <div class="wcf-tab-wrapper">
196
-
197
- <?php foreach ( $tabs as $key => $tab ) { ?>
198
- <div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
199
- <span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
200
- <span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
201
- </div>
202
- <?php } ?>
203
-
204
- <input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
205
- </div>
206
- </div>
207
- <div class="wcf-column-right">
208
- <?php $this->tab_shortcodes( $options, $post_id ); ?>
209
- <?php $this->tab_general( $options, $post_id ); ?>
210
- <?php $this->tab_style( $options, $post_id ); ?>
211
- <?php $this->tab_product_bump( $options, $post_id ); ?>
212
- <?php $this->tab_custom_fields( $options, $post_id ); ?>
213
- <?php $this->tab_header_content( $options, $post_id ); ?>
214
- <?php $this->right_column_footer( $options, $post_id ); ?>
215
- </div>
216
- </div>
217
- </div>
218
-
219
- <?php
220
- }
221
-
222
- /**
223
- * Shortcodes tab
224
- *
225
- * @param array $options options.
226
- * @param int $post_id post ID.
227
- */
228
- function tab_shortcodes( $options, $post_id ) {
229
- ?>
230
- <div class="wcf-checkout-shortcodes wcf-tab-content widefat">
231
-
232
- <?php
233
-
234
- echo wcf()->meta->get_shortcode_field(
235
- array(
236
- 'label' => 'Checkout Page',
237
- 'name' => 'wcf-checkout-shortcode',
238
- 'content' => '[cartflows_checkout]',
239
- 'help' => __( 'Add this shortcode to your checkout page', 'cartflows' ),
240
- )
241
- );
242
- ?>
243
- </div>
244
- <?php
245
- }
246
-
247
-
248
- /**
249
- * General tab
250
- *
251
- * @param array $options options.
252
- * @param int $post_id post ID.
253
- */
254
- function tab_general( $options, $post_id ) {
255
- ?>
256
- <div class="wcf-checkout-general wcf-tab-content widefat">
257
-
258
- <?php
259
-
260
- echo wcf()->meta->get_product_selection_repeater(
261
- array(
262
- 'name' => 'wcf-checkout-products',
263
- 'value' => $options['wcf-checkout-products'],
264
- 'allow_clear' => true,
265
- )
266
- );
267
-
268
- do_action( 'cartflows_checkout_general_tab_content', $options, $post_id );
269
-
270
- ?>
271
- </div>
272
- <?php
273
- }
274
-
275
- /**
276
- * Product bump tab
277
- *
278
- * @param array $options options.
279
- * @param int $post_id post ID.
280
- */
281
- function tab_product_bump( $options, $post_id ) {
282
- ?>
283
- <div class="wcf-product-order-bump wcf-tab-content widefat">
284
- <?php
285
- if ( ! _is_cartflows_pro() ) {
286
-
287
- echo wcf()->meta->get_description_field(
288
- array(
289
- 'name' => 'wcf-upgrade-to-pro',
290
- 'content' => '<i>' . __( 'Upgrade to <a href="#">CartFlows Pro</a> for Order Bump feature', 'cartflows' ) . '</i>',
291
- )
292
- );
293
- }
294
- ?>
295
-
296
- <?php do_action( 'cartflows_order_bump_tab_content', $options, $post_id ); ?>
297
- </div>
298
- <?php
299
- }
300
- /**
301
- * Tab custom fields
302
- *
303
- * @param array $options options.
304
- * @param int $post_id post ID.
305
- */
306
- function tab_custom_fields( $options, $post_id ) {
307
- ?>
308
- <div class="wcf-checkout-custom-fields wcf-tab-content widefat">
309
- <?php
310
- /* Custom Checkout Fields Section */
311
-
312
- if ( ! _is_cartflows_pro() ) {
313
-
314
- echo wcf()->meta->get_description_field(
315
- array(
316
- 'name' => 'wcf-upgrade-to-pro',
317
- 'content' => '<i>' . __( 'Upgrade to <a href="#">CartFlows Pro</a> for Custom Fields feature', 'cartflows' ) . '</i>',
318
- )
319
- );
320
- }
321
- ?>
322
- <?php do_action( 'cartflows_custom_fields_tab_content', $options, $post_id ); ?>
323
- </div>
324
- <?php
325
- }
326
-
327
- /**
328
- * Tab style
329
- *
330
- * @param array $options options.
331
- * @param int $post_id post ID.
332
- */
333
- function tab_style( $options, $post_id ) {
334
- ?>
335
-
336
- <div class="wcf-checkout-style wcf-tab-content widefat">
337
- <div class="wcf-cs-fields">
338
- <div class="wcf-cs-checkbox-field">
339
- <?php
340
-
341
- $layout_pro_option = array();
342
-
343
- if ( ! _is_cartflows_pro() ) {
344
- $layout_pro_option = array(
345
- 'one-column' => __( 'One Column (Available in CartFlows Pro) ', 'cartflows' ),
346
- );
347
- }
348
-
349
- echo wcf()->meta->get_select_field(
350
- array(
351
- 'label' => __( 'Checkout Skin', 'cartflows' ),
352
- 'name' => 'wcf-checkout-layout',
353
- 'value' => $options['wcf-checkout-layout'],
354
- 'options' => array(
355
- 'one-column' => __( 'One Column', 'cartflows' ),
356
- 'two-column' => __( 'Two Column', 'cartflows' ),
357
- ),
358
- 'pro-options' => $layout_pro_option,
359
-
360
- )
361
- );
362
-
363
- echo wcf()->meta->get_color_picker_field(
364
- array(
365
- 'label' => __( 'Primary Color', 'cartflows' ),
366
- 'name' => 'wcf-primary-color',
367
- 'value' => $options['wcf-primary-color'],
368
- )
369
- );
370
-
371
- echo wcf()->meta->get_font_family_field(
372
- array(
373
- 'for' => 'wcf-base',
374
- 'label' => __( 'Font Family', 'cartflows' ),
375
- 'name' => 'wcf-base-font-family',
376
- 'value' => $options['wcf-base-font-family'],
377
- )
378
- );
379
-
380
- echo wcf()->meta->get_checkbox_field(
381
- array(
382
- 'label' => __( 'Advance Options', 'cartflows' ),
383
- 'name' => 'wcf-advance-options-fields',
384
- 'value' => $options['wcf-advance-options-fields'],
385
- 'after' => 'Enable',
386
- )
387
- );
388
- ?>
389
- </div>
390
- <div class="wcf-cs-fields-options">
391
- <?php
392
- echo wcf()->meta->get_section(
393
- array(
394
- 'label' => __( 'Heading', 'cartflows' ),
395
- )
396
- );
397
-
398
- echo wcf()->meta->get_color_picker_field(
399
- array(
400
- 'label' => __( 'Heading Color', 'cartflows' ),
401
- 'name' => 'wcf-heading-color',
402
- 'value' => $options['wcf-heading-color'],
403
- )
404
- );
405
-
406
- echo wcf()->meta->get_font_family_field(
407
- array(
408
- 'for' => 'wcf-heading',
409
- 'label' => __( 'Font Family', 'cartflows' ),
410
- 'name' => 'wcf-heading-font-family',
411
- 'value' => $options['wcf-heading-font-family'],
412
- )
413
- );
414
-
415
- echo wcf()->meta->get_font_weight_field(
416
- array(
417
- 'for' => 'wcf-heading',
418
- 'label' => __( 'Font Weight', 'cartflows' ),
419
- 'name' => 'wcf-heading-font-weight',
420
- 'value' => $options['wcf-heading-font-weight'],
421
- )
422
- );
423
-
424
- echo wcf()->meta->get_section(
425
- array(
426
- 'label' => __( 'Input Fields', 'cartflows' ),
427
- )
428
- );
429
-
430
- $fields_skin_pro_option = array();
431
-
432
- if ( ! _is_cartflows_pro() ) {
433
- $fields_skin_pro_option = array(
434
- 'skin-one' => __( 'Style 1 (Available in CartFlows Pro)', 'cartflows' ),
435
- );
436
- }
437
-
438
- echo wcf()->meta->get_select_field(
439
- array(
440
- 'label' => __( 'Style', 'cartflows' ),
441
- 'name' => 'wcf-fields-skins',
442
- 'value' => $options['wcf-fields-skins'],
443
- 'options' => array(
444
- 'default' => __( 'Default', 'cartflows' ),
445
- 'style-one' => __( 'Style 1', 'cartflows' ),
446
- ),
447
- 'pro-options' => $fields_skin_pro_option,
448
-
449
- )
450
- );
451
-
452
- echo wcf()->meta->get_font_family_field(
453
- array(
454
- 'for' => 'wcf-input',
455
- 'label' => __( 'Font Family', 'cartflows' ),
456
- 'name' => 'wcf-input-font-family',
457
- 'value' => $options['wcf-input-font-family'],
458
- )
459
- );
460
-
461
- echo wcf()->meta->get_font_weight_field(
462
- array(
463
- 'for' => 'wcf-input',
464
- 'label' => __( 'Font Weight', 'cartflows' ),
465
- 'name' => 'wcf-input-font-weight',
466
- 'value' => $options['wcf-input-font-weight'],
467
- )
468
- );
469
-
470
- echo wcf()->meta->get_select_field(
471
- array(
472
- 'label' => __( 'Size', 'cartflows' ),
473
- 'name' => 'wcf-input-field-size',
474
- 'value' => $options['wcf-input-field-size'],
475
- 'options' => array(
476
- '33px' => __( 'Extra Small', 'cartflows' ),
477
- '38px' => __( 'Small', 'cartflows' ),
478
- '44px' => __( 'Medium', 'cartflows' ),
479
- '58px' => __( 'Large', 'cartflows' ),
480
- '68px' => __( 'Extra Large', 'cartflows' ),
481
- 'custom' => __( 'Custom', 'cartflows' ),
482
- ),
483
- )
484
- );
485
-
486
- echo wcf()->meta->get_number_field(
487
- array(
488
- 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
489
- 'name' => 'wcf-field-tb-padding',
490
- 'value' => $options['wcf-field-tb-padding'],
491
- )
492
- );
493
-
494
- echo wcf()->meta->get_number_field(
495
- array(
496
- 'label' => __( 'Left Right Spacing', 'cartflows' ),
497
- 'name' => 'wcf-field-lr-padding',
498
- 'value' => $options['wcf-field-lr-padding'],
499
- )
500
- );
501
-
502
- echo wcf()->meta->get_color_picker_field(
503
- array(
504
- 'label' => __( 'Text / Placeholder Color', 'cartflows' ),
505
- 'name' => 'wcf-field-color',
506
- 'value' => $options['wcf-field-color'],
507
- )
508
- );
509
-
510
- echo wcf()->meta->get_color_picker_field(
511
- array(
512
- 'label' => __( 'Background Color', 'cartflows' ),
513
- 'name' => 'wcf-field-bg-color',
514
- 'value' => $options['wcf-field-bg-color'],
515
- )
516
- );
517
-
518
- echo wcf()->meta->get_color_picker_field(
519
- array(
520
- 'label' => __( 'Border Color', 'cartflows' ),
521
- 'name' => 'wcf-field-border-color',
522
- 'value' => $options['wcf-field-border-color'],
523
- )
524
- );
525
- echo wcf()->meta->get_color_picker_field(
526
- array(
527
- 'label' => __( 'Label Color', 'cartflows' ),
528
- 'name' => 'wcf-field-label-color',
529
- 'value' => $options['wcf-field-label-color'],
530
- )
531
- );
532
-
533
- ?>
534
- </div>
535
- <div class="wcf-cs-button-options">
536
- <?php
537
-
538
- echo wcf()->meta->get_section(
539
- array(
540
- 'label' => __( 'Buttons', 'cartflows' ),
541
- )
542
- );
543
-
544
- echo wcf()->meta->get_font_family_field(
545
- array(
546
- 'for' => 'wcf-button',
547
- 'label' => __( 'Font Family', 'cartflows' ),
548
- 'name' => 'wcf-button-font-family',
549
- 'value' => $options['wcf-button-font-family'],
550
- )
551
- );
552
-
553
- echo wcf()->meta->get_font_weight_field(
554
- array(
555
- 'for' => 'wcf-button',
556
- 'label' => __( 'Font Weight', 'cartflows' ),
557
- 'name' => 'wcf-button-font-weight',
558
- 'value' => $options['wcf-button-font-weight'],
559
- )
560
- );
561
-
562
- echo wcf()->meta->get_select_field(
563
- array(
564
- 'label' => __( 'Size', 'cartflows' ),
565
- 'name' => 'wcf-input-button-size',
566
- 'value' => $options['wcf-input-button-size'],
567
- 'options' => array(
568
- '33px' => __( 'Extra Small', 'cartflows' ),
569
- '38px' => __( 'Small', 'cartflows' ),
570
- '44px' => __( 'Medium', 'cartflows' ),
571
- '58px' => __( 'Large', 'cartflows' ),
572
- '68px' => __( 'Extra Large', 'cartflows' ),
573
- 'custom' => __( 'Custom', 'cartflows' ),
574
- ),
575
- )
576
- );
577
-
578
- echo wcf()->meta->get_number_field(
579
- array(
580
- 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
581
- 'name' => 'wcf-submit-tb-padding',
582
- 'value' => $options['wcf-submit-tb-padding'],
583
- )
584
- );
585
-
586
- echo wcf()->meta->get_number_field(
587
- array(
588
- 'label' => __( 'Left Right Spacing', 'cartflows' ),
589
- 'name' => 'wcf-submit-lr-padding',
590
- 'value' => $options['wcf-submit-lr-padding'],
591
- )
592
- );
593
-
594
- echo wcf()->meta->get_color_picker_field(
595
- array(
596
- 'label' => __( 'Text Color', 'cartflows' ),
597
- 'name' => 'wcf-submit-color',
598
- 'value' => $options['wcf-submit-color'],
599
- )
600
- );
601
-
602
- echo wcf()->meta->get_color_picker_field(
603
- array(
604
- 'label' => __( 'Text Hover Color', 'cartflows' ),
605
- 'name' => 'wcf-submit-hover-color',
606
- 'value' => $options['wcf-submit-hover-color'],
607
- )
608
- );
609
-
610
- echo wcf()->meta->get_color_picker_field(
611
- array(
612
- 'label' => __( 'Background Color', 'cartflows' ),
613
- 'name' => 'wcf-submit-bg-color',
614
- 'value' => $options['wcf-submit-bg-color'],
615
- )
616
- );
617
-
618
- echo wcf()->meta->get_color_picker_field(
619
- array(
620
- 'label' => __( 'Background Hover Color', 'cartflows' ),
621
- 'name' => 'wcf-submit-bg-hover-color',
622
- 'value' => $options['wcf-submit-bg-hover-color'],
623
- )
624
- );
625
-
626
- echo wcf()->meta->get_color_picker_field(
627
- array(
628
- 'label' => __( 'Border Color', 'cartflows' ),
629
- 'name' => 'wcf-submit-border-color',
630
- 'value' => $options['wcf-submit-border-color'],
631
- )
632
- );
633
-
634
- echo wcf()->meta->get_color_picker_field(
635
- array(
636
- 'label' => __( 'Border Hover Color', 'cartflows' ),
637
- 'name' => 'wcf-submit-border-hover-color',
638
- 'value' => $options['wcf-submit-border-hover-color'],
639
- )
640
- );
641
-
642
- ?>
643
- </div>
644
- <div class="wcf-cs-section-options">
645
- <?php
646
-
647
- echo wcf()->meta->get_section(
648
- array(
649
- 'label' => __( 'Sections', 'cartflows' ),
650
- )
651
- );
652
-
653
- echo wcf()->meta->get_color_picker_field(
654
- array(
655
- 'label' => __( 'Highlight Area Background Color', 'cartflows' ),
656
- 'name' => 'wcf-hl-bg-color',
657
- 'value' => $options['wcf-hl-bg-color'],
658
- )
659
- );
660
-
661
- echo wcf()->meta->get_hidden_field(
662
- array(
663
- 'name' => 'wcf-field-google-font-url',
664
- 'value' => $options['wcf-field-google-font-url'],
665
- )
666
- );
667
- ?>
668
- </div>
669
- <?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
670
- </div>
671
- </div>
672
- <?php
673
- }
674
-
675
-
676
- /**
677
- * Tab Header (Used for add logo into header)
678
- *
679
- * @param array $options options.
680
- * @param int $post_id post ID.
681
- */
682
- function tab_header_content( $options, $post_id ) {
683
- ?>
684
-
685
- <div class="wcf-checkout-header wcf-tab-content widefat">
686
- <?php
687
-
688
- $layout_pro_option = array();
689
-
690
- echo wcf()->meta->get_image_field(
691
- array(
692
- 'name' => 'wcf-header-logo-image',
693
- 'value' => $options['wcf-header-logo-image'],
694
- 'label' => __( 'Header Logo', 'cartflows' ),
695
- )
696
- );
697
-
698
- echo wcf()->meta->get_number_field(
699
- array(
700
- 'name' => 'wcf-header-logo-width',
701
- 'value' => $options['wcf-header-logo-width'],
702
- 'label' => __( 'Logo Width (In px)', 'cartflows' ),
703
- )
704
- );
705
- ?>
706
- <?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
707
- </div>
708
- <?php
709
- }
710
- /**
711
- * Get metabox options
712
- *
713
- * @param int $post_id post ID.
714
- */
715
- public static function get_meta_option( $post_id ) {
716
-
717
- if ( null === self::$meta_option ) {
718
-
719
- /**
720
- * Set metabox options
721
- *
722
- * @see http://php.net/manual/en/filter.filters.sanitize.php
723
- */
724
- self::$meta_option = wcf()->options->get_checkout_fields( $post_id );
725
- }
726
-
727
- return self::$meta_option;
728
- }
729
-
730
- /**
731
- * Metabox Save
732
- *
733
- * @param number $post_id Post ID.
734
- * @return void
735
- */
736
- function save_meta_box( $post_id ) {
737
-
738
- // Checks save status.
739
- $is_autosave = wp_is_post_autosave( $post_id );
740
- $is_revision = wp_is_post_revision( $post_id );
741
-
742
- $is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( $_POST['nonce-checkout-step-meta'], 'save-nonce-checkout-step-meta' ) ) ? true : false;
743
-
744
- // Exits script depending on save status.
745
- if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
746
- return;
747
- }
748
-
749
- wcf()->options->save_checkout_fields( $post_id );
750
- }
751
-
752
- }
753
-
754
- /**
755
- * Kicking this off by calling 'get_instance()' method
756
- */
757
- Cartflows_Checkout_Meta::get_instance();
 
 
1
+ <?php
2
+ /**
3
+ * Checkout post meta
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Meta Boxes setup
10
+ */
11
+ class Cartflows_Checkout_Meta extends Cartflows_Meta {
12
+
13
+ /**
14
+ * Instance
15
+ *
16
+ * @var $instance
17
+ */
18
+ private static $instance;
19
+
20
+ /**
21
+ * Meta Option
22
+ *
23
+ * @var $meta_option
24
+ */
25
+ private static $meta_option = null;
26
+
27
+ /**
28
+ * Initiator
29
+ */
30
+ public static function get_instance() {
31
+ if ( ! isset( self::$instance ) ) {
32
+ self::$instance = new self;
33
+ }
34
+
35
+ return self::$instance;
36
+ }
37
+
38
+ /**
39
+ * Constructor
40
+ */
41
+ public function __construct() {
42
+
43
+ /* Init Metabox */
44
+ add_action( 'load-post.php', array( $this, 'init_metabox' ) );
45
+ add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
46
+ }
47
+
48
+ /**
49
+ * Init Metabox
50
+ */
51
+ public function init_metabox() {
52
+
53
+ add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
54
+ add_action( 'save_post', array( $this, 'save_meta_box' ) );
55
+ }
56
+
57
+ /**
58
+ * Setup Metabox
59
+ */
60
+ function setup_meta_box() {
61
+
62
+ // Get all posts.
63
+ $post_types = get_post_types();
64
+
65
+ if ( _is_wcf_checkout_type() ) {
66
+ add_meta_box(
67
+ 'wcf-checkout-settings', // Id.
68
+ __( 'Checkout Layout', 'cartflows' ), // Title.
69
+ array( $this, 'markup_meta_box' ), // Callback.
70
+ wcf()->utils->get_step_post_type(), // Post_type.
71
+ 'normal', // Context.
72
+ 'high' // Priority.
73
+ );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Metabox Markup
79
+ *
80
+ * @param object $post Post object.
81
+ * @return void
82
+ */
83
+ function markup_meta_box( $post ) {
84
+
85
+ wp_nonce_field( 'save-nonce-checkout-step-meta', 'nonce-checkout-step-meta' );
86
+
87
+ $stored = get_post_meta( $post->ID );
88
+
89
+ $checkout_meta = self::get_meta_option( $post->ID );
90
+
91
+ // Set stored and override defaults.
92
+ foreach ( $stored as $key => $value ) {
93
+ if ( array_key_exists( $key, $checkout_meta ) ) {
94
+ self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
95
+ } else {
96
+ self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
97
+ }
98
+ }
99
+
100
+ // Get defaults.
101
+ $meta = self::get_meta_option( $post->ID );
102
+ $checkout_data = array();
103
+
104
+ foreach ( $meta as $key => $value ) {
105
+
106
+ $checkout_data[ $key ] = $meta[ $key ]['default'];
107
+ }
108
+
109
+ /*
110
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post->ID );
111
+
112
+ foreach ( $billing_fields as $key => $value ) {
113
+
114
+ $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
115
+ }
116
+
117
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post->ID );
118
+
119
+ foreach ( $shipping_fields as $key => $value ) {
120
+
121
+ $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
122
+ }
123
+
124
+ $additional_fields = Cartflows_Helper::get_checkout_fields( 'additional', $post->ID );
125
+
126
+ foreach ( $additional_fields as $key => $value ) {
127
+
128
+ $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
129
+ }
130
+ */
131
+
132
+ do_action( 'wcf_checkout_settings_markup_before' );
133
+ $this->tabs_markup( $checkout_data, $post->ID );
134
+ do_action( 'wcf_checkout_settings_markup_after' );
135
+ }
136
+
137
+ /**
138
+ * Page Header Tabs
139
+ *
140
+ * @param array $options options.
141
+ * @param int $post_id post ID.
142
+ */
143
+ function tabs_markup( $options, $post_id ) {
144
+
145
+ $active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
146
+
147
+ if ( empty( $active_tab ) ) {
148
+ $active_tab = 'wcf-checkout-shortcodes';
149
+ }
150
+
151
+ $tabs = array(
152
+ array(
153
+ 'title' => __( 'Shortcodes', 'cartflows' ),
154
+ 'id' => 'wcf-checkout-shortcodes',
155
+ 'class' => 'wcf-checkout-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
156
+ 'icon' => 'dashicons-editor-code',
157
+ 'help_text' => 'Help Helpppp...',
158
+ ),
159
+ array(
160
+ 'title' => __( 'Select Product', 'cartflows' ),
161
+ 'id' => 'wcf-checkout-general',
162
+ 'class' => 'wcf-checkout-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
163
+ 'icon' => 'dashicons-info',
164
+ ),
165
+ array(
166
+ 'title' => __( 'Order Bump', 'cartflows' ),
167
+ 'id' => 'wcf-product-order-bump',
168
+ 'class' => 'wcf-product-order-bump' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
169
+ 'icon' => 'dashicons-cart',
170
+ ),
171
+ array(
172
+ 'title' => __( 'Checkout Design', 'cartflows' ),
173
+ 'id' => 'wcf-checkout-style',
174
+ 'class' => 'wcf-checkout-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
175
+ 'icon' => 'dashicons-admin-customizer',
176
+ ),
177
+ array(
178
+ 'title' => __( 'Checkout Fields', 'cartflows' ),
179
+ 'id' => 'wcf-checkout-custom-fields',
180
+ 'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
181
+ 'icon' => 'dashicons-welcome-widgets-menus',
182
+ ),
183
+ array(
184
+ 'title' => __( 'Logo ( Optional )', 'cartflows' ),
185
+ 'id' => 'wcf-checkout-header',
186
+ 'class' => 'wcf-checkout-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
187
+ 'icon' => 'dashicons-format-image',
188
+ ),
189
+ );
190
+
191
+ ?>
192
+ <div class="wcf-checkout-table wcf-metabox-wrap widefat">
193
+ <div class="wcf-table-container">
194
+ <div class="wcf-column-left">
195
+ <div class="wcf-tab-wrapper">
196
+
197
+ <?php foreach ( $tabs as $key => $tab ) { ?>
198
+ <div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
199
+ <span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
200
+ <span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
201
+ </div>
202
+ <?php } ?>
203
+
204
+ <input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
205
+ </div>
206
+ </div>
207
+ <div class="wcf-column-right">
208
+ <?php $this->tab_shortcodes( $options, $post_id ); ?>
209
+ <?php $this->tab_general( $options, $post_id ); ?>
210
+ <?php $this->tab_style( $options, $post_id ); ?>
211
+ <?php $this->tab_product_bump( $options, $post_id ); ?>
212
+ <?php $this->tab_custom_fields( $options, $post_id ); ?>
213
+ <?php $this->tab_header_content( $options, $post_id ); ?>
214
+ <?php $this->right_column_footer( $options, $post_id ); ?>
215
+ </div>
216
+ </div>
217
+ </div>
218
+
219
+ <?php
220
+ }
221
+
222
+ /**
223
+ * Shortcodes tab
224
+ *
225
+ * @param array $options options.
226
+ * @param int $post_id post ID.
227
+ */
228
+ function tab_shortcodes( $options, $post_id ) {
229
+ ?>
230
+ <div class="wcf-checkout-shortcodes wcf-tab-content widefat">
231
+
232
+ <?php
233
+
234
+ echo wcf()->meta->get_shortcode_field(
235
+ array(
236
+ 'label' => 'Checkout Page',
237
+ 'name' => 'wcf-checkout-shortcode',
238
+ 'content' => '[cartflows_checkout]',
239
+ 'help' => __( 'Add this shortcode to your checkout page', 'cartflows' ),
240
+ )
241
+ );
242
+ ?>
243
+ </div>
244
+ <?php
245
+ }
246
+
247
+
248
+ /**
249
+ * General tab
250
+ *
251
+ * @param array $options options.
252
+ * @param int $post_id post ID.
253
+ */
254
+ function tab_general( $options, $post_id ) {
255
+ ?>
256
+ <div class="wcf-checkout-general wcf-tab-content widefat">
257
+
258
+ <?php
259
+
260
+ echo wcf()->meta->get_product_selection_repeater(
261
+ array(
262
+ 'name' => 'wcf-checkout-products',
263
+ 'value' => $options['wcf-checkout-products'],
264
+ 'allow_clear' => true,
265
+ )
266
+ );
267
+
268
+ do_action( 'cartflows_checkout_general_tab_content', $options, $post_id );
269
+
270
+ ?>
271
+ </div>
272
+ <?php
273
+ }
274
+
275
+ /**
276
+ * Product bump tab
277
+ *
278
+ * @param array $options options.
279
+ * @param int $post_id post ID.
280
+ */
281
+ function tab_product_bump( $options, $post_id ) {
282
+ ?>
283
+ <div class="wcf-product-order-bump wcf-tab-content widefat">
284
+ <?php
285
+ if ( ! _is_cartflows_pro() ) {
286
+
287
+ echo wcf()->meta->get_description_field(
288
+ array(
289
+ 'name' => 'wcf-upgrade-to-pro',
290
+ /* translators: %s: link */
291
+ 'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
292
+ )
293
+ );
294
+ }
295
+ ?>
296
+
297
+ <?php do_action( 'cartflows_order_bump_tab_content', $options, $post_id ); ?>
298
+ </div>
299
+ <?php
300
+ }
301
+ /**
302
+ * Tab custom fields
303
+ *
304
+ * @param array $options options.
305
+ * @param int $post_id post ID.
306
+ */
307
+ function tab_custom_fields( $options, $post_id ) {
308
+ ?>
309
+ <div class="wcf-checkout-custom-fields wcf-tab-content widefat">
310
+ <?php
311
+ /* Custom Checkout Fields Section */
312
+
313
+ if ( ! _is_cartflows_pro() ) {
314
+
315
+ echo wcf()->meta->get_description_field(
316
+ array(
317
+ 'name' => 'wcf-upgrade-to-pro',
318
+ /* translators: %s: link */
319
+ 'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
320
+ )
321
+ );
322
+ }
323
+ ?>
324
+ <?php do_action( 'cartflows_custom_fields_tab_content', $options, $post_id ); ?>
325
+ </div>
326
+ <?php
327
+ }
328
+
329
+ /**
330
+ * Tab style
331
+ *
332
+ * @param array $options options.
333
+ * @param int $post_id post ID.
334
+ */
335
+ function tab_style( $options, $post_id ) {
336
+ ?>
337
+
338
+ <div class="wcf-checkout-style wcf-tab-content widefat">
339
+ <div class="wcf-cs-fields">
340
+ <div class="wcf-cs-checkbox-field">
341
+ <?php
342
+
343
+ $layout_pro_option = array();
344
+
345
+ if ( ! _is_cartflows_pro() ) {
346
+ $layout_pro_option = array(
347
+ 'one-column' => __( 'One Column (Available in CartFlows Pro) ', 'cartflows' ),
348
+ );
349
+ }
350
+
351
+ echo wcf()->meta->get_select_field(
352
+ array(
353
+ 'label' => __( 'Checkout Skin', 'cartflows' ),
354
+ 'name' => 'wcf-checkout-layout',
355
+ 'value' => $options['wcf-checkout-layout'],
356
+ 'options' => array(
357
+ 'one-column' => __( 'One Column', 'cartflows' ),
358
+ 'two-column' => __( 'Two Column', 'cartflows' ),
359
+ ),
360
+ 'pro-options' => $layout_pro_option,
361
+
362
+ )
363
+ );
364
+
365
+ echo wcf()->meta->get_color_picker_field(
366
+ array(
367
+ 'label' => __( 'Primary Color', 'cartflows' ),
368
+ 'name' => 'wcf-primary-color',
369
+ 'value' => $options['wcf-primary-color'],
370
+ )
371
+ );
372
+
373
+ echo wcf()->meta->get_font_family_field(
374
+ array(
375
+ 'for' => 'wcf-base',
376
+ 'label' => __( 'Font Family', 'cartflows' ),
377
+ 'name' => 'wcf-base-font-family',
378
+ 'value' => $options['wcf-base-font-family'],
379
+ )
380
+ );
381
+
382
+ echo wcf()->meta->get_checkbox_field(
383
+ array(
384
+ 'label' => __( 'Advance Options', 'cartflows' ),
385
+ 'name' => 'wcf-advance-options-fields',
386
+ 'value' => $options['wcf-advance-options-fields'],
387
+ 'after' => 'Enable',
388
+ )
389
+ );
390
+ ?>
391
+ </div>
392
+ <div class="wcf-cs-fields-options">
393
+ <?php
394
+ echo wcf()->meta->get_section(
395
+ array(
396
+ 'label' => __( 'Heading', 'cartflows' ),
397
+ )
398
+ );
399
+
400
+ echo wcf()->meta->get_color_picker_field(
401
+ array(
402
+ 'label' => __( 'Heading Color', 'cartflows' ),
403
+ 'name' => 'wcf-heading-color',
404
+ 'value' => $options['wcf-heading-color'],
405
+ )
406
+ );
407
+
408
+ echo wcf()->meta->get_font_family_field(
409
+ array(
410
+ 'for' => 'wcf-heading',
411
+ 'label' => __( 'Font Family', 'cartflows' ),
412
+ 'name' => 'wcf-heading-font-family',
413
+ 'value' => $options['wcf-heading-font-family'],
414
+ )
415
+ );
416
+
417
+ echo wcf()->meta->get_font_weight_field(
418
+ array(
419
+ 'for' => 'wcf-heading',
420
+ 'label' => __( 'Font Weight', 'cartflows' ),
421
+ 'name' => 'wcf-heading-font-weight',
422
+ 'value' => $options['wcf-heading-font-weight'],
423
+ )
424
+ );
425
+
426
+ echo wcf()->meta->get_section(
427
+ array(
428
+ 'label' => __( 'Input Fields', 'cartflows' ),
429
+ )
430
+ );
431
+
432
+ $fields_skin_pro_option = array();
433
+
434
+ if ( ! _is_cartflows_pro() ) {
435
+ $fields_skin_pro_option = array(
436
+ 'skin-one' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ),
437
+ );
438
+ }
439
+
440
+ echo wcf()->meta->get_select_field(
441
+ array(
442
+ 'label' => __( 'Style', 'cartflows' ),
443
+ 'name' => 'wcf-fields-skins',
444
+ 'value' => $options['wcf-fields-skins'],
445
+ 'options' => array(
446
+ 'default' => __( 'Default', 'cartflows' ),
447
+ 'style-one' => __( 'Floating Labels', 'cartflows' ),
448
+ ),
449
+ 'pro-options' => $fields_skin_pro_option,
450
+
451
+ )
452
+ );
453
+
454
+ echo wcf()->meta->get_font_family_field(
455
+ array(
456
+ 'for' => 'wcf-input',
457
+ 'label' => __( 'Font Family', 'cartflows' ),
458
+ 'name' => 'wcf-input-font-family',
459
+ 'value' => $options['wcf-input-font-family'],
460
+ )
461
+ );
462
+
463
+ echo wcf()->meta->get_font_weight_field(
464
+ array(
465
+ 'for' => 'wcf-input',
466
+ 'label' => __( 'Font Weight', 'cartflows' ),
467
+ 'name' => 'wcf-input-font-weight',
468
+ 'value' => $options['wcf-input-font-weight'],
469
+ )
470
+ );
471
+
472
+ echo wcf()->meta->get_select_field(
473
+ array(
474
+ 'label' => __( 'Size', 'cartflows' ),
475
+ 'name' => 'wcf-input-field-size',
476
+ 'value' => $options['wcf-input-field-size'],
477
+ 'options' => array(
478
+ '33px' => __( 'Extra Small', 'cartflows' ),
479
+ '38px' => __( 'Small', 'cartflows' ),
480
+ '44px' => __( 'Medium', 'cartflows' ),
481
+ '58px' => __( 'Large', 'cartflows' ),
482
+ '68px' => __( 'Extra Large', 'cartflows' ),
483
+ 'custom' => __( 'Custom', 'cartflows' ),
484
+ ),
485
+ )
486
+ );
487
+
488
+ echo wcf()->meta->get_number_field(
489
+ array(
490
+ 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
491
+ 'name' => 'wcf-field-tb-padding',
492
+ 'value' => $options['wcf-field-tb-padding'],
493
+ )
494
+ );
495
+
496
+ echo wcf()->meta->get_number_field(
497
+ array(
498
+ 'label' => __( 'Left Right Spacing', 'cartflows' ),
499
+ 'name' => 'wcf-field-lr-padding',
500
+ 'value' => $options['wcf-field-lr-padding'],
501
+ )
502
+ );
503
+
504
+ echo wcf()->meta->get_color_picker_field(
505
+ array(
506
+ 'label' => __( 'Text / Placeholder Color', 'cartflows' ),
507
+ 'name' => 'wcf-field-color',
508
+ 'value' => $options['wcf-field-color'],
509
+ )
510
+ );
511
+
512
+ echo wcf()->meta->get_color_picker_field(
513
+ array(
514
+ 'label' => __( 'Background Color', 'cartflows' ),
515
+ 'name' => 'wcf-field-bg-color',
516
+ 'value' => $options['wcf-field-bg-color'],
517
+ )
518
+ );
519
+
520
+ echo wcf()->meta->get_color_picker_field(
521
+ array(
522
+ 'label' => __( 'Border Color', 'cartflows' ),
523
+ 'name' => 'wcf-field-border-color',
524
+ 'value' => $options['wcf-field-border-color'],
525
+ )
526
+ );
527
+ echo wcf()->meta->get_color_picker_field(
528
+ array(
529
+ 'label' => __( 'Label Color', 'cartflows' ),
530
+ 'name' => 'wcf-field-label-color',
531
+ 'value' => $options['wcf-field-label-color'],
532
+ )
533
+ );
534
+
535
+ ?>
536
+ </div>
537
+ <div class="wcf-cs-button-options">
538
+ <?php
539
+
540
+ echo wcf()->meta->get_section(
541
+ array(
542
+ 'label' => __( 'Buttons', 'cartflows' ),
543
+ )
544
+ );
545
+
546
+ echo wcf()->meta->get_font_family_field(
547
+ array(
548
+ 'for' => 'wcf-button',
549
+ 'label' => __( 'Font Family', 'cartflows' ),
550
+ 'name' => 'wcf-button-font-family',
551
+ 'value' => $options['wcf-button-font-family'],
552
+ )
553
+ );
554
+
555
+ echo wcf()->meta->get_font_weight_field(
556
+ array(
557
+ 'for' => 'wcf-button',
558
+ 'label' => __( 'Font Weight', 'cartflows' ),
559
+ 'name' => 'wcf-button-font-weight',
560
+ 'value' => $options['wcf-button-font-weight'],
561
+ )
562
+ );
563
+
564
+ echo wcf()->meta->get_select_field(
565
+ array(
566
+ 'label' => __( 'Size', 'cartflows' ),
567
+ 'name' => 'wcf-input-button-size',
568
+ 'value' => $options['wcf-input-button-size'],
569
+ 'options' => array(
570
+ '33px' => __( 'Extra Small', 'cartflows' ),
571
+ '38px' => __( 'Small', 'cartflows' ),
572
+ '44px' => __( 'Medium', 'cartflows' ),
573
+ '58px' => __( 'Large', 'cartflows' ),
574
+ '68px' => __( 'Extra Large', 'cartflows' ),
575
+ 'custom' => __( 'Custom', 'cartflows' ),
576
+ ),
577
+ )
578
+ );
579
+
580
+ echo wcf()->meta->get_number_field(
581
+ array(
582
+ 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
583
+ 'name' => 'wcf-submit-tb-padding',
584
+ 'value' => $options['wcf-submit-tb-padding'],
585
+ )
586
+ );
587
+
588
+ echo wcf()->meta->get_number_field(
589
+ array(
590
+ 'label' => __( 'Left Right Spacing', 'cartflows' ),
591
+ 'name' => 'wcf-submit-lr-padding',
592
+ 'value' => $options['wcf-submit-lr-padding'],
593
+ )
594
+ );
595
+
596
+ echo wcf()->meta->get_color_picker_field(
597
+ array(
598
+ 'label' => __( 'Text Color', 'cartflows' ),
599
+ 'name' => 'wcf-submit-color',
600
+ 'value' => $options['wcf-submit-color'],
601
+ )
602
+ );
603
+
604
+ echo wcf()->meta->get_color_picker_field(
605
+ array(
606
+ 'label' => __( 'Text Hover Color', 'cartflows' ),
607
+ 'name' => 'wcf-submit-hover-color',
608
+ 'value' => $options['wcf-submit-hover-color'],
609
+ )
610
+ );
611
+
612
+ echo wcf()->meta->get_color_picker_field(
613
+ array(
614
+ 'label' => __( 'Background Color', 'cartflows' ),
615
+ 'name' => 'wcf-submit-bg-color',
616
+ 'value' => $options['wcf-submit-bg-color'],
617
+ )
618
+ );
619
+
620
+ echo wcf()->meta->get_color_picker_field(
621
+ array(
622
+ 'label' => __( 'Background Hover Color', 'cartflows' ),
623
+ 'name' => 'wcf-submit-bg-hover-color',
624
+ 'value' => $options['wcf-submit-bg-hover-color'],
625
+ )
626
+ );
627
+
628
+ echo wcf()->meta->get_color_picker_field(
629
+ array(
630
+ 'label' => __( 'Border Color', 'cartflows' ),
631
+ 'name' => 'wcf-submit-border-color',
632
+ 'value' => $options['wcf-submit-border-color'],
633
+ )
634
+ );
635
+
636
+ echo wcf()->meta->get_color_picker_field(
637
+ array(
638
+ 'label' => __( 'Border Hover Color', 'cartflows' ),
639
+ 'name' => 'wcf-submit-border-hover-color',
640
+ 'value' => $options['wcf-submit-border-hover-color'],
641
+ )
642
+ );
643
+
644
+ ?>
645
+ </div>
646
+ <div class="wcf-cs-section-options">
647
+ <?php
648
+
649
+ echo wcf()->meta->get_section(
650
+ array(
651
+ 'label' => __( 'Sections', 'cartflows' ),
652
+ )
653
+ );
654
+
655
+ echo wcf()->meta->get_color_picker_field(
656
+ array(
657
+ 'label' => __( 'Highlight Area Background Color', 'cartflows' ),
658
+ 'name' => 'wcf-hl-bg-color',
659
+ 'value' => $options['wcf-hl-bg-color'],
660
+ )
661
+ );
662
+
663
+ echo wcf()->meta->get_hidden_field(
664
+ array(
665
+ 'name' => 'wcf-field-google-font-url',
666
+ 'value' => $options['wcf-field-google-font-url'],
667
+ )
668
+ );
669
+ ?>
670
+ </div>
671
+ <?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
672
+ </div>
673
+ </div>
674
+ <?php
675
+ }
676
+
677
+
678
+ /**
679
+ * Tab Header (Used for add logo into header)
680
+ *
681
+ * @param array $options options.
682
+ * @param int $post_id post ID.
683
+ */
684
+ function tab_header_content( $options, $post_id ) {
685
+ ?>
686
+
687
+ <div class="wcf-checkout-header wcf-tab-content widefat">
688
+ <?php
689
+
690
+ $layout_pro_option = array();
691
+
692
+ echo wcf()->meta->get_image_field(
693
+ array(
694
+ 'name' => 'wcf-header-logo-image',
695
+ 'value' => $options['wcf-header-logo-image'],
696
+ 'label' => __( 'Header Logo', 'cartflows' ),
697
+ )
698
+ );
699
+
700
+ echo wcf()->meta->get_number_field(
701
+ array(
702
+ 'name' => 'wcf-header-logo-width',
703
+ 'value' => $options['wcf-header-logo-width'],
704
+ 'label' => __( 'Logo Width (In px)', 'cartflows' ),
705
+ )
706
+ );
707
+ ?>
708
+ <?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
709
+ </div>
710
+ <?php
711
+ }
712
+ /**
713
+ * Get metabox options
714
+ *
715
+ * @param int $post_id post ID.
716
+ */
717
+ public static function get_meta_option( $post_id ) {
718
+
719
+ if ( null === self::$meta_option ) {
720
+
721
+ /**
722
+ * Set metabox options
723
+ *
724
+ * @see http://php.net/manual/en/filter.filters.sanitize.php
725
+ */
726
+ self::$meta_option = wcf()->options->get_checkout_fields( $post_id );
727
+ }
728
+
729
+ return self::$meta_option;
730
+ }
731
+
732
+ /**
733
+ * Metabox Save
734
+ *
735
+ * @param number $post_id Post ID.
736
+ * @return void
737
+ */
738
+ function save_meta_box( $post_id ) {
739
+
740
+ // Checks save status.
741
+ $is_autosave = wp_is_post_autosave( $post_id );
742
+ $is_revision = wp_is_post_revision( $post_id );
743
+
744
+ $is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( $_POST['nonce-checkout-step-meta'], 'save-nonce-checkout-step-meta' ) ) ? true : false;
745
+
746
+ // Exits script depending on save status.
747
+ if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
748
+ return;
749
+ }
750
+
751
+ wcf()->options->save_checkout_fields( $post_id );
752
+ }
753
+
754
+ }
755
+
756
+ /**
757
+ * Kicking this off by calling 'get_instance()' method
758
+ */
759
+ Cartflows_Checkout_Meta::get_instance();
modules/flow/classes/class-cartflows-step-post-type.php CHANGED
@@ -1,449 +1,449 @@
1
- <?php
2
- /**
3
- * Step post type.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Initialization
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Step_Post_Type {
14
-
15
-
16
- /**
17
- * Member Variable
18
- *
19
- * @var instance
20
- */
21
- private static $instance;
22
-
23
- /**
24
- * Member Variable
25
- *
26
- * @var body_classes
27
- */
28
- private $body_classes = array();
29
-
30
- /**
31
- * Initiator
32
- */
33
- public static function get_instance() {
34
- if ( ! isset( self::$instance ) ) {
35
- self::$instance = new self;
36
- }
37
- return self::$instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- */
43
- public function __construct() {
44
-
45
- add_action( 'init', array( $this, 'step_post_type' ) );
46
- add_action( 'init', array( $this, 'add_wp_templates_support' ) );
47
- add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
48
- add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
49
- add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
50
- add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ) );
51
-
52
- add_filter( 'template_include', array( $this, 'load_page_template' ), 99 );
53
- }
54
-
55
- /**
56
- * Trys to load page.php for a header, footer or part theme layout.
57
- *
58
- * @since 1.0.0
59
- * @param string $template The current template to be loaded.
60
- * @return string
61
- */
62
- function load_page_template( $template ) {
63
-
64
- global $post;
65
-
66
- if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
67
-
68
- /**
69
- * Remove Next/Prev Navigation
70
- * add_filter('next_post_link', '__return_empty_string');
71
- * add_filter('previous_post_link', '__return_empty_string');
72
- *
73
- * $page = locate_template( array( 'page.php' ) );
74
- *
75
- * if ( ! empty( $page ) ) {
76
- * return $page;
77
- * }
78
- */
79
-
80
- $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
81
-
82
- $page_template = apply_filters( 'cartflows_page_template', $page_template );
83
-
84
- $file = '';
85
-
86
- switch ( $page_template ) {
87
-
88
- case 'cartflows-default':
89
- $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
90
- $this->body_classes[] = $page_template;
91
- break;
92
- case 'cartflows-canvas':
93
- $file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
94
- $this->body_classes[] = $page_template;
95
- break;
96
- default:
97
- $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
98
- $this->body_classes[] = 'cartflows-default';
99
- break;
100
- }
101
-
102
- // Just to be safe, we check if the file exist first.
103
- if ( file_exists( $file ) ) {
104
-
105
- /* Add Body Class */
106
- add_filter( 'body_class', [ $this, 'body_class' ] );
107
-
108
- return $file;
109
- } else {
110
- echo $file;
111
- }
112
- }
113
-
114
- return $template;
115
- }
116
-
117
- /**
118
- * Body classes.
119
- *
120
- * @since 1.0.0
121
- * @param array $classes Body classes.
122
- * @return array
123
- */
124
- function body_class( $classes = [] ) {
125
-
126
- $classes = array_merge( $classes, $this->body_classes );
127
-
128
- return $classes;
129
- }
130
-
131
- /**
132
- * Create custom post type
133
- */
134
- function step_post_type() {
135
-
136
- $labels = array(
137
- 'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
138
- 'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
139
- 'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
140
- 'all_items' => esc_html__( 'All Steps', 'cartflows' ),
141
- 'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
142
- 'view_item' => esc_html__( 'View Step', 'cartflows' ),
143
- 'add_new' => esc_html__( 'Add New', 'cartflows' ),
144
- 'update_item' => esc_html__( 'Update Step', 'cartflows' ),
145
- 'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
146
- 'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
147
- );
148
-
149
- $args = array(
150
- 'labels' => $labels,
151
- 'public' => true,
152
- 'query_var' => true,
153
- 'can_export' => true,
154
- 'exclude_from_search' => true,
155
- 'show_ui' => true,
156
- 'show_in_menu' => false,
157
- 'show_in_admin_bar' => true,
158
- 'supports' => array( 'title', 'editor', 'elementor' ),
159
- 'capability_type' => 'post',
160
- 'capabilities' => array(
161
- 'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
162
- ),
163
- 'map_meta_cap' => true,
164
- );
165
-
166
- register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
167
-
168
- $args = array(
169
- 'label' => __( 'Step Type', 'cartflows' ),
170
- 'public' => false,
171
- 'rewrite' => false,
172
- 'hierarchical' => false,
173
- );
174
-
175
- register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
176
-
177
- $args = array(
178
- 'label' => __( 'Step Flow', 'cartflows' ),
179
- 'public' => false,
180
- 'rewrite' => false,
181
- 'hierarchical' => false,
182
- );
183
-
184
- register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
185
-
186
- /**
187
- * Register 'Elementor' & 'Beaver Builder' site types.
188
- *
189
- * @see self::add_terms();
190
- */
191
- $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
192
-
193
- $terms = array(
194
- array(
195
- 'name' => __( 'Landing', 'cartflows' ),
196
- 'args' => array(
197
- 'slug' => 'landing',
198
- ),
199
- ),
200
- array(
201
- 'name' => __( 'Checkout', 'cartflows' ),
202
- 'args' => array(
203
- 'slug' => 'checkout',
204
- ),
205
- ),
206
- array(
207
- 'name' => __( 'Thank You', 'cartflows' ),
208
- 'args' => array(
209
- 'slug' => 'thankyou',
210
- ),
211
- ),
212
- array(
213
- 'name' => __( 'Upsell', 'cartflows' ),
214
- 'args' => array(
215
- 'slug' => 'upsell',
216
- ),
217
- ),
218
- array(
219
- 'name' => __( 'Downsell', 'cartflows' ),
220
- 'args' => array(
221
- 'slug' => 'downsell',
222
- ),
223
- ),
224
- );
225
-
226
- $this->add_terms( $taxonomy, $terms );
227
- }
228
-
229
- /**
230
- * Add WordPress templates.
231
- *
232
- * Adds Cartflows templates to steps
233
- *
234
- * @since 1.0.0
235
- * @access public
236
- */
237
- function add_wp_templates_support() {
238
- add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
239
- }
240
-
241
- /**
242
- * Add page templates.
243
- *
244
- * @since 1.0.0
245
- * @access public
246
- *
247
- * @param array $page_templates Array of page templates.
248
- *
249
- * @param object $wp_theme wp theme.
250
- * @param object $post post.
251
- *
252
- * @return array Page templates.
253
- */
254
- function add_page_templates( $page_templates, $wp_theme, $post ) {
255
-
256
- $page_templates = array(
257
- 'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
258
- );
259
-
260
- return $page_templates;
261
- }
262
-
263
- /**
264
- * Have WordPress match postname to any of our public post types.
265
- * All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
266
- * By default, WordPress only accounts for posts and pages where the slug is /post-name/.
267
- *
268
- * @param string $query query statement.
269
- */
270
- function add_cpt_post_names_to_main_query( $query ) {
271
-
272
- // Bail if this is not the main query.
273
- if ( ! $query->is_main_query() ) {
274
- return;
275
- }
276
- // Bail if this query doesn't match our very specific rewrite rule.
277
- if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
278
- return;
279
- }
280
- // Bail if we're not querying based on the post name.
281
- if ( empty( $query->query['name'] ) ) {
282
- return;
283
- }
284
- // Add CPT to the list of post types WP will include when it queries based on the post name.
285
- $query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
286
- }
287
-
288
- /**
289
- * Modify permalink
290
- *
291
- * @param string $post_link post link.
292
- * @param array $post post data.
293
- * @param string $leavename leave name.
294
- * @return string
295
- */
296
- function post_type_permalinks( $post_link, $post, $leavename ) {
297
-
298
- // If elementor page preview, return post link as it is.
299
- if ( isset( $_REQUEST['elementor-preview'] ) ) {
300
- return $post_link;
301
- }
302
-
303
- $structure = get_option( 'permalink_structure' );
304
-
305
- if ( '/%postname%/' === $structure ) {
306
-
307
- if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
308
-
309
- $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
310
- }
311
- }
312
-
313
- return $post_link;
314
- }
315
-
316
- /**
317
- * Prevent slug duplicated
318
- *
319
- * @param string $slug post slug.
320
- * @param int $post_ID post id.
321
- * @param string $post_status post status.
322
- * @param string $post_type post type.
323
- * @param int $post_parent post parent id.
324
- * @param string $original_slug original slug.
325
- * @return string
326
- */
327
- function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
328
-
329
- $check_post_types = array(
330
- 'post',
331
- 'page',
332
- CARTFLOWS_STEP_POST_TYPE,
333
- );
334
-
335
- if ( ! in_array( $post_type, $check_post_types ) ) {
336
- return $slug;
337
- }
338
-
339
- if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
340
- // Saving a post, check for duplicates in POST or PAGE post types.
341
- $post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
342
- $page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
343
-
344
- if ( $post_match || $page_match ) {
345
- $slug .= '-2';
346
- }
347
- } else {
348
-
349
- // Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
350
- $custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
351
-
352
- if ( $custom_post_type_match ) {
353
- $slug .= '-2';
354
- }
355
- }
356
-
357
- return $slug;
358
- }
359
-
360
- /**
361
- * Add Update messages for any custom post type
362
- *
363
- * @param array $messages Array of default messages.
364
- */
365
- function post_update_messages( $messages ) {
366
-
367
- $custom_post_type = get_post_type( get_the_ID() );
368
-
369
- if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
370
-
371
- $obj = get_post_type_object( $custom_post_type );
372
- $singular_name = $obj->labels->singular_name;
373
- $messages[ $custom_post_type ] = array(
374
- 0 => '', // Unused. Messages start at index 1.
375
- /* translators: %s: singular custom post type name */
376
- 1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
377
- /* translators: %s: singular custom post type name */
378
- 2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
379
- /* translators: %s: singular custom post type name */
380
- 3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
381
- /* translators: %s: singular custom post type name */
382
- 4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
383
- /* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
384
- 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
385
- /* translators: %s: singular custom post type name */
386
- 6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
387
- /* translators: %s: singular custom post type name */
388
- 7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
389
- /* translators: %s: singular custom post type name */
390
- 8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
391
- /* translators: %s: singular custom post type name */
392
- 9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
393
- /* translators: %s: singular custom post type name */
394
- 10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
395
- );
396
- }
397
-
398
- return $messages;
399
- }
400
-
401
- /**
402
- * Add Terms for Taxonomy.
403
- *
404
- * => Example.
405
- *
406
- * $taxonomy = '{taxonomy}';
407
- * $terms = array(
408
- * array(
409
- * 'name' => 'Free',
410
- * ),
411
- * array(
412
- * 'name' => 'Premium',
413
- * ),
414
- * );
415
- *
416
- * self::add_terms( $taxonomy, $terms );
417
- *
418
- * @since 1.0.0
419
- * @param string $taxonomy Taxonomy Name.
420
- * @param array $terms Terms list.
421
- * @return void
422
- */
423
- function add_terms( $taxonomy = '', $terms = array() ) {
424
-
425
- foreach ( $terms as $key => $term ) {
426
-
427
- $term_exist = term_exists( $term['name'], $taxonomy );
428
-
429
- if ( empty( $term_exist ) ) {
430
-
431
- /**
432
- * Add additional args if passed from request.
433
- *
434
- * @see https://codex.wordpress.org/Function_Reference/wp_insert_term
435
- */
436
- if ( array_key_exists( 'args', $term ) ) {
437
- wp_insert_term( $term['name'], $taxonomy, $term['args'] );
438
- } else {
439
- wp_insert_term( $term['name'], $taxonomy );
440
- }
441
- }
442
- }
443
- }
444
- }
445
-
446
- /**
447
- * Kicking this off by calling 'get_instance()' method
448
- */
449
- Cartflows_Step_Post_Type::get_instance();
1
+ <?php
2
+ /**
3
+ * Step post type.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Initialization
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Step_Post_Type {
14
+
15
+
16
+ /**
17
+ * Member Variable
18
+ *
19
+ * @var instance
20
+ */
21
+ private static $instance;
22
+
23
+ /**
24
+ * Member Variable
25
+ *
26
+ * @var body_classes
27
+ */
28
+ private $body_classes = array();
29
+
30
+ /**
31
+ * Initiator
32
+ */
33
+ public static function get_instance() {
34
+ if ( ! isset( self::$instance ) ) {
35
+ self::$instance = new self;
36
+ }
37
+ return self::$instance;
38
+ }
39
+
40
+ /**
41
+ * Constructor
42
+ */
43
+ public function __construct() {
44
+
45
+ add_action( 'init', array( $this, 'step_post_type' ) );
46
+ add_action( 'init', array( $this, 'add_wp_templates_support' ) );
47
+ add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
48
+ add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
49
+ add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
50
+ add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ) );
51
+
52
+ add_filter( 'template_include', array( $this, 'load_page_template' ), 99 );
53
+ }
54
+
55
+ /**
56
+ * Trys to load page.php for a header, footer or part theme layout.
57
+ *
58
+ * @since 1.0.0
59
+ * @param string $template The current template to be loaded.
60
+ * @return string
61
+ */
62
+ function load_page_template( $template ) {
63
+
64
+ global $post;
65
+
66
+ if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
67
+
68
+ /**
69
+ * Remove Next/Prev Navigation
70
+ * add_filter('next_post_link', '__return_empty_string');
71
+ * add_filter('previous_post_link', '__return_empty_string');
72
+ *
73
+ * $page = locate_template( array( 'page.php' ) );
74
+ *
75
+ * if ( ! empty( $page ) ) {
76
+ * return $page;
77
+ * }
78
+ */
79
+
80
+ $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
81
+
82
+ $page_template = apply_filters( 'cartflows_page_template', $page_template );
83
+
84
+ $file = '';
85
+
86
+ switch ( $page_template ) {
87
+
88
+ case 'cartflows-default':
89
+ $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
90
+ $this->body_classes[] = $page_template;
91
+ break;
92
+ case 'cartflows-canvas':
93
+ $file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
94
+ $this->body_classes[] = $page_template;
95
+ break;
96
+ default:
97
+ $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
98
+ $this->body_classes[] = 'cartflows-default';
99
+ break;
100
+ }
101
+
102
+ // Just to be safe, we check if the file exist first.
103
+ if ( file_exists( $file ) ) {
104
+
105
+ /* Add Body Class */
106
+ add_filter( 'body_class', [ $this, 'body_class' ] );
107
+
108
+ return $file;
109
+ } else {
110
+ echo $file;
111
+ }
112
+ }
113
+
114
+ return $template;
115
+ }
116
+
117
+ /**
118
+ * Body classes.
119
+ *
120
+ * @since 1.0.0
121
+ * @param array $classes Body classes.
122
+ * @return array
123
+ */
124
+ function body_class( $classes = [] ) {
125
+
126
+ $classes = array_merge( $classes, $this->body_classes );
127
+
128
+ return $classes;
129
+ }
130
+
131
+ /**
132
+ * Create custom post type
133
+ */
134
+ function step_post_type() {
135
+
136
+ $labels = array(
137
+ 'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
138
+ 'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
139
+ 'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
140
+ 'all_items' => esc_html__( 'All Steps', 'cartflows' ),
141
+ 'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
142
+ 'view_item' => esc_html__( 'View Step', 'cartflows' ),
143
+ 'add_new' => esc_html__( 'Add New', 'cartflows' ),
144
+ 'update_item' => esc_html__( 'Update Step', 'cartflows' ),
145
+ 'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
146
+ 'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
147
+ );
148
+
149
+ $args = array(
150
+ 'labels' => $labels,
151
+ 'public' => true,
152
+ 'query_var' => true,
153
+ 'can_export' => true,
154
+ 'exclude_from_search' => true,
155
+ 'show_ui' => true,
156
+ 'show_in_menu' => false,
157
+ 'show_in_admin_bar' => true,
158
+ 'supports' => array( 'title', 'editor', 'elementor' ),
159
+ 'capability_type' => 'post',
160
+ 'capabilities' => array(
161
+ 'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
162
+ ),
163
+ 'map_meta_cap' => true,
164
+ );
165
+
166
+ register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
167
+
168
+ $args = array(
169
+ 'label' => __( 'Step Type', 'cartflows' ),
170
+ 'public' => false,
171
+ 'rewrite' => false,
172
+ 'hierarchical' => false,
173
+ );
174
+
175
+ register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
176
+
177
+ $args = array(
178
+ 'label' => __( 'Step Flow', 'cartflows' ),
179
+ 'public' => false,
180
+ 'rewrite' => false,
181
+ 'hierarchical' => false,
182
+ );
183
+
184
+ register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
185
+
186
+ /**
187
+ * Register 'Elementor' & 'Beaver Builder' site types.
188
+ *
189
+ * @see self::add_terms();
190
+ */
191
+ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
192
+
193
+ $terms = array(
194
+ array(
195
+ 'name' => __( 'Landing', 'cartflows' ),
196
+ 'args' => array(
197
+ 'slug' => 'landing',
198
+ ),
199
+ ),
200
+ array(
201
+ 'name' => __( 'Checkout', 'cartflows' ),
202
+ 'args' => array(
203
+ 'slug' => 'checkout',
204
+ ),
205
+ ),
206
+ array(
207
+ 'name' => __( 'Thank You', 'cartflows' ),
208
+ 'args' => array(
209
+ 'slug' => 'thankyou',
210
+ ),
211
+ ),
212
+ array(
213
+ 'name' => __( 'Upsell', 'cartflows' ),
214
+ 'args' => array(
215
+ 'slug' => 'upsell',
216
+ ),
217
+ ),
218
+ array(
219
+ 'name' => __( 'Downsell', 'cartflows' ),
220
+ 'args' => array(
221
+ 'slug' => 'downsell',
222
+ ),
223
+ ),
224
+ );
225
+
226
+ $this->add_terms( $taxonomy, $terms );
227
+ }
228
+
229
+ /**
230
+ * Add WordPress templates.
231
+ *
232
+ * Adds Cartflows templates to steps
233
+ *
234
+ * @since 1.0.0
235
+ * @access public
236
+ */
237
+ function add_wp_templates_support() {
238
+ add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
239
+ }
240
+
241
+ /**
242
+ * Add page templates.
243
+ *
244
+ * @since 1.0.0
245
+ * @access public
246
+ *
247
+ * @param array $page_templates Array of page templates.
248
+ *
249
+ * @param object $wp_theme wp theme.
250
+ * @param object $post post.
251
+ *
252
+ * @return array Page templates.
253
+ */
254
+ function add_page_templates( $page_templates, $wp_theme, $post ) {
255
+
256
+ $page_templates = array(
257
+ 'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
258
+ );
259
+
260
+ return $page_templates;
261
+ }
262
+
263
+ /**
264
+ * Have WordPress match postname to any of our public post types.
265
+ * All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
266
+ * By default, WordPress only accounts for posts and pages where the slug is /post-name/.
267
+ *
268
+ * @param string $query query statement.
269
+ */
270
+ function add_cpt_post_names_to_main_query( $query ) {
271
+
272
+ // Bail if this is not the main query.
273
+ if ( ! $query->is_main_query() ) {
274
+ return;
275
+ }
276
+ // Bail if this query doesn't match our very specific rewrite rule.
277
+ if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
278
+ return;
279
+ }
280
+ // Bail if we're not querying based on the post name.
281
+ if ( empty( $query->query['name'] ) ) {
282
+ return;
283
+ }
284
+ // Add CPT to the list of post types WP will include when it queries based on the post name.
285
+ $query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
286
+ }
287
+
288
+ /**
289
+ * Modify permalink
290
+ *
291
+ * @param string $post_link post link.
292
+ * @param array $post post data.
293
+ * @param string $leavename leave name.
294
+ * @return string
295
+ */
296
+ function post_type_permalinks( $post_link, $post, $leavename ) {
297
+
298
+ // If elementor page preview, return post link as it is.
299
+ if ( isset( $_REQUEST['elementor-preview'] ) ) {
300
+ return $post_link;
301
+ }
302
+
303
+ $structure = get_option( 'permalink_structure' );
304
+
305
+ if ( '/%postname%/' === $structure ) {
306
+
307
+ if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
308
+
309
+ $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
310
+ }
311
+ }
312
+
313
+ return $post_link;
314
+ }
315
+
316
+ /**
317
+ * Prevent slug duplicated
318
+ *
319
+ * @param string $slug post slug.
320
+ * @param int $post_ID post id.
321
+ * @param string $post_status post status.
322
+ * @param string $post_type post type.
323
+ * @param int $post_parent post parent id.
324
+ * @param string $original_slug original slug.
325
+ * @return string
326
+ */
327
+ function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
328
+
329
+ $check_post_types = array(
330
+ 'post',
331
+ 'page',
332
+ CARTFLOWS_STEP_POST_TYPE,
333
+ );
334
+
335
+ if ( ! in_array( $post_type, $check_post_types ) ) {
336
+ return $slug;
337
+ }
338
+
339
+ if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
340
+ // Saving a post, check for duplicates in POST or PAGE post types.
341
+ $post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
342
+ $page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
343
+
344
+ if ( $post_match || $page_match ) {
345
+ $slug .= '-2';
346
+ }
347
+ } else {
348
+
349
+ // Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
350
+ $custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
351
+
352
+ if ( $custom_post_type_match ) {
353
+ $slug .= '-2';
354
+ }
355
+ }
356
+
357
+ return $slug;
358
+ }
359
+
360
+ /**
361
+ * Add Update messages for any custom post type
362
+ *
363
+ * @param array $messages Array of default messages.
364
+ */
365
+ function post_update_messages( $messages ) {
366
+
367
+ $custom_post_type = get_post_type( get_the_ID() );
368
+
369
+ if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
370
+
371
+ $obj = get_post_type_object( $custom_post_type );
372
+ $singular_name = $obj->labels->singular_name;
373
+ $messages[ $custom_post_type ] = array(
374
+ 0 => '', // Unused. Messages start at index 1.
375
+ /* translators: %s: singular custom post type name */
376
+ 1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
377
+ /* translators: %s: singular custom post type name */
378
+ 2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
379
+ /* translators: %s: singular custom post type name */
380
+ 3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
381
+ /* translators: %s: singular custom post type name */
382
+ 4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
383
+ /* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
384
+ 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
385
+ /* translators: %s: singular custom post type name */
386
+ 6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
387
+ /* translators: %s: singular custom post type name */
388
+ 7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
389
+ /* translators: %s: singular custom post type name */
390
+ 8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
391
+ /* translators: %s: singular custom post type name */
392
+ 9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
393
+ /* translators: %s: singular custom post type name */
394
+ 10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
395
+ );
396
+ }
397
+
398
+ return $messages;
399
+ }
400
+
401
+ /**
402
+ * Add Terms for Taxonomy.
403
+ *
404
+ * => Example.
405
+ *
406
+ * $taxonomy = '{taxonomy}';
407
+ * $terms = array(
408
+ * array(
409
+ * 'name' => 'Free',
410
+ * ),
411
+ * array(
412
+ * 'name' => 'Premium',
413
+ * ),
414
+ * );
415
+ *
416
+ * self::add_terms( $taxonomy, $terms );
417
+ *
418
+ * @since 1.0.0
419
+ * @param string $taxonomy Taxonomy Name.
420
+ * @param array $terms Terms list.
421
+ * @return void
422
+ */
423
+ function add_terms( $taxonomy = '', $terms = array() ) {
424
+
425
+ foreach ( $terms as $key => $term ) {
426
+
427
+ $term_exist = term_exists( $term['name'], $taxonomy );
428
+
429
+ if ( empty( $term_exist ) ) {
430
+
431
+ /**
432
+ * Add additional args if passed from request.
433
+ *
434
+ * @see https://codex.wordpress.org/Function_Reference/wp_insert_term
435
+ */
436
+ if ( array_key_exists( 'args', $term ) ) {
437
+ wp_insert_term( $term['name'], $taxonomy, $term['args'] );
438
+ } else {
439
+ wp_insert_term( $term['name'], $taxonomy );
440
+ }
441
+ }
442
+ }
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Kicking this off by calling 'get_instance()' method
448
+ */
449
+ Cartflows_Step_Post_Type::get_instance();
modules/flow/view/meta-flow-steps.php CHANGED
@@ -1,147 +1,168 @@
1
- <?php
2
- /**
3
- * View Flow steps
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- $get_steps = array(
9
- 'landing' => __( 'Landing', 'cartflows' ),
10
- 'checkout' => __( 'Checkout', 'cartflows' ),
11
- 'thankyou' => __( 'Thank You', 'cartflows' ),
12
- 'upsell' => __( 'Upsell', 'cartflows' ),
13
- 'downsell' => __( 'Downsell', 'cartflows' ),
14
-
15
- );
16
-
17
- ?>
18
- <div class="wcf-flow-steps-meta-box">
19
- <div class="wcf-flow-settings">
20
- <?php do_action( 'cartflows_above_flow_steps' ); ?>
21
- <div class="wcf-flow-steps-wrap">
22
- <div class="wcf-flow-steps-container">
23
- <?php if ( is_array( $options['steps'] ) ) { ?>
24
- <?php foreach ( $options['steps'] as $index => $data ) { ?>
25
- <?php
26
- $term_slug = '';
27
- $term_name = '';
28
- $step_wrap_class = '';
29
- $has_product_assigned = true;
30
-
31
- if ( isset( $data['type'] ) ) {
32
- $term_slug = $data['type'];
33
- $term_name = $get_steps[ $data['type'] ];
34
- }
35
-
36
- if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
37
- $step_wrap_class .= ' invalid-step';
38
- }
39
-
40
- if ( isset( $_GET['highlight-step-id'] ) && $_GET['highlight-step-id'] == $data['id'] ) {
41
- $step_wrap_class .= ' wcf-new-step-highlight';
42
- }
43
-
44
- if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
45
-
46
- $has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
47
-
48
- if ( ! $has_product_assigned ) {
49
- $step_wrap_class .= ' wcf-no-product-step';
50
- }
51
- }
52
-
53
- ?>
54
- <div class="wcf-step-wrap <?php echo $step_wrap_class; ?>" data-id="<?php echo $data['id']; ?>" data-term-slug="<?php echo esc_attr( $term_slug ); ?>">
55
- <div class="wcf-step">
56
- <div class="wcf-step-left-content">
57
- <span class="dashicons dashicons-menu"></span>
58
- <span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
59
- <span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
60
-
61
- <?php
62
- if ( ! $has_product_assigned ) {
63
- ?>
64
- <span class="wcf-no-product-badge"><?php _e( 'No Product Assigned', 'cartflows' ); ?></span>
65
- <?php
66
- }
67
-
68
- ?>
69
- <input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
70
- </div>
71
- <div class="wcf-steps-action-buttons">
72
- <a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'View Step', 'cartflows' ); ?>" >
73
- <span class="dashicons dashicons-visibility"></span>
74
- <span class="wcf-step-act-btn-text">View</span>
75
- </a>
76
- <a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Edit Step', 'cartflows' ); ?>" >
77
- <span class="dashicons dashicons-edit"></span>
78
- <span class="wcf-step-act-btn-text">Edit</span>
79
- </a>
80
- <a href="<?php echo wp_nonce_url( 'admin.php?action=cartflows_clone_step&post=' . $data['id'], 'step_clone', 'step_clone_nonce' ); ?>" class="wcf-step-clone wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
81
- <span class="dashicons dashicons-admin-page"></span>
82
- <span class="wcf-step-act-btn-text">Clone</span>
83
- </a>
84
- <a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
85
- <span class="dashicons dashicons-trash"></span>
86
- <span class="wcf-step-act-btn-text">Delete</span>
87
- </a>
88
- </div>
89
- </div>
90
- </div><!-- .wcf-step-wrap -->
91
- <?php } ?>
92
- <?php } ?>
93
- </div><!-- .wcf-flow-steps-container -->
94
- </div> <!-- .wcf-flow-steps-wrap -->
95
- <div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
96
- <?php do_action( 'cartflows_bellow_flow_steps' ); ?>
97
- <div class='wcf-add-new-step-btn-wrap'>
98
- <button class='wcf-trigger-popup button button-primary'>
99
- <?php echo __( 'Add New Step', 'cartflows' ); ?>
100
- </button>
101
- </div>
102
- </div><!-- .wcf-flow-buttons-wrap -->
103
- </div><!-- .wcf-flow-settings -->
104
-
105
- <div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
106
- <div class="wcf-templates-popup-content">
107
- <div class="spinner"></div>
108
- <div class="wcf-templates-wrap wcf-templates-wrap-flows">
109
-
110
- <div id="wcf-remote-step-actions" class="wcf-template-header">
111
- <div class="wcf-template-logo-wrap">
112
- <span class="wcf-cartflows-logo-img">
113
- <span class="cartflows-icon"></span>
114
- </span>
115
- <span class="wcf-cartflows-title"><?php _e( 'Templates', 'cartflows' ); ?></span>
116
- </div>
117
- <div class="wcf-tab-wrapper">
118
- <div id="wcf-page-builders">
119
- <ul class="wcf-page-builder-links filter-links">
120
- <li><a href="#" class="current" data-id="elementor"><?php _e( 'Elementor', 'cartflows' ); ?></a></li>
121
- <li><a href="#" data-id="divi"><?php _e( 'Divi', 'cartflows' ); ?></a></li>
122
- <li><a href="#" data-id="bb"><?php _e( 'Beaver Builder', 'cartflows' ); ?></a></li>
123
- </ul>
124
- </div>
125
- </div>
126
- <div class="wcf-popup-close-wrap">
127
- <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
128
- </div>
129
- </div>
130
-
131
- <!--<div class="wcf-search-form">
132
- <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
133
- <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
134
- </div>-->
135
- <?php if ( ! _is_cartflows_pro() ) { ?>
136
- <div class="wcf-template-notice"><p><?php echo __( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
137
- <?php } ?>
138
- <div id="wcf-remote-content">
139
- <div id="wcf-remote-step-filters"></div>
140
- <div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"></div>
141
- <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
142
- </div>
143
- </div>
144
- </div>
145
- </div><!-- .wcf-templates-popup-overlay -->
146
- </div>
147
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * View Flow steps
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ $get_steps = array(
9
+ 'landing' => __( 'Landing', 'cartflows' ),
10
+ 'checkout' => __( 'Checkout', 'cartflows' ),
11
+ 'thankyou' => __( 'Thank You', 'cartflows' ),
12
+ 'upsell' => __( 'Upsell', 'cartflows' ),
13
+ 'downsell' => __( 'Downsell', 'cartflows' ),
14
+
15
+ );
16
+
17
+ ?>
18
+ <div class="wcf-flow-steps-meta-box">
19
+ <div class="wcf-flow-settings">
20
+ <?php do_action( 'cartflows_above_flow_steps' ); ?>
21
+ <div class="wcf-flow-steps-wrap">
22
+ <div class="wcf-flow-steps-container">
23
+ <?php if ( is_array( $options['steps'] ) ) { ?>
24
+ <?php foreach ( $options['steps'] as $index => $data ) { ?>
25
+ <?php
26
+ $term_slug = '';
27
+ $term_name = '';
28
+ $step_wrap_class = '';
29
+ $has_product_assigned = true;
30
+ $is_global_checkout = '';
31
+ $common = '';
32
+
33
+ if ( isset( $data['type'] ) ) {
34
+ $term_slug = $data['type'];
35
+ $term_name = $get_steps[ $data['type'] ];
36
+ }
37
+
38
+ if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
39
+ $step_wrap_class .= ' invalid-step';
40
+ }
41
+
42
+ if ( isset( $_GET['highlight-step-id'] ) && $_GET['highlight-step-id'] == $data['id'] ) {
43
+ $step_wrap_class .= ' wcf-new-step-highlight';
44
+ }
45
+
46
+ if ( 'checkout' === $term_slug ) {
47
+
48
+ $common = Cartflows_Helper::get_common_settings();
49
+
50
+ $is_global_checkout = (int) $common['global_checkout'];
51
+
52
+ if ( $data['id'] === $is_global_checkout ) {
53
+ $step_wrap_class .= ' wcf-global-checkout';
54
+ }
55
+ }
56
+
57
+ if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
58
+
59
+ $has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
60
+
61
+ if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
62
+ $step_wrap_class .= ' wcf-no-product-step';
63
+ }
64
+ }
65
+
66
+ ?>
67
+ <div class="wcf-step-wrap <?php echo $step_wrap_class; ?>" data-id="<?php echo $data['id']; ?>" data-term-slug="<?php echo esc_attr( $term_slug ); ?>">
68
+ <div class="wcf-step">
69
+ <div class="wcf-step-left-content">
70
+ <span class="dashicons dashicons-menu"></span>
71
+ <span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
72
+ <span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
73
+
74
+ <?php
75
+ if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
76
+ ?>
77
+ <span class="wcf-no-product-badge"><?php _e( 'No Product Assigned', 'cartflows' ); ?></span>
78
+ <?php
79
+ } elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) {
80
+ ?>
81
+ <span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span>
82
+ <?php
83
+ } elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) {
84
+ ?>
85
+ <span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout', 'cartflows' ); ?></span>
86
+ <?php
87
+ }
88
+ ?>
89
+
90
+ <input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
91
+ </div>
92
+ <div class="wcf-steps-action-buttons">
93
+ <a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'View Step', 'cartflows' ); ?>" >
94
+ <span class="dashicons dashicons-visibility"></span>
95
+ <span class="wcf-step-act-btn-text">View</span>
96
+ </a>
97
+ <a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Edit Step', 'cartflows' ); ?>" >
98
+ <span class="dashicons dashicons-edit"></span>
99
+ <span class="wcf-step-act-btn-text">Edit</span>
100
+ </a>
101
+ <a href="<?php echo wp_nonce_url( 'admin.php?action=cartflows_clone_step&post=' . $data['id'], 'step_clone', 'step_clone_nonce' ); ?>" class="wcf-step-clone wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
102
+ <span class="dashicons dashicons-admin-page"></span>
103
+ <span class="wcf-step-act-btn-text">Clone</span>
104
+ </a>
105
+ <a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
106
+ <span class="dashicons dashicons-trash"></span>
107
+ <span class="wcf-step-act-btn-text">Delete</span>
108
+ </a>
109
+ </div>
110
+ </div>
111
+ </div><!-- .wcf-step-wrap -->
112
+ <?php } ?>
113
+ <?php } ?>
114
+ </div><!-- .wcf-flow-steps-container -->
115
+ </div> <!-- .wcf-flow-steps-wrap -->
116
+ <div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
117
+ <?php do_action( 'cartflows_bellow_flow_steps' ); ?>
118
+ <div class='wcf-add-new-step-btn-wrap'>
119
+ <button class='wcf-trigger-popup button button-primary'>
120
+ <?php echo __( 'Add New Step', 'cartflows' ); ?>
121
+ </button>
122
+ </div>
123
+ </div><!-- .wcf-flow-buttons-wrap -->
124
+ </div><!-- .wcf-flow-settings -->
125
+
126
+ <div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
127
+ <div class="wcf-templates-popup-content">
128
+ <div class="spinner"></div>
129
+ <div class="wcf-templates-wrap wcf-templates-wrap-flows">
130
+
131
+ <div id="wcf-remote-step-actions" class="wcf-template-header">
132
+ <div class="wcf-template-logo-wrap">
133
+ <span class="wcf-cartflows-logo-img">
134
+ <span class="cartflows-icon"></span>
135
+ </span>
136
+ <span class="wcf-cartflows-title"><?php _e( 'Templates', 'cartflows' ); ?></span>
137
+ </div>
138
+ <div class="wcf-tab-wrapper">
139
+ <div id="wcf-page-builders">
140
+ <ul class="wcf-page-builder-links filter-links">
141
+ <li><a href="#" class="current" data-id="elementor"><?php _e( 'Elementor', 'cartflows' ); ?></a></li>
142
+ <li><a href="#" data-id="divi"><?php _e( 'Divi', 'cartflows' ); ?></a></li>
143
+ <li><a href="#" data-id="bb"><?php _e( 'Beaver Builder', 'cartflows' ); ?></a></li>
144
+ </ul>
145
+ </div>
146
+ </div>
147
+ <div class="wcf-popup-close-wrap">
148
+ <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
149
+ </div>
150
+ </div>
151
+
152
+ <!--<div class="wcf-search-form">
153
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
154
+ <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
155
+ </div>-->
156
+ <?php if ( ! _is_cartflows_pro() ) { ?>
157
+ <div class="wcf-template-notice"><p><?php echo __( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
158
+ <?php } ?>
159
+ <div id="wcf-remote-content">
160
+ <div id="wcf-remote-step-filters"></div>
161
+ <div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"></div>
162
+ <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
163
+ </div>
164
+ </div>
165
+ </div>
166
+ </div><!-- .wcf-templates-popup-overlay -->
167
+ </div>
168
+ <?php
modules/thankyou/classes/class-cartflows-thankyou-markup.php CHANGED
@@ -1,242 +1,260 @@
1
- <?php
2
- /**
3
- * Front end and markup
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Checkout Markup
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Thankyou_Markup {
14
-
15
- /**
16
- * Member Variable
17
- *
18
- * @var object instance
19
- */
20
- private static $instance;
21
-
22
- /**
23
- * Initiator
24
- */
25
- public static function get_instance() {
26
- if ( ! isset( self::$instance ) ) {
27
- self::$instance = new self;
28
- }
29
- return self::$instance;
30
- }
31
-
32
- /**
33
- * Constructor
34
- */
35
- public function __construct() {
36
-
37
- /* Downsell Shortcode */
38
- add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
39
-
40
- add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
41
- }
42
-
43
- /**
44
- * Order shortcode markup
45
- *
46
- * @param array $atts attributes.
47
- * @since 1.0.0
48
- */
49
- function cartflows_order_details_shortcode_markup( $atts ) {
50
-
51
- $output = '';
52
-
53
- if ( _is_wcf_thankyou_type() ) {
54
-
55
- /* Remove order item link */
56
- add_filter( 'woocommerce_order_item_permalink', '__return_false' );
57
-
58
- if ( ! function_exists( 'wc_print_notices' ) ) {
59
- return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
60
- }
61
-
62
- wc_print_notices();
63
-
64
- $order = false;
65
-
66
- if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
67
-
68
- $args = array(
69
- 'limit' => 1,
70
- 'order' => 'DESC',
71
- 'status' => array( 'completed', 'processing' ),
72
- );
73
-
74
- $latest_order = wc_get_orders( $args );
75
-
76
- $order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
77
-
78
- if ( $order_id > 0 ) {
79
-
80
- $order = wc_get_order( $order_id );
81
-
82
- if ( ! $order ) {
83
- $order = false;
84
- }
85
- }
86
- } else {
87
- if ( ! isset( $_GET['wcf-order'] ) ) {
88
- return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
89
- }
90
-
91
- // Get the order.
92
- $order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
93
- $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) ); // WPCS: input var ok, CSRF ok.
94
-
95
- if ( $order_id > 0 ) {
96
-
97
- $order = wc_get_order( $order_id );
98
-
99
- if ( ! $order || $order->get_order_key() !== $order_key ) {
100
- $order = false;
101
- }
102
- }
103
- }
104
-
105
- // Empty awaiting payment session.
106
- unset( WC()->session->order_awaiting_payment );
107
-
108
- // Empty current cart.
109
- wc_empty_cart();
110
-
111
- ob_start();
112
- echo "<div class='wcf-thankyou-wrap'>";
113
- wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
114
- echo '</div>';
115
- $output = ob_get_clean();
116
- }
117
-
118
- return $output;
119
- }
120
-
121
- /**
122
- * Load Thank You scripts.
123
- *
124
- * @return void
125
- */
126
- function thank_you_scripts() {
127
-
128
- if ( _is_wcf_thankyou_type() ) {
129
-
130
- do_action( 'cartflows_thank_you_scripts' );
131
-
132
- $style = $this->generate_thank_you_style();
133
-
134
- wp_add_inline_style( 'wcf-frontend-global', $style );
135
- }
136
- }
137
-
138
-
139
- /**
140
- * Generate Thank You Styles.
141
- *
142
- * @return string
143
- */
144
- function generate_thank_you_style() {
145
-
146
- global $post;
147
-
148
- if ( _is_wcf_thankyou_type() ) {
149
- $thank_you_id = $post->ID;
150
- } else {
151
- $thank_you_id = _get_wcf_thankyou_id( $post->post_content );
152
- }
153
-
154
- CartFlows_Font_Families::render_fonts( $thank_you_id );
155
-
156
- $text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' );
157
- $text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' );
158
- $heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' );
159
- $heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' );
160
- $heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' );
161
- $container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' );
162
- $section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' );
163
-
164
- $show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' );
165
-
166
- $show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' );
167
-
168
- $show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' );
169
-
170
- $show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' );
171
-
172
- $output = "
173
- .wcf-thankyou-wrap{
174
- color: {$text_color};
175
- font-family: {$text_font_family};
176
- max-width:{$container_width}px;
177
- }
178
-
179
- .woocommerce-order h2.woocommerce-column__title,
180
- .woocommerce-order h2.woocommerce-order-details__title,
181
- .woocommerce-order .woocommerce-thankyou-order-received,
182
- .woocommerce-order-details h2 {
183
- color: {$heading_text_color};
184
- font-family: {$heading_font_family};
185
- font-weight: {$heading_font_weight};
186
- }
187
-
188
- .woocommerce-order ul.order_details,
189
- .woocommerce-order .woocommerce-order-details,
190
- .woocommerce-order .woocommerce-customer-details{
191
- background-color: {$section_bg_color}
192
- }
193
- ";
194
-
195
- if ( 'no' == $show_order_review ) {
196
- $output .= '
197
- .woocommerce-order ul.order_details{
198
- display: none;
199
- }
200
- ';
201
- }
202
-
203
- if ( 'no' == $show_order_details ) {
204
- $output .= '
205
- .woocommerce-order .woocommerce-order-details{
206
- display: none;
207
- }
208
- ';
209
- }
210
-
211
- if ( 'no' == $show_billing_details ) {
212
- $output .= '
213
- .woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
214
- display: none;
215
- }
216
- ';
217
- }
218
-
219
- if ( 'no' == $show_shipping_details ) {
220
- $output .= '
221
- .woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
222
- display: none;
223
- }
224
- ';
225
- }
226
-
227
- if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
228
- $output .= '
229
- .woocommerce-order .woocommerce-customer-details{
230
- display: none;
231
- }
232
- ';
233
- }
234
-
235
- return $output;
236
- }
237
- }
238
-
239
- /**
240
- * Kicking this off by calling 'get_instance()' method
241
- */
242
- Cartflows_Thankyou_Markup::get_instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Front end and markup
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Checkout Markup
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Thankyou_Markup {
14
+
15
+ /**
16
+ * Member Variable
17
+ *
18
+ * @var object instance
19
+ */
20
+ private static $instance;
21
+
22
+ /**
23
+ * Initiator
24
+ */
25
+ public static function get_instance() {
26
+ if ( ! isset( self::$instance ) ) {
27
+ self::$instance = new self;
28
+ }
29
+ return self::$instance;
30
+ }
31
+
32
+ /**
33
+ * Constructor
34
+ */
35
+ public function __construct() {
36
+
37
+ /* Downsell Shortcode */
38
+ add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
39
+
40
+ add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
41
+
42
+ add_action( 'woocommerce_is_order_received_page', array( $this, 'set_order_received_page' ) );
43
+
44
+ }
45
+
46
+ /**
47
+ * Order shortcode markup
48
+ *
49
+ * @param array $atts attributes.
50
+ * @since 1.0.0
51
+ */
52
+ function cartflows_order_details_shortcode_markup( $atts ) {
53
+
54
+ $output = '';
55
+
56
+ if ( _is_wcf_thankyou_type() ) {
57
+
58
+ /* Remove order item link */
59
+ add_filter( 'woocommerce_order_item_permalink', '__return_false' );
60
+
61
+ if ( ! function_exists( 'wc_print_notices' ) ) {
62
+ return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
63
+ }
64
+
65
+ wc_print_notices();
66
+
67
+ $order = false;
68
+
69
+ if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
70
+
71
+ $args = array(
72
+ 'limit' => 1,
73
+ 'order' => 'DESC',
74
+ 'status' => array( 'completed', 'processing' ),
75
+ );
76
+
77
+ $latest_order = wc_get_orders( $args );
78
+
79
+ $order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
80
+
81
+ if ( $order_id > 0 ) {
82
+
83
+ $order = wc_get_order( $order_id );
84
+
85
+ if ( ! $order ) {
86
+ $order = false;
87
+ }
88
+ }
89
+ } else {
90
+ if ( ! isset( $_GET['wcf-order'] ) ) {
91
+ return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
92
+ }
93
+
94
+ // Get the order.
95
+ $order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
96
+ $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) ); // WPCS: input var ok, CSRF ok.
97
+
98
+ if ( $order_id > 0 ) {
99
+
100
+ $order = wc_get_order( $order_id );
101
+
102
+ if ( ! $order || $order->get_order_key() !== $order_key ) {
103
+ $order = false;
104
+ }
105
+ }
106
+ }
107
+
108
+ // Empty awaiting payment session.
109
+ unset( WC()->session->order_awaiting_payment );
110
+
111
+ // Empty current cart.
112
+ wc_empty_cart();
113
+
114
+ ob_start();
115
+ echo "<div class='wcf-thankyou-wrap'>";
116
+ wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
117
+ echo '</div>';
118
+ $output = ob_get_clean();
119
+ }
120
+
121
+ return $output;
122
+ }
123
+
124
+ /**
125
+ * Load Thank You scripts.
126
+ *
127
+ * @return void
128
+ */
129
+ function thank_you_scripts() {
130
+
131
+ if ( _is_wcf_thankyou_type() ) {
132
+
133
+ do_action( 'cartflows_thank_you_scripts' );
134
+
135
+ $style = $this->generate_thank_you_style();
136
+
137
+ wp_add_inline_style( 'wcf-frontend-global', $style );
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Set thank you as a order received page.
143
+ *
144
+ * @param boolean $is_order_page order page.
145
+ * @return boolean
146
+ */
147
+ function set_order_received_page( $is_order_page ) {
148
+
149
+ if ( _is_wcf_thankyou_type() ) {
150
+
151
+ $is_order_page = true;
152
+ }
153
+
154
+ return $is_order_page;
155
+ }
156
+
157
+ /**
158
+ * Generate Thank You Styles.
159
+ *
160
+ * @return string
161
+ */
162
+ function generate_thank_you_style() {
163
+
164
+ global $post;
165
+
166
+ if ( _is_wcf_thankyou_type() ) {
167
+ $thank_you_id = $post->ID;
168
+ } else {
169
+ $thank_you_id = _get_wcf_thankyou_id( $post->post_content );
170
+ }
171
+
172
+ CartFlows_Font_Families::render_fonts( $thank_you_id );
173
+
174
+ $text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' );
175
+ $text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' );
176
+ $heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' );
177
+ $heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' );
178
+ $heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' );
179
+ $container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' );
180
+ $section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' );
181
+
182
+ $show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' );
183
+
184
+ $show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' );
185
+
186
+ $show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' );
187
+
188
+ $show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' );
189
+
190
+ $output = "
191
+ .wcf-thankyou-wrap{
192
+ color: {$text_color};
193
+ font-family: {$text_font_family};
194
+ max-width:{$container_width}px;
195
+ }
196
+
197
+ .woocommerce-order h2.woocommerce-column__title,
198
+ .woocommerce-order h2.woocommerce-order-details__title,
199
+ .woocommerce-order .woocommerce-thankyou-order-received,
200
+ .woocommerce-order-details h2 {
201
+ color: {$heading_text_color};
202
+ font-family: {$heading_font_family};
203
+ font-weight: {$heading_font_weight};
204
+ }
205
+
206
+ .woocommerce-order ul.order_details,
207
+ .woocommerce-order .woocommerce-order-details,
208
+ .woocommerce-order .woocommerce-customer-details{
209
+ background-color: {$section_bg_color}
210
+ }
211
+ ";
212
+
213
+ if ( 'no' == $show_order_review ) {
214
+ $output .= '
215
+ .woocommerce-order ul.order_details{
216
+ display: none;
217
+ }
218
+ ';
219
+ }
220
+
221
+ if ( 'no' == $show_order_details ) {
222
+ $output .= '
223
+ .woocommerce-order .woocommerce-order-details{
224
+ display: none;
225
+ }
226
+ ';
227
+ }
228
+
229
+ if ( 'no' == $show_billing_details ) {
230
+ $output .= '
231
+ .woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
232
+ display: none;
233
+ }
234
+ ';
235
+ }
236
+
237
+ if ( 'no' == $show_shipping_details ) {
238
+ $output .= '
239
+ .woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
240
+ display: none;
241
+ }
242
+ ';
243
+ }
244
+
245
+ if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
246
+ $output .= '
247
+ .woocommerce-order .woocommerce-customer-details{
248
+ display: none;
249
+ }
250
+ ';
251
+ }
252
+
253
+ return $output;
254
+ }
255
+ }
256
+
257
+ /**
258
+ * Kicking this off by calling 'get_instance()' method
259
+ */
260
+ Cartflows_Thankyou_Markup::get_instance();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, cart
5
  Requires at least: 4.4
6
  Requires PHP: 5.6
7
  Tested up to: 5.0
8
- Stable tag: 1.0.4
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -22,21 +22,29 @@ Create beautiful checkout pages & sales flows for WooCommerce.
22
 
23
  == Changelog ==
24
 
 
 
 
 
 
 
 
 
25
  Version 1.0.4 - Friday, 23rd November 2018
26
- - Fix: Thank you page style meta option issue.
27
 
28
  Version 1.0.3 - Friday, 23rd November 2018
29
- - Improvement: Optimized flow and step import.
30
- - Fix: Elementor page preview not working if landing page is set as homepage.
31
- - Fix: Landing page issue when set as home-page. Used Home url instead of Site url.
32
 
33
  Version 1.0.2 - Wednesday, 21st November 2018
34
- - Fix: Address fields misalignment on checkout page.
35
 
36
  Version 1.0.1 - Wednesday, 21st November 2018
37
- - New: Checkout persistence remember data
38
- - Fix: Link issue in Beaver Builder
39
- - Fix: Unwanted fields on checkout page.
40
 
41
  Version 1.0.0 - Monday, 19th November 2018
42
- - Initial Release
5
  Requires at least: 4.4
6
  Requires PHP: 5.6
7
  Tested up to: 5.0
8
+ Stable tag: 1.1.0
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
22
 
23
  == Changelog ==
24
 
25
+ Version 1.1.0 - Wednesday, 5th December 2018
26
+ * New: Ready for Order Bump Positions.
27
+ * Improvement: PixelYourSite compatibility added.
28
+ * Fix: Elementor preview not working for some permalinks.
29
+ * Fix: Checkout field label alignment issue.
30
+ * Fix: Long field text overlap on mobile.
31
+
32
+
33
  Version 1.0.4 - Friday, 23rd November 2018
34
+ * Fix: Thank you page style meta option issue.
35
 
36
  Version 1.0.3 - Friday, 23rd November 2018
37
+ * Improvement: Optimized flow and step import.
38
+ * Fix: Elementor page preview not working if landing page is set as homepage.
39
+ * Fix: Landing page issue when set as home-page. Used Home url instead of Site url.
40
 
41
  Version 1.0.2 - Wednesday, 21st November 2018
42
+ * Fix: Address fields misalignment on checkout page.
43
 
44
  Version 1.0.1 - Wednesday, 21st November 2018
45
+ * New: Checkout persistence remember data
46
+ * Fix: Link issue in Beaver Builder
47
+ * Fix: Unwanted fields on checkout page.
48
 
49
  Version 1.0.0 - Monday, 19th November 2018
50
+ * Initial Release