<?php
/**
 * All Wizard related functions
 */
namespace Codexpert\WC_Affiliate;

use Codexpert\Plugin\Base;
use Codexpert\Plugin\Setup;
use Codexpert\WC_Affiliate\Helper;

/**
 * if accessed directly, exit.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * @package Plugin
 * @subpackage Wizard
 * @author codexpert <hello@codexpert.io>
 */
class Wizard extends Base {

	public $plugin;
	public $slug;
	public $name;
	public $version;
	public $admin_url;

	/**
	 * Constructor function
	 */
	public function __construct( $plugin ) {
		$this->plugin  = $plugin;
		$this->slug    = $this->plugin['TextDomain'];
		$this->name    = $this->plugin['Name'];
		$this->version = $this->plugin['Version'];
	}

	public function enqueue_style() {
		wp_enqueue_style( $this->slug . '-wizard', plugins_url( '/assets/css/wizard.css', WCAFFILIATE ), '', time(), 'all' );
		wp_enqueue_script( 'codexpert-product-wizard', WOOLEMENTOR_ASSETS . '/js/wizard.js', [ 'jquery' ], '' );
	}

	public function action_links( $links ) {
		$this->admin_url = admin_url( 'admin.php' );

		$new_links = array(
			'wizard' => sprintf( '<a href="%1$s">%2$s</a>', add_query_arg( array( 'page' => "{$this->slug}_setup" ), $this->admin_url ), __( 'Setup Wizard', 'wc-affiliate' ) ),
		);

		return array_merge( $new_links, $links );
	}

	public function render() {

		// force setup once
		if ( get_option( "{$this->slug}_setup" ) != 1 ) {
			update_option( "{$this->slug}_setup", 1 );
			wp_safe_redirect( add_query_arg( array( 'page' => "{$this->slug}_setup" ), admin_url( 'admin.php' ) ) );
			exit;
		}

		$this->plugin['steps'] = array(
			'welcome'    => array(
				'label'    => __( 'Welcome' ),
				'callback' => array( $this, 'welcome' ),
				'action'   => array( $this, 'save_page_selection' ),
			),
			'page-selection'    => array(
				'label'    => __( 'Affiliate Dashboard' ),
				'callback' => array( $this, 'page_selection' ),
				'action'   => array( $this, 'save_page_selection' ),
			),
			'configuration'     => array(
				'label'    => __( 'Configuration' ),
				'callback' => array( $this, 'configuration' ),
				'action'   => array( $this, 'save_configuration' ),
			),
			'referral_statuses' => array(
				'label'    => __( 'Email' ),
				'callback' => array( $this, 'referral_statuses' ),
				'action'   => array( $this, 'save_referral_statuses' ),
			),
			'complete' => array(
				'label'    => __( 'Complete!' ),
				'callback' => array( $this, 'complete' ),
				'action'   => array( $this, 'save_complete' ),
				'redirect' => add_query_arg( array( 'page' => "{$this->slug}" ), admin_url( 'admin.php' ) ),
			),
		);

		new Setup( $this->plugin );

	}

