PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 1.1.12
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v1.1.12
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / classes / class-cartflows-flow-frontend.php

class-cartflows-flow-frontend.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 1.1.12, at classes/class-cartflows-flow-frontend.php

200 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Frontend & Markup
4 *
5 * @package CartFlows
6 */
7
8 /**
9 * Flow Markup
10 *
11 * @since 1.0.0
12 */
13 class Cartflows_Flow_Frontend {
14
15
16 /**
17 * Member Variable
18 *
19 * @var object instance
20 */
21 private static $instance;
22
23 /**
24 * Initiator
25 */
26 public static function get_instance() {
27 if ( ! isset( self::$instance ) ) {
28 self::$instance = new self;
29 }
30 return self::$instance;
31 }
32
33 /**
34 * Constructor
35 */
36 public function __construct() {
37
38 /* Analytics */
39 add_action( 'cartflows_wp_footer', array( $this, 'footer_markup' ) );
40 }
41
42 /**
43 * Footer markup
44 */
45 function footer_markup() {
46
47 if ( wcf()->utils->is_step_post_type() ) {
48 // @codingStandardsIgnoreStart
49 ?>
50 <?php if( $this->is_flow_testmode() ) { ?>
51 <div class="wcf-preview-mode">
52 <span><?php _e( 'Test mode is active — which displays random products for previewing. It can be deactivated from the flow settings in the admin dashboard.', 'cartflows' ); ?></span>
53 </div>
54 <?php } ?>
55 <?php
56 // @codingStandardsIgnoreEnd
57 }
58 }
59
60 /**
61 * Check if flow test mode is enable.
62 *
63 * @since 1.0.0
64 * @param int $flow_id flow ID.
65 *
66 * @return boolean
67 */
68 function is_flow_testmode( $flow_id = '' ) {
69
70 if ( ! $flow_id ) {
71 $flow_id = wcf()->utils->get_flow_id();
72 }
73
74 $test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' );
75
76 if ( 'no' === $test_mode ) {
77 return false;
78 }
79
80 return true;
81 }
82
83 /**
84 * Get steps data.
85 *
86 * @since 1.0.0
87 * @param int $flow_id flow ID.
88 *
89 * @return array
90 */
91 function get_steps( $flow_id ) {
92
93 $steps = get_post_meta( $flow_id, 'wcf-steps', true );
94
95 if ( ! is_array( $steps ) ) {
96
97 $steps = array();
98 }
99
100 return $steps;
101 }
102
103 /**
104 * Check thank you page exists.
105 *
106 * @since 1.0.0
107 * @param array $order order data.
108 *
109 * @return bool
110 */
111 function is_thankyou_page_exists( $order ) {
112
113 $thankyou_step_exist = false;
114
115 $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
116
117 if ( $flow_id ) {
118
119 $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
120 $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
121
122 if ( is_array( $flow_steps ) ) {
123
124 $current_step_found = false;
125
126 foreach ( $flow_steps as $index => $data ) {
127
128 if ( $current_step_found ) {
129
130 if ( 'thankyou' === $data['type'] ) {
131
132 $thankyou_step_exist = true;
133 break;
134 }
135 } else {
136
137 if ( intval( $data['id'] ) === $step_id ) {
138
139 $current_step_found = true;
140 }
141 }
142 }
143 }
144 }
145
146 return $thankyou_step_exist;
147 }
148
149 /**
150 * Check thank you page exists.
151 *
152 * @since 1.0.0
153 * @param array $order order data.
154 *
155 * @return bool
156 */
157 function get_thankyou_page_id( $order ) {
158
159 $thankyou_step_id = false;
160
161 $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
162
163 if ( $flow_id ) {
164
165 $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
166 $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
167
168 if ( is_array( $flow_steps ) ) {
169
170 $current_step_found = false;
171
172 foreach ( $flow_steps as $index => $data ) {
173
174 if ( $current_step_found ) {
175
176 if ( 'thankyou' === $data['type'] ) {
177
178 $thankyou_step_id = intval( $data['id'] );
179 break;
180 }
181 } else {
182
183 if ( intval( $data['id'] ) === $step_id ) {
184
185 $current_step_found = true;
186 }
187 }
188 }
189 }
190 }
191
192 return $thankyou_step_id;
193 }
194 }
195
196 /**
197 * Kicking this off by calling 'get_instance()' method
198 */
199 Cartflows_Flow_Frontend::get_instance();
200