/**
  * When a user is renewing their key from a renewal URL, set the initial
  * state to login.
  *
  * @since 1.0
  *
  * @param string $state
  *
  * @return string
  */
 public function set_initial_state_to_login($state)
 {
     if (isset($_GET['renew_key'])) {
         if (is_user_logged_in()) {
             $key = itelic_get_key($_GET['renew_key']);
             if ($key && $key->get_customer()->id == it_exchange_get_current_customer_id()) {
                 it_exchange_add_product_to_shopping_cart($key->get_product()->ID);
                 $this->update_cache_data(array("p{$key->get_product()->ID}" => $key->get_key()));
                 $state = 'checkout';
             }
         } else {
             $state = 'login';
         }
     }
     return $state;
 }
<?php

/**
 * Template file for the renew product purchase requirement
 *
 * @author Iron Bound Designs
 * @since  1.0
 */
$query = itelic_get_keys(array('customer' => it_exchange_get_current_customer_id(), 'product' => \ITELIC\get_current_product_id()));
?>

<style type="text/css">
	.renew-product-wrapper {
		background: #F6F6F6;
		padding: 1em;
	}

	#itelic-key-to-renew {
		display: block;
		max-width: 250px;
		white-space: nowrap;
	}
</style>

<div class="it-exchange-sw-processing it-exchange-sw-processing-renew-product">

	<form method="POST" class="it-exchange-sw-renew-product">
		<div class="renew-product-wrapper">

			<label for="itelic-key-to-renew"><?php 
_e("Select Key to Renew", ITELIC\Plugin::SLUG);
 /**
  * Retrieve the licenses.
  *
  * @since 1.0
  *
  * @return Key[]
  */
 protected function get_licenses()
 {
     $args = array('customer' => it_exchange_get_current_customer_id());
     return itelic_get_keys($args);
 }
        echo esc_attr($product);
        ?>
">
						<?php 
        echo itelic_get_product($product)->post_title;
        ?>
					</label>
					<select id="itelic-renew-product-<?php 
        echo esc_attr($product);
        ?>
" name="itelic_key[<?php 
        echo esc_attr($product);
        ?>
]">
						<?php 
        $keys = itelic_get_keys(array('customer' => it_exchange_get_current_customer_id(), 'product' => $product));
        ?>

						<?php 
        foreach ($keys as $key) {
            ?>
							<?php 
            if ($key->get_expires() !== null) {
                ?>
								<option value="<?php 
                echo esc_attr($key->get_key());
                ?>
">
									<?php 
                echo $key->get_key();
                ?>