	public function welcome() {
		$settings  = get_option( 'wc_affiliate_basic', array() );
		$platform  = isset( $settings['platform'] ) ? $settings['platform'] : 'woocommerce';

		?>
			<div class="wc-affiliate-wizard-first-wrapper">
				<!-- <div class="wc-affiliate-wizard-logo">
					<img src="<?php echo WOOLEMENTOR_ASSETS . '/img/wc-acffiliate-logo.png'; ?>" alt="">
				</div> -->
				<h2><?php _e( 'Welcome to WC Affiliate 👋', 'wc-affiliate' ); ?></h2>
				<p><?php _e( '<b>Track referrals, reward affiliates, and grow your business,</b> all seamlessly <b>integrated with WooCommerce.</b> Follow this <b>quick setup wizard</b> to get started in minutes.', 'wc-affiliate' ); ?></p>
				<div class="wc-affiliate-wizard-platform-wrap">
					<select id="wc-wizard-select" name="platform">
						<option value="woocommerce" <?php selected( $platform, 'woocommerce' ); ?>><?php _e( 'Woocommerce', 'wc-affiliate' ); ?></option>
						<option value="easycommerce" <?php selected( $platform, 'easycommerce' ); ?>><?php _e( 'Easycommerce', 'wc-affiliate' ); ?></option>
					</select>
				</div>
				<div id="wc-affiliate-wizard-subs">
					<p>
						<label><?php _e( 'Get in touch: ', 'wc-affiliate' ); ?></label>
						<input id="setup-wizard-email" type="email" name="email" value="<?php echo esc_attr( get_currentuserinfo()->user_email ); ?>" placeholder="<?php echo esc_attr__( 'Enter your email address', 'wc-affiliate' ); ?>" />
					</p>
					<p class="cx-wizard-desc">
						<?php printf( esc_html__( 'Only product updates, tutorials & deals. No spamming. Unsubscribe anytime.', 'wc-affiliate' ) ); ?>
					</p>
				</div>
			</div>
		<?php 
	}

	public function page_selection() {
		$pages      = Helper::get_posts( array( 'post_type' => 'page' ) );
		$settings   = get_option( 'wc_affiliate_basic', array() );
		$_dashboard = isset( $settings['dashboard'] ) ? sanitize_text_field( $settings['dashboard'] ) : '';
		?>
		<div class="wc-affiliate-sw-panel-area">

			<div class="wc-affiliate-sw-panel wc-affiliate-sw-dashboard">
				<div>
					<h3><?php _e( 'Affiliate Dashboard', 'wc-affiliate' ); ?></h3>
					<p>The affiliate dashboard displays a summary of the referrals, earnings, and visits of your affiliate, as well as, other settings to monitor commissions.</p>
				</div>
				<h4>Select where to show the Affiliate Dashboard</h4>

				<div class="wc-affiliate-page-selection">
					<input type="radio" name="wc-page-selection" id="create-page-enable" checked value="1">
					<label for="create-page-enable">Create a new page</label>
				</div>
				<div class="wc-affiliate-sw-panel wc-affiliate-sw-dashboard-new-page">
					<input type="text" name="dashboard-create-new-page" placeholder="<?php esc_html_e( 'New page name', 'wc-affiliate' ); ?>" value="">
				</div>

				<div class="wc-affiliate-page-selection">
					<input type="radio" name="wc-page-selection" id="select-existing-page" value="2">
					<label for="select-existing-page">Select an existing page</label>
				</div>
				<select name="dashboard" id="">
					<?php
					foreach ( $pages as $page_id => $page_name ) {
						echo wp_kses_post( "<option value='" . esc_attr( $page_id ) . "' " . selected( $page_id, $_dashboard, false ) . '>' . esc_html( $page_name ) . '</option>' );
					}
					?>
				</select>

				<div class="wc-affiliate-notes">
					<p>You can change these options from the WC Affiliate Settings page later.</p>
				</div>
			</div>

		</div>

		<script type='text/javascript'>
			jQuery(function($){
				$(document).ready(function() {
					toggleSelect();

					$('input[name="wc-page-selection"]').on('change', function() {
						toggleSelect();
					});

					function toggleSelect() {
						if ($('#create-page-enable').is(':checked')) {
							$('input[name="dashboard-create-new-page"]').prop('disabled', false);
							$('select[name="dashboard"]').prop('disabled', true);
						}
						else if ($('#select-existing-page').is(':checked')) {
							$('input[name="dashboard-create-new-page"]').prop('disabled', true);
							$('select[name="dashboard"]').prop('disabled', false);
						}
					}
				});
			}); 
		</script>
		<?php
	}

	public function configuration() {
		$settings          = get_option( 'wc_affiliate_basic', array() );
		$commission_type   = isset( $settings['commission_type'] ) ? sanitize_text_field( $settings['commission_type'] ) : 'percent';
		$commission_base   = isset( $settings['commission_base'] ) ? sanitize_text_field( $settings['commission_base'] ) : 'payable_amount';
		$commission_amount = isset( $settings['commission_amount'] ) ? sanitize_text_field( $settings['commission_amount'] ) : 20;
		$payout_amount     = isset( $settings['payout_amount'] ) ? sanitize_text_field( $settings['payout_amount'] ) : 100;
		$expiry_time       = isset( $settings['expiry_time'] ) ? sanitize_text_field( $settings['expiry_time'] ) : 1;
		$expiry_unit       = isset( $settings['expiry_unit'] ) ? sanitize_text_field( $settings['expiry_unit'] ) : 2592000;
		$commissions_rate  = Helper::get_commission_rate();
		$base 			   = Helper::get_commission_base();
		$time_units        = Helper::get_time_units();

		?>
		<div class="wc-affiliate-sw-panel-area">
			<div class="wc-affiliate-sw-panel wc-affiliate-sw-commission-type">

				<div>
					<h3><?php _e( 'A Few Essential Settings to Setup', 'wc-affiliate' ); ?></h3>
					<p>Let's set up some essential options that form the foundation of your affiliate program. You can adjust these anytime  from the settings page of WC Affiliate.</p>
				</div>

				<div class="wc-configuration-row wc-commission-type wc-affiliate-commission-base">
					<label for="">
						<?php esc_html_e( 'Affiliate Commission Base', 'wc-affiliate' ); ?>
						<img class="affiliate_commission_base_icon" src="<?php echo esc_url( WOOLEMENTOR_ASSETS . '/img/icon.svg' ); ?>" alt="icon">
					</label>
					<select name="commission-base" id="commission-base" required>
						<?php
						foreach ( $base as $key => $commission ) {
							echo wp_kses_post( "<option value='{$key}' " . selected( $key, $commission_base, false ) . ">{$commission}</option>" );
						}
						?>
					</select>
					<span class="affiliate_commission_based_enable" style="display: none;"><?php esc_html_e( 'Choose the type of affiliate commission base you will provide.', 'wc-affiliate' ); ?> </span>
				</div>
			</div>
			<div class="wc-configuration-row wc-commission-type">
				<div class="wc-configuration-column">
					<label for="">
						<?php esc_html_e( 'Commission Rate ', 'wc-affiliate' ); ?>
						<img class="commission_rate_icon" src="<?php echo esc_url( WOOLEMENTOR_ASSETS . '/img/icon.svg' ); ?>" alt="icon">
					</label>
					<div class="wc-affiliate-sw-panel wc-affiliate-sw-commission-amount">
						<input type="number" name="commission-amount" placeholder="<?php esc_attr_e( 'Input commission amount', 'wc-affiliate' ); ?>" value="<?php echo esc_attr( $commission_amount ); ?>" required>
					</div>		
				</div>
				<div class="wc-configuration-column">
					<div class="wc-affiliate-sw-panel wc-affiliate-sw-payout-amount">					
						<select name="commission-base" id="commission-base" required>
							<?php
							foreach ( $commissions_rate as $key => $commission ) {
								echo wp_kses_post( "<option value='{$key}' " . selected( $key, $commission_base, false ) . ">{$commission}</option>" );
							}
							?>
						</select>
					</div>
				</div>
				<span class="commission_rate_enable" style="display: none;"><?php esc_html_e( 'The rate of commission you want to give to your affiliates. Calculated based on quantities sold.' ); ?> </span>
			</div>

			<div class="wc-configuration-row wc-commission-type">
				<div class="wc-configuration-column">
					<div class="wc-affiliate-sw-panel-area">
						<label for="">
							<?php esc_html_e( 'Cookie Expiry ', 'wc-affiliate' ); ?>
							<img class="cookie_expiry_icon" src="<?php echo esc_url( WOOLEMENTOR_ASSETS . '/img/icon.svg' ); ?>" alt="icon">
						</label>
						<div class="wc-affiliate-sw-panel wc-affiliate-sw-cookie-expiry-time">
							<input type="number" name="cookie-expiry-time" placeholder="<?php esc_html_e( 'input time', 'wc-affiliate' ); ?>" value="<?php echo esc_attr( $expiry_time ); ?>" required>
						</div>
						<span class="cookie_expiry_enable" style="display: none;"><?php esc_html_e( 'Set the duration for which a referred visitor remains tracked. If they purchase within this period, the referring affiliate earns a commission.', 'wc-affiliate' ); ?></span>
					</div>
				</div>
				<div class="wc-configuration-column">
					<div class="wc-affiliate-sw-panel-area">
						<div class="wc-affiliate-sw-panel wc-affiliate-sw-cookie-expiry-time">
							<select name="cookie-expiry-time-unit" id="" required>
								<?php
									foreach ( $time_units as $key => $time_unit ) {
										echo wp_kses_post( "<option value='{$key}' " . selected( $key, $expiry_unit, false ) . ">{$time_unit}</option>" );
									}
								?>
							</select>
						</div>
					</div>					
				</div>
			</div>
			
		</div>
		<?php
	}

	private function admin_email_fields() {
		$fields = array(
			'affiliate_applied_admin_enable'    => array(
				'label' => __( 'Affiliate Application', 'wc-affiliate' ),
				'desc'  => __( 'Enable this to get notified whenever an affiliate registers to apply.', 'wc-affiliate' ),
			),
			'request_payout_admin_enable' => array(
				'label' => __( 'Payout Request', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to be notified when an affiliate requests a payout.', 'wc-affiliate' ),
			),
			'add_credit_admin_enable'    => array(
				'label' => __( 'Commission Earned', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to get notified whenever an affiliate receives a commission.', 'wc-affiliate' ),
			)
		);

		return $fields;
	}

	private function affiliate_email_fields() {
		$fields = array(
			'affiliate_applied_enable'    => array(
				'label' => __( 'Affiliate Application', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to send an email after an affiliate applies.', 'wc-affiliate' ),
			),
			'affiliate_approved_enable' => array(
				'label' => __( 'Affiliate Account Approval', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to send an email when an affiliate account is approved.', 'wc-affiliate' ),
			),
			'account_reject_enable'    => array(
				'label' => __( 'Affiliate Account Rejection', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to send an email if an affiliate application is rejected.', 'wc-affiliate' ),
			),
			'request_payout_enable'    => array(
				'label' => __( 'Payout Request', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to send an email after an affiliate requests for a payout.', 'wc-affiliate' ),
			),
			'add_credit_enable'    => array(
				'label' => __( 'Commission Earned', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to send an email when an affiliate gets a commission.', 'wc-affiliate' ),
			),
			'payout_process_enable'    => array(
				'label' => __( 'Payout Process', 'wc-affiliate' ),
				'desc'  => __( 'Enable this if you want to send an email when an affiliate\'s earnings are disbursed.', 'wc-affiliate' ),
			)
		);

		return $fields;
	}

	public function referral_statuses() {

		$admin_email_fields		= $this->admin_email_fields();
		$affiliate_email_fields	= $this->affiliate_email_fields();
		$settings          		= get_option( 'wc_affiliate_email', array() );

		?>
		<div class="wc-affiliate-sw-panel-area">
			<div class="wc-affiliate-sw-panel wc-affiliate-email-configuration">

			<div class="wc-admin-emails">
				<h3><?php _e( 'Admin Emails', 'wc-affiliate' ); ?></h3>
				<p>Choose which emails you want to receive.</p>
			</div>
			<?php
			foreach( $admin_email_fields as $key => $value ) {
				?>
				<div class="wc-affiliate-admin-email-configuration">
					<div class="wc-affiliate-single-email-config">
						<div class="wc-affiliate-email-title <?php esc_attr_e( $key ); ?>">
							<p>
								<?php echo $value['label']; ?>
								<img src="<?php echo WOOLEMENTOR_ASSETS . '/img/icon.svg'; ?>" alt="icon">
							</p>
						</div>
						<div class="wc-affiliate-switch">
							<!-- Hidden input to send empty value when unchecked -->
							<input type="hidden" name="<?php echo esc_attr( $key ); ?>" value="off" />

							<!-- Checkbox input -->
							<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo $key; ?>" 
								<?php echo isset($settings[$key]) && $settings[$key] == 'on' ? 'checked' : '' ?> />
							<label for="<?php echo $key; ?>"><?php __( 'Toggle', 'wc-affiliate' ); ?></label>
						</div>
						<span class="<?php esc_attr_e( $key ); ?>"><?php esc_html_e( $value['desc'], 'wc-affiliate' ); ?></span>
					</div>
					
				</div>
				<?php 
			}

			?>
			<div class="wc-affiliate-emails">
				<h3><?php _e( 'Affiliate Emails', 'wc-affiliate' ); ?></h3>
				<p>Choose which emails your affiliates will receive.</p>
			</div>

			<?php
			foreach( $affiliate_email_fields as $key => $value ) {
				?>
				<div class="wc-affiliate-admin-email-configuration <?php esc_attr_e( $key ); ?>">
					<div class="wc-affiliate-single-email-config">
						<div class="wc-affiliate-email-title">
							<p>
								<?php esc_html_e( $value['label'], 'wc-affiliate' ); ?>
								<img src="<?php echo WOOLEMENTOR_ASSETS . '/img/icon.svg'; ?>" alt="icon">
							</p>
						</div>
						<div class="wc-affiliate-switch">
							<!-- Hidden input to send empty value when unchecked -->
							<input type="hidden" name="<?php echo $key; ?>" value="off" />

							<!-- Checkbox input -->
							<input type="checkbox" name="<?php echo $key; ?>" id="<?php echo $key; ?>" 
								<?php echo isset($settings[$key]) && $settings[$key] == 'on' ? 'checked' : '' ?> />
							<label for="<?php echo $key; ?>"><?php __( 'Toggle', 'wc-affiliate' ); ?></label>
						</div>
						<span class="<?php esc_attr_e( $key ); ?>"><?php esc_html_e( $value['desc'], 'wc-affiliate' ); ?></span>
					</div>
					
				</div>
				<?php 
			}

			?>

			</div>
		</div>
		<?php 
	}

	public function save_page_selection() {
		$settings = get_option( 'wc_affiliate_basic', array() );
	
		// Save dashboard page
		if ( isset( $_POST['dashboard-create-new-page'] ) && $_POST['dashboard-create-new-page'] != '' ) {
			$args = array(
				'post_type'    => 'page',
				'post_status'  => 'publish',
				'post_title'   => sanitize_text_field( $_POST['dashboard-create-new-page'] ),
				'post_content' => '[wc-affiliate-dashboard]',
			);
	
			$page_id               = wp_insert_post( $args );
			$settings['dashboard'] = $page_id;
		} elseif ( isset( $_POST['dashboard'] ) ) {
			$settings['dashboard'] = sanitize_text_field( $_POST['dashboard'] );
		}
	
		// ✅ Save platform selection
		if ( isset( $_POST['platform'] ) ) {
			$settings['platform'] = sanitize_text_field( $_POST['platform'] );
		}
	
		update_option( 'wc_affiliate_basic', $settings );
	}
	

	public function save_configuration() {
		// save two to DB
		$settings        = get_option( 'wc_affiliate_basic', array() );
		$payout_settings = get_option( 'wc_affiliate_payout', array() );

		if ( isset( $_POST['commission-base'] ) ) {
			$settings['commission_base'] = sanitize_text_field( $_POST['commission-base'] );
		}

		if ( isset( $_POST['commission-type'] ) ) {
			$settings['commission_type'] = sanitize_text_field( $_POST['commission-type'] );
		}

		if ( isset( $_POST['commission-amount'] ) ) {
			$settings['commission_amount'] = (int) sanitize_text_field( $_POST['commission-amount'] );
		}

		if ( isset( $_POST['enable-discount'] ) ) {
			$settings['enable_discount'] = sanitize_text_field( $_POST['enable-discount'] );
		}

		if ( isset( $_POST['payout-amount'] ) ) {
			$payout_settings['payout_amount'] = sanitize_text_field( $_POST['payout-amount'] );
		}

		if ( isset( $_POST['cookie-expiry-time'] ) ) {
			$settings['expiry_time'] = sanitize_text_field( $_POST['cookie-expiry-time'] );
		}

		if ( isset( $_POST['cookie-expiry-time-unit'] ) && isset( $_POST['cookie-expiry-time'] ) ) {
			$settings['expiry_unit'] = sanitize_text_field( $_POST['cookie-expiry-time-unit'] );
		}

		update_option( 'wc_affiliate_basic', $settings );
		update_option( 'wc_affiliate_payout', $payout_settings );
	}

	public function save_referral_statuses() {
	
		$admin_email_fields		= $this->admin_email_fields();
		$affiliate_email_fields	= $this->affiliate_email_fields();
		$settings          		= get_option( 'wc_affiliate_email', array() );
		foreach ( $admin_email_fields as $key => $field ) {

			if ( isset( $_POST[ $key ] ) ) {
				$settings[ $key ] = sanitize_text_field( $_POST[ $key ] );
			}
		}
		foreach ( $affiliate_email_fields as $key => $field ) {

			if ( isset( $_POST[ $key ] ) ) {
				$settings[ $key ] = sanitize_text_field( $_POST[ $key ] );
			}
		}		

		update_option( 'wc_affiliate_email', $settings );
	}

	public function complete() {
		?>
			<div class="wc-affiliate-sw-panel-area">
				<div class="wc-affiliate-sw-panel wc-affiliate-sw-commission-type">
					<div>
						<h3><?php _e( 'That’s It – You’re All Set!', 'wc-affiliate' ); ?></h3>
						<p>WC Affiliate is set up and ready to track referrals, commissions, and payouts. Visit the settings page anytime to tweak your program.</p>
					</div>
					<div class="wc-affiliate-complete-actions">
						<div class="wc-affiliate-complete-column documentation">
							<img src="<?php echo WOOLEMENTOR_ASSETS . '/img/documentation.svg' ?>" alt="">
							<h4>Read Detailed Documentation</h4>
							<p>Learn the ins and outs of WC Affiliate and set up your affiliate program exactly how you want it</p>
							<a class="documentation" target="_blank" href="https://help.codexpert.io/docs/wc-affiliate/wc-affiliate-configuration/i-want-to-disable-commission-for-a-product-what-to-do/?utm_source=wp+repository&utm_medium=setup+wizard&utm_campaign=documentation">Documentation <svg xmlns="http://www.w3.org/2000/svg" width="17" height="12" viewBox="0 0 17 12" fill="none">
							<path d="M10.6969 11.5C10.4811 11.5 10.2781 11.4266 10.1247 11.2934C9.97125 11.1594 9.88716 10.9822 9.88716 10.7934C9.88716 10.6045 9.97125 10.4273 10.1241 10.2938L14.2376 6.70298H0.809173C0.363097 6.70298 0 6.386 0 5.99658C0 5.60716 0.363376 5.29018 0.809173 5.29018H14.2379L10.1241 1.69935C9.97125 1.56589 9.88716 1.38868 9.88716 1.19981C9.88716 1.01093 9.97125 0.833724 10.1241 0.700271C10.4304 0.433122 10.9631 0.433365 11.2685 0.700271L16.7632 5.49729C17.0789 5.7727 17.0789 6.22095 16.7632 6.49612L11.2688 11.2931C11.1162 11.4266 10.9127 11.5 10.6969 11.5Z" fill="#222D3D"/>
							</svg></a>
						</div>
						<?php
						ob_start();
						?>
						<div class="wc-affiliate-complete-column upgrade-to-pro">
							<img src="<?php echo WOOLEMENTOR_ASSETS; ?>/img/affiliate-program.svg" alt="">
							<h4>Upgrade to Pro & Get Exclusive Features</h4>
							<p>Give your program the competitive edge it needs to stand out in a crowded market!</p>
							<a class="upgrade" target="_blank" href="https://codexpert.io/wc-affiliate/pricing/?utm_source=wp+repository&utm_medium=setup+wizard&utm_campaign=upgrade+to+pro">
								<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
									<path d="M14.3652 2.94772C14.1455 2.84065 13.896 2.81117 13.6574 2.86409C13.4187 2.917 13.205 3.04919 13.0512 3.23911L10.5201 6.37005L8.52044 0.728068C8.44478 0.515867 8.30533 0.332267 8.12121 0.202443C7.93709 0.0726195 7.71732 0.00292969 7.49203 0.00292969C7.26675 0.00292969 7.04698 0.0726195 6.86286 0.202443C6.67874 0.332267 6.53929 0.515867 6.46362 0.728068L4.46965 6.33862L1.9329 3.24196C1.77994 3.05095 1.56693 2.91721 1.32842 2.86246C1.08991 2.80771 0.839901 2.83516 0.618948 2.94034C0.397995 3.04553 0.219064 3.22228 0.111182 3.44193C0.00330105 3.66158 -0.0272008 3.91123 0.0246252 4.15039L1.71579 12.412H13.2683L14.9594 4.15039C15.012 3.91223 14.9818 3.66327 14.8737 3.44461C14.7657 3.22595 14.5863 3.05068 14.3652 2.94772Z" fill="#222D3D"/>
									<path d="M2.99034 13.5518H1.84766V14.2488C1.84735 14.7116 2.03067 15.1556 2.35737 15.4833C2.68407 15.8111 3.12746 15.9959 3.59024 15.9971H11.3947C11.8575 15.9959 12.3009 15.8111 12.6276 15.4833C12.9543 15.1556 13.1376 14.7116 13.1373 14.2488V13.5518H2.99034Z" fill="#222D3D"/>
								</svg>Upgrade to Pro
							</a>
						</div>
						<?php
						echo apply_filters( 'wc_affiliate_setup_wizard_upgrade_to_pro', ob_get_clean() );
						?>
						
					</div>
					<div class="wc-affiliate-complete-actions wc-affiliate-complete-actions-last support">
						<div class="wc-affiliate-complete-column">
							<img src="<?php echo WOOLEMENTOR_ASSETS . '/img/support.svg' ?>" alt="">
							<h4>Need a hand? We're here to help!</h4>
							<p>Got questions or need assistance? Our support team is ready to help you every step of the way. Reach out anytime, and we’ll make sure you’re set up for success!</p>
							<a class="support" target="_blank" href="https://help.pluggable.io/new-ticket/?utm_source=wp+repository&utm_medium=setup+wizard&utm_campaign=support">Get Support <svg xmlns="http://www.w3.org/2000/svg" width="17" height="12" viewBox="0 0 17 12" fill="none">
							<path d="M10.6969 11.5C10.4811 11.5 10.2781 11.4266 10.1247 11.2934C9.97125 11.1594 9.88716 10.9822 9.88716 10.7934C9.88716 10.6045 9.97125 10.4273 10.1241 10.2938L14.2376 6.70298H0.809173C0.363097 6.70298 0 6.386 0 5.99658C0 5.60716 0.363376 5.29018 0.809173 5.29018H14.2379L10.1241 1.69935C9.97125 1.56589 9.88716 1.38868 9.88716 1.19981C9.88716 1.01093 9.97125 0.833724 10.1241 0.700271C10.4304 0.433122 10.9631 0.433365 11.2685 0.700271L16.7632 5.49729C17.0789 5.7727 17.0789 6.22095 16.7632 6.49612L11.2688 11.2931C11.1162 11.4266 10.9127 11.5 10.6969 11.5Z" fill="#222D3D"/>
							</svg></a>
						</div>
					</div>
				</div>
			</div>
		<?php 	
	}

	public function save_complete() {
		// save three to DB
	}

}