PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
← All changes | admin/modules/steps/class-wpfnl-steps.php +80 -0 2.8.16 → 3.13.3 View file →
@@ -188,8 +188,15 @@
188 188 wp_ajax_helper()->handle('step-edit')
189 189 ->with_callback([ $this, 'step_edit' ])
190 190 ->with_validation($this->get_validation_data());
191 191
192 + wp_ajax_helper()->handle('wpfnl-save-skip-offer-settings')
193 + ->with_callback([ $this, 'save_skip_offer_settings' ])
194 + ->with_validation($this->get_validation_data());
195 +
196 + wp_ajax_helper()->handle('wpfnl-get-skip-offer-settings')
197 + ->with_callback([ $this, 'get_skip_offer_settings' ])
198 + ->with_validation($this->get_validation_data());
192 199 }
193 200
194 201 /**
195 202 * Edit step by ajax request
@@ -210,8 +217,81 @@
210 217 wp_update_post($step_post);
211 218 return [
212 219 'success' => true,
213 220 'message' => "Step title updated",
221 + ];
222 + }
223 +
224 + /**
225 + * Save skip offer settings
226 + *
227 + * @param array $payload
228 + * @return array
229 + * @since 3.0.0
230 + */
231 + public function save_skip_offer_settings($payload)
232 + {
233 + $step_id = isset($payload['step_id']) ? absint($payload['step_id']) : 0;
234 + $funnel_id = isset($payload['funnel_id']) ? absint($payload['funnel_id']) : 0;
235 +
236 + if (!$step_id) {
237 + return [
238 + 'success' => false,
239 + 'message' => __('Invalid step ID', 'wpfnl'),
240 + ];
241 + }
242 +
243 + // Sanitize and save settings
244 + $skip_offer_enabled = isset($payload['skip_offer_enabled']) ? sanitize_text_field($payload['skip_offer_enabled']) : 'no';
245 + $skip_if_parent_product_exists = isset($payload['skip_if_parent_product_exists']) ? sanitize_text_field($payload['skip_if_parent_product_exists']) : 'no';
246 + $skip_if_ever_purchased = isset($payload['skip_if_ever_purchased']) ? sanitize_text_field($payload['skip_if_ever_purchased']) : 'no';
247 +
248 + // Update post meta
249 + update_post_meta($step_id, '_wpfnl_skip_offer_enabled', $skip_offer_enabled);
250 + update_post_meta($step_id, '_wpfnl_skip_if_parent_product_exists', $skip_if_parent_product_exists);
251 + update_post_meta($step_id, '_wpfnl_skip_if_ever_purchased', $skip_if_ever_purchased);
252 +
253 + return [
254 + 'success' => true,
255 + 'message' => __('Offer settings saved successfully', 'wpfnl'),
256 + ];
257 + }
258 +
259 + /**
260 + * Get skip offer settings
261 + *
262 + * @param array $payload
263 + * @return array
264 + * @since 3.0.0
265 + */
266 + public function get_skip_offer_settings($payload)
267 + {
268 + $step_id = isset($payload['step_id']) ? absint($payload['step_id']) : 0;
269 +
270 + if (!$step_id) {
271 + return [
272 + 'success' => false,
273 + 'message' => __('Invalid step ID', 'wpfnl'),
274 + ];
275 + }
276 +
277 + // Get settings from post meta
278 + $skip_offer_enabled = get_post_meta($step_id, '_wpfnl_skip_offer_enabled', true);
279 + $skip_if_parent_product_exists = get_post_meta($step_id, '_wpfnl_skip_if_parent_product_exists', true);
280 + $skip_if_ever_purchased = get_post_meta($step_id, '_wpfnl_skip_if_ever_purchased', true);
281 +
282 + // Set defaults if not set
283 + $skip_offer_enabled = $skip_offer_enabled ? $skip_offer_enabled : 'no';
284 + $skip_if_parent_product_exists = $skip_if_parent_product_exists ? $skip_if_parent_product_exists : 'no';
285 + $skip_if_ever_purchased = $skip_if_ever_purchased ? $skip_if_ever_purchased : 'no';
286 +
287 + return [
288 + 'success' => true,
289 + 'data' => [
290 + 'skip_offer_enabled' => $skip_offer_enabled,
291 + 'skip_if_parent_product_exists' => $skip_if_parent_product_exists,
292 + 'skip_if_ever_purchased' => $skip_if_ever_purchased,
293 + ],
214 294 ];
215 295 }
216 296
217 297 /**