# sellkit/1.2.5/includes/funnel/steps/thankyou.php

SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster, version 1.2.5. 61 lines.

- Page: https://pluginprobe.com/plugins/sellkit/1.2.5/code/includes/funnel/steps/thankyou.php
- Raw: https://pluginprobe.com/plugins/sellkit/1.2.5/raw/includes/funnel/steps/thankyou.php
- Modified: 2022-08-03T13:13:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sellkit/1.2.5/code/includes/funnel/steps/thankyou.php#L10-L20`.

```php
<?php

namespace Sellkit\Funnel\Steps;

defined( 'ABSPATH' ) || die();

/**
 * Class Sellkit_Thankyou.
 *
 * @since 1.1.0
 */
class Thankyou {

	/**
	 * Thankyou constructor.
	 *
	 * @since 1.1.0
	 */
	public function __construct() {
		add_action( 'template_redirect', [ $this, 'redirect_after_purchase' ], 10 );
	}

	/**
	 * Redirects after purchasing.
	 *
	 * @since 1.1.0
	 */
	public function redirect_after_purchase() {
		if ( ! class_exists( 'woocommerce' ) ) {
			return;
		}

		global $wp;

		$funnel = sellkit_funnel();

		if ( ! empty( $funnel->funnel_id ) && 'thankyou' === $funnel->current_step_data['type']['key'] ) {
			return;
		}

		if ( ! function_exists( 'is_checkout' ) ) {
			return;
		}

		if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
			$order_id  = absint( $wp->query_vars['order-received'] );
			$order_key = sellkit_htmlspecialchars( INPUT_GET, 'key' );
			$order     = wc_get_order( $order_id );
			$next_step = $order->get_meta( 'sellkit_funnel_next_step_data' );

			if ( empty( $next_step ) ) {
				return;
			}

			$next_step_link = add_query_arg( [ 'order-key' => $order_key ], get_permalink( $next_step['page_id'] ) );

			wp_safe_redirect( $next_step_link );
		}
	}
}

```
