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/createFunnel/class-wpfnl-create-funnel.php +91 -22 2.8.16 → 3.13.3 View file →
@@ -42,37 +42,51 @@
42 42 * @since 1.0.0
43 43 */
44 44 public function create_funnel( $payload )
45 45 {
46 + // Check if this is a Store Checkout import
47 + $is_store_checkout = isset($payload['is_store_checkout']) && filter_var($payload['is_store_checkout'], FILTER_VALIDATE_BOOLEAN);
48 +
46 49 $funnel = Wpfnl::$instance->funnel_store;
47 50 $funnel_id = $funnel->create($payload['funnelName']);
51 + $funnel_type = '';
48 52 if ( $funnel_id ) {
49 - $general_settings = get_option( '_wpfunnels_general_settings' );
50 - if( isset($general_settings['funnel_type']) ){
51 - if( 'woocommerce' == $general_settings['funnel_type'] ){
52 - $general_settings['funnel_type'] = 'sales';
53 - update_option( '_wpfunnels_general_settings', $general_settings );
54 -
53 + // Mark funnel as Store Checkout if applicable
54 + if ($is_store_checkout) {
55 + update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'store_checkout' );
56 + $funnel_type = 'store_checkout';
57 + } else {
58 + // Check if LMS add-on is active AND at least one LMS plugin (LearnDash or CreatorLMS) is active
59 + if( Wpfnl_functions::is_lms_addon_active() && Wpfnl_functions::is_any_lms_plugin_active() && isset($payload['type']) && 'lms' === $payload['type'] ){
60 + update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'lms' );
61 + $funnel_type = 'lms';
62 + }elseif( Wpfnl_functions::is_wc_active() && isset($payload['type']) && 'wc' === $payload['type'] ){
63 + update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'wc' );
64 + $funnel_type = 'wc';
65 + }elseif( isset($payload['type']) && 'lead' === $payload['type'] ){
66 + update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'lead' );
67 + $funnel_type = 'lead';
55 68 }
56 -
57 - if( 'sales' == $general_settings['funnel_type'] ){
58 - if( Wpfnl_functions::is_lms_addon_active() && isset($payload['type']) && 'lms' === $payload['type'] ){
59 - update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'lms' );
60 - }elseif( Wpfnl_functions::is_wc_active() && isset($payload['type']) && 'wc' === $payload['type'] ){
61 - update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'wc' );
62 - }elseif( isset($payload['type']) && 'lead' === $payload['type'] ){
63 - update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'lead' );
64 - }
65 -
66 - }else{
67 -
68 - if( isset($payload['type']) && 'lead' === $payload['type'] ){
69 - update_post_meta( $funnel_id, '_wpfnl_funnel_type', 'lead' );
70 - }
71 - }
72 69 }
73 70 }
71 +
72 + if ($is_store_checkout) {
73 + // For Store Checkout funnels, always create a fixed checkout → thank you layout
74 + $steps = $this->get_store_checkout_default_steps();
75 + $templateLayout = new \WPFunnels\Admin\Module\Layout\TemplateLayout($funnel, $funnel_id, $funnel_type, $steps);
76 + $templateLayout->create_step();
77 + $templateLayout->save_funnel_data();
74 78
79 + // Persist the checkout step ID so the public-facing override can use it
80 + require_once WPFNL_DIR . 'includes/core/woocommerce/class-wpfnl-store-checkout-override.php';
81 + \WPFunnels\WooCommerce\Wpfnl_Store_Checkout_Override::save_checkout_step_id( $funnel_id );
82 + } elseif( !empty($payload['selectedFunnelLayout']['steps']) ){
83 + $steps = $payload['selectedFunnelLayout']['steps'];
84 + $templateLayout = new \WPFunnels\Admin\Module\Layout\TemplateLayout($funnel, $funnel_id, $funnel_type, $steps);
85 + $templateLayout->create_step();
86 + $templateLayout->save_funnel_data();
87 + }
88 +
75 89 $link = add_query_arg(
76 90 [
77 91 'page' => 'edit_funnel',
78 92 'id' => $funnel_id,
@@ -79,13 +93,68 @@
79 93 ],
80 94 admin_url('admin.php')
81 95 );
82 96
97 + do_action('wpfunnels_after_funnel_created', $funnel_id, $funnel_type);
98 +
99 + // Flush rewrite rules so newly created funnel/step permalinks resolve immediately.
100 + flush_rewrite_rules();
101 +
83 102 return [
84 103 'success' => true,
85 104 'funnelID' => $funnel_id,
86 105 'redirectUrl' => $link,
87 106 ];
107 + }
108 +
109 +
110 + /**
111 + * Get the default steps for a Store Checkout funnel (checkout + thank you only).
112 + *
113 + * @return array
114 + * @since 3.5.0
115 + */
116 + private function get_store_checkout_default_steps()
117 + {
118 + return [
119 + [
120 + 'name' => __( 'Checkout', 'wpfnl' ),
121 + 'value' => 'checkout',
122 + 'pos_x' => 156,
123 + 'pos_y' => 258,
124 + ],
125 + [
126 + 'name' => __( 'Thank You', 'wpfnl' ),
127 + 'value' => 'thankyou',
128 + 'pos_x' => 399,
129 + 'pos_y' => 258,
130 + ],
131 + ];
132 + }
133 +
134 +
135 + /**
136 + * Get Store Checkout funnel if exists
137 + *
138 + * @return WP_Post|false
139 + * @since 3.5.0
140 + */
141 + private function get_store_checkout_funnel()
142 + {
143 + $args = array(
144 + 'post_type' => WPFNL_FUNNELS_POST_TYPE,
145 + 'posts_per_page' => 1,
146 + 'post_status' => array( 'publish', 'draft' ),
147 + 'meta_query' => array(
148 + array(
149 + 'key' => '_wpfnl_funnel_type',
150 + 'value' => 'store_checkout',
151 + ),
152 + ),
153 + );
154 +
155 + $funnels = get_posts( $args );
156 + return !empty( $funnels ) ? $funnels[0] : false;
88 157 }
89 158
90 159 public function get_name()
91 160 {