PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.11.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.11.1
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
wpfunnels / public / classes / class-wpfnl-frontend.php

class-wpfnl-frontend.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.11.1, at public/classes/class-wpfnl-frontend.php

56 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle frontend
4 *
5 * @package
6 */
7 namespace WPFunnels\Frontend;
8
9
10 use WPFunnels\Wpfnl_functions;
11
12 class Wpfnl_Frontend
13 {
14 public function __construct()
15 {
16 add_filter('woocommerce_get_checkout_order_received_url', [ $this, 'redirect_to_next_step' ], 10, 2);
17 }
18
19
20 /**
21 * Next step url after checkout is
22 * completed
23 *
24 * @param $order_received_url
25 * @param $order
26 *
27 * @return string
28 */
29 public function redirect_to_next_step($order_received_url, $order)
30 {
31 $order_key = $order->get_order_key();
32 $order_id = $order->get_id();
33 $current_page_id = get_post_meta($order_id, '_wpfunnel_checkout_id', true);
34 $funnel_id = get_post_meta($order_id, '_wpfunnel_id', true);
35 $next_step = Wpfnl_functions::get_next_step($funnel_id, $current_page_id);
36 if ($next_step) {
37
38 $custom_url = Wpfnl_functions::custom_url_for_thankyou_page( $next_step['id'] );
39 if( $custom_url ){
40 return $custom_url;
41 }
42
43 $next_step_link = get_page_link($next_step['id']);
44 $permalink_structure = get_option('permalink_structure');
45 if ($permalink_structure) {
46 $redirect_link = $next_step_link.'?order_id='.$order_id.'&order_key='.$order_key;
47 } else {
48 $redirect_link = $next_step_link.'&order_id='.$order_id.'&order_key='.$order_key;
49 }
50
51 return $redirect_link;
52 }
53 return $order_received_url;
54 }
55 }
56