funnel_id ) && 'thankyou' === $funnel->current_step_data['type']['key'] ) { return; } if ( ! function_exists( 'is_checkout' ) ) { return; } $order_key = filter_input( INPUT_GET, 'key', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( ! empty( $order_key ) ) { $order_id = wc_get_order_id_by_order_key( $order_key ); $order = wc_get_order( $order_id ); $next_step = $order->get_meta( 'sellkit_funnel_next_step_data' ); $funnel_id = get_post_meta( $order_id, 'sellkit_funnel_id', true ); if ( empty( $next_step ) ) { return; } if ( empty( $funnel_id ) ) { $step_id = intval( $next_step['page_id'] ); $step_data = get_post_meta( $step_id, 'step_data', true ); $funnel_id = (int) $step_data['funnel_id']; } // For the new method( upsell popup ) we show thakyou page right away after checkout step. $thankyou_id = $this->find_funnel_thankyou_page( $funnel_id ); $next_step_link = add_query_arg( [ 'order-key' => $order_key ], get_permalink( $thankyou_id ) ); $last_price = $order->get_total() - $order->get_total_discount() - $order->get_total_tax(); $this->contacts->add_total_spent( $last_price, $funnel_id ); wp_safe_redirect( $next_step_link ); exit(); } } /** * Find funnel thankyou page using one of steps data. * * @param array $funnel_id funnel id. * @since 1.6.2 */ private function find_funnel_thankyou_page( $funnel_id ) { $funnel_data = get_post_meta( $funnel_id, 'nodes', true ); $id = 0; foreach ( $funnel_data as $step ) { if ( 'thankyou' === $step['type']['key'] ) { $id = $step['page_id']; } } return $id; } }