PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.2
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.2
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-step-factory.php

class-cartflows-step-factory.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.2, at classes/class-cartflows-step-factory.php

254 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get current step data - factory.
4 *
5 * @package cartflows
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12 /**
13 * Step factory
14 *
15 * @since 1.0.0
16 */
17 class Cartflows_Step_Factory {
18
19 /**
20 * Member Variable
21 *
22 * @var int step_id
23 */
24 private $step_id;
25
26 /**
27 * Member Variable
28 *
29 * @var int control_step_id
30 */
31 private $control_step_id;
32
33 /**
34 * Member Variable
35 *
36 * @var int flow_id
37 */
38 private $flow_id;
39
40
41 /**
42 * Member Variable
43 *
44 * @var string step_type
45 */
46 private $step_type;
47
48 /**
49 * Member Variable
50 *
51 * @var int flow_steps
52 */
53 private $flow_steps;
54
55 /**
56 * Member Variable
57 *
58 * @var int flow_steps
59 */
60 private $flow_steps_map;
61
62 /**
63 * Member Variable
64 *
65 * @var int ab_test
66 */
67 private $ab_test;
68
69 /**
70 * Member Variable
71 *
72 * @var int all_variations
73 */
74 private $all_variations;
75
76 /**
77 * Member Variable
78 *
79 * @var array show_variations
80 */
81 private $show_variations;
82
83 /**
84 * Member Variable
85 *
86 * @var int show_variation_id
87 */
88 private $show_variation_id;
89
90 /**
91 * Constructor
92 *
93 * @param int $id step id.
94 */
95 public function __construct( $id = null ) {
96
97 if ( null !== $id ) {
98
99 /* Data from step */
100 $this->step_id = intval( $id );
101 $this->step_type = get_post_meta( $this->step_id, 'wcf-step-type', true );
102 /* Data from flow */
103 $this->flow_id = get_post_meta( $this->step_id, 'wcf-flow-id', true );
104 $this->flow_steps = get_post_meta( $this->flow_id, 'wcf-steps', true );
105
106 /* If Ab test */
107 $this->ab_test = get_post_meta( $this->step_id, 'wcf-ab-test', true );
108 $this->control_step_id = $this->step_id;
109
110 if ( $this->ab_test ) {
111
112 $control_step_id = get_post_meta( $this->step_id, 'wcf-control-step', true );
113
114 if ( ! empty( $control_step_id ) ) {
115 $this->control_step_id = intval( $control_step_id );
116 }
117 }
118 }
119 }
120
121 /**
122 * Is ab test enable
123 */
124 public function is_ab_test_enable() {
125
126 if ( $this->ab_test ) {
127
128 return true;
129 }
130
131 return false;
132 }
133
134 /**
135 * Get flow id
136 */
137 public function get_flow_id() {
138 return $this->flow_id;
139 }
140
141 /**
142 * Get step id
143 */
144 public function get_step_id() {
145 return $this->step_id;
146 }
147
148 /**
149 * Get step type
150 */
151 public function get_step_type() {
152 return $this->step_type;
153 }
154
155 /**
156 * Get control step id
157 */
158 public function get_current_step() {
159 return $this->step_id;
160 }
161
162 /**
163 * Get control step id
164 */
165 public function get_control_step() {
166 return $this->control_step_id;
167 }
168
169 /**
170 * Get flow steps
171 */
172 public function get_flow_steps() {
173 return $this->flow_steps;
174 }
175
176 /**
177 * Set flow steps map
178 */
179 public function set_flow_steps_map() {
180 }
181
182 /**
183 * Check for thank you page
184 *
185 * @return bool
186 */
187 public function is_thankyou_page() {
188
189 $step_type = $this->get_step_type();
190
191 if ( 'thankyou' === $step_type ) {
192
193 return true;
194 }
195
196 return false;
197 }
198
199 /**
200 * Check for checkout page
201 *
202 * @return bool
203 */
204 public function is_checkout_page() {
205
206 $step_type = $this->get_step_type();
207
208 if ( 'checkout' === $step_type ) {
209
210 return true;
211 }
212
213 return false;
214 }
215
216 /**
217 * Get direct next step id.
218 *
219 * @since 1.6.15
220 *
221 * @return bool|int
222 */
223 public function get_direct_next_step_id() {
224
225 $next_step_id = false;
226
227 if ( $this->flow_id ) {
228
229 $flow_steps = $this->get_flow_steps();
230 $control_step = $this->get_control_step();
231
232 if ( is_array( $flow_steps ) ) {
233 $flow_steps_count = count( $flow_steps );
234
235 foreach ( $flow_steps as $index => $data ) {
236
237 if ( intval( $data['id'] ) === $control_step ) {
238
239 for ( $i = $index + 1; $i < $flow_steps_count; $i++ ) {
240
241 if ( isset( $flow_steps[ $i ]['id'] ) && ! wcf()->utils->is_step_disabled( $flow_steps[ $i ]['id'] ) ) {
242 $next_step_id = intval( $flow_steps[ $i ]['id'] );
243 break;
244 }
245 }
246 }
247 }
248 }
249 }
250
251 return $next_step_id;
252 }
253 }
254