/**
 * Get AJAX URL
 *
 * @since 1.3
 * @return string
*/
function edd_get_ajax_url()
{
    $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
    $current_url = edd_get_current_page_url();
    $ajax_url = admin_url('admin-ajax.php', $scheme);
    if (preg_match('/^https/', $current_url) && !preg_match('/^https/', $ajax_url)) {
        $ajax_url = preg_replace('/^http/', 'https', $ajax_url);
    }
    return apply_filters('edd_ajax_url', $ajax_url);
}
/**
 * Registration Form
 *
 * @since 2.0
 * @global $post
 * @param string $redirect Redirect page URL
 * @return string Register form
*/
function edd_register_form($redirect = '')
{
    global $edd_register_redirect;
    if (empty($redirect)) {
        $redirect = edd_get_current_page_url();
    }
    $edd_register_redirect = $redirect;
    ob_start();
    if (!is_user_logged_in()) {
        edd_get_template_part('shortcode', 'register');
    }
    return apply_filters('edd_register_form', ob_get_clean());
}
/**
 * Profile Editor Shortcode
 *
 * Outputs the EDD Profile Editor to allow users to amend their details from the front-end
 *
 * @access      public
 * @since       1.4
 * @author      Sunny Ratilal
 */
function edd_profile_editor_shortcode($atts, $content = null)
{
    global $current_user;
    ob_start();
    if (is_user_logged_in()) {
        $user_id = get_current_user_id();
        $first_name = get_user_meta($user_id, 'first_name', true);
        $last_name = get_user_meta($user_id, 'last_name', true);
        $display_name = $current_user->display_name;
        if (isset($_GET['updated']) && $_GET['updated'] == true && !edd_get_errors()) {
            ?>
		<p class="edd_success"><strong><?php 
            _e('Success', 'edd');
            ?>
:</strong> <?php 
            _e('Your profile has been edited successfully.', 'edd');
            ?>
</p>
		<?php 
        }
        edd_print_errors();
        ?>
		<form id="edd_profile_editor_form" class="edd_form" action="<?php 
        echo edd_get_current_page_url();
        ?>
" method="post">
			<fieldset>
				<legend><?php 
        _e('Change your Name', 'edd');
        ?>
</legend>
				<p id="edd_profile_name_wrap">
					<label for="edd_first_name"><?php 
        _e('First Name', 'edd');
        ?>
</label>
					<input name="edd_first_name" id="edd_first_name" class="text edd-input" type="text" value="<?php 
        echo $first_name;
        ?>
" />
					<br />
					<label for="edd_last_name"><?php 
        _e('Last Name', 'edd');
        ?>
</label>
					<input name="edd_last_name" id="edd_last_name" class="text edd-input" type="text" value="<?php 
        echo $last_name;
        ?>
" />
				</p>
				<p id="edd_profile_display_name_wrap">
					<label for="edd_display_name"><?php 
        _e('Display Name', 'edd');
        ?>
</label>
					<select name="edd_display_name">
						<?php 
        if (!empty($current_user->first_name)) {
            ?>
						<option <?php 
            selected($display_name, $current_user->first_name);
            ?>
 value="<?php 
            echo $current_user->first_name;
            ?>
"><?php 
            echo $current_user->first_name;
            ?>
</option>
						<?php 
        }
        ?>
						<option <?php 
        selected($display_name, $current_user->user_nicename);
        ?>
 value="<?php 
        echo $current_user->user_nicename;
        ?>
"><?php 
        echo $current_user->user_nicename;
        ?>
</option>
						<?php 
        if (!empty($current_user->last_name)) {
            ?>
						<option <?php 
            selected($display_name, $current_user->last_name);
            ?>
 value="<?php 
            echo $current_user->last_name;
            ?>
"><?php 
            echo $current_user->last_name;
            ?>
</option>
						<?php 
        }
        ?>
						<?php 
        if (!empty($current_user->first_name) && !empty($current_user->last_name)) {
            ?>
						<option <?php 
            selected($display_name, $current_user->first_name . ' ' . $current_user->last_name);
            ?>
 value="<?php 
            echo $current_user->first_name . ' ' . $current_user->last_name;
            ?>
"><?php 
            echo $current_user->first_name . ' ' . $current_user->last_name;
            ?>
</option>
						<option <?php 
            selected($display_name, $current_user->last_name . ' ' . $current_user->first_name);
            ?>
 value="<?php 
            echo $current_user->last_name . ' ' . $current_user->first_name;
            ?>
"><?php 
            echo $current_user->last_name . ' ' . $current_user->first_name;
            ?>
</option>
						<?php 
        }
        ?>
					</select>
				</p>
				<p>
					<label for="edd_email"><?php 
        _e('Email Address', 'edd');
        ?>
</label>
					<input name="edd_email" id="edd_email" class="text edd-input required" type="email" value="<?php 
        echo $current_user->user_email;
        ?>
" />
				</p>
				<legend><?php 
        _e('Change your Password', 'edd');
        ?>
</legend>
				<p id="edd_profile_password_wrap">
					<label for="edd_user_pass"><?php 
        _e('New Password', 'edd');
        ?>
</label>
					<input name="edd_new_user_pass1" id="edd_new_user_pass1" class="password edd-input" type="password"/>
					<br />
					<label for="edd_user_pass"><?php 
        _e('Re-enter Password', 'edd');
        ?>
</label>
					<input name="edd_new_user_pass2" id="edd_new_user_pass2" class="password edd-input" type="password"/>
				</p>
				<p class="edd_password_change_notice"><?php 
        _e('Please note after changing your password, you must log back in.', 'edd');
        ?>
</p>
				<p id="edd_profile_submit_wrap">
					<input type="hidden" name="edd_profile_editor_nonce" value="<?php 
        echo wp_create_nonce('edd-profile-editor-nonce');
        ?>
"/>
					<input type="hidden" name="edd_action" value="edit_user_profile" />
					<input type="hidden" name="edd_redirect" value="<?php 
        echo esc_url(edd_get_current_page_url());
        ?>
" />
					<input name="edd_profile_editor_submit" id="edd_profile_editor_submit" type="submit" class="edd_submit" value="<?php 
        _e('Save Changes', 'edd');
        ?>
"/>
				</p>
			</fieldset>
		</form><!-- #edd_profile_editor_form -->
		<?php 
    } else {
        echo '<p>' . __('You need to login to edit your profile.', 'edd') . '</p>';
        wp_login_form(array('echo' => true, 'redirect' => edd_get_current_page_url(), 'form_id' => 'edd_login_form', 'label_username' => __('Username', 'edd'), 'label_password' => __('Password', 'edd'), 'label_remember' => __('Remember me?', 'edd'), 'label_log_in' => __('Log In', 'edd'), 'id_username' => 'edd_user_login', 'id_password' => 'edd_user_pass', 'id_remember' => 'edd_remember_me', 'id_submit' => 'edd_login_form_submit', 'remember' => true));
    }
    $display = ob_get_clean();
    return $display;
}
				<?php do_action( 'edd_profile_editor_address' ); ?>
			</p>
			<?php do_action( 'edd_profile_editor_after_address' ); ?>
			<span id="edd_profile_password_label"><legend><?php _e( 'Change your Password', 'edd' ); ?></legend></span>
			<p id="edd_profile_password_wrap">
				<label for="edd_user_pass"><?php _e( 'New Password', 'edd' ); ?></label>
				<input name="edd_new_user_pass1" id="edd_new_user_pass1" class="password edd-input" type="password"/>
				<br />
				<label for="edd_user_pass"><?php _e( 'Re-enter Password', 'edd' ); ?></label>
				<input name="edd_new_user_pass2" id="edd_new_user_pass2" class="password edd-input" type="password"/>
				<?php do_action( 'edd_profile_editor_password' ); ?>
			</p>
			<p class="edd_password_change_notice"><?php _e( 'Please note after changing your password, you must log back in.', 'edd' ); ?></p>
			<?php do_action( 'edd_profile_editor_after_password' ); ?>
			<p id="edd_profile_submit_wrap">
				<input type="hidden" name="edd_profile_editor_nonce" value="<?php echo wp_create_nonce( 'edd-profile-editor-nonce' ); ?>"/>
				<input type="hidden" name="edd_action" value="edit_user_profile" />
				<input type="hidden" name="edd_redirect" value="<?php echo esc_url( edd_get_current_page_url() ); ?>" />
				<input name="edd_profile_editor_submit" id="edd_profile_editor_submit" type="submit" class="edd_submit" value="<?php _e( 'Save Changes', 'edd' ); ?>"/>
			</p>
		</fieldset>
	</form><!-- #edd_profile_editor_form -->

	<?php do_action( 'edd_profile_editor_after' ); ?>

	<?php
else:
	echo __( 'You need to login to edit your profile.', 'edd' );
	echo edd_login_form();
endif;
 /**
  * Displays a payment update form
  *
  * @since  x.x
  * @return string
  */
 public function update_payment_form()
 {
     global $user_ID;
     if (!is_user_logged_in()) {
         return;
     }
     if (!EDD_Recurring_Customer::is_customer_active($user_ID)) {
         return;
     }
     if ('cancelled' === EDD_Recurring_Customer::get_customer_status($user_ID)) {
         return;
     }
     // Gateways can choose to show the form or not by using this filter
     $show_cc_form = apply_filters('edd_recurring_customer_can_update_card', false, $user_ID);
     if (!$show_cc_form) {
         $form_fields = array();
         $form_fields['cc_number'] = array('type' => 'text', 'options' => array('name' => 'edd-recurring-card-number', 'label' => __('Credit Card Number', 'edd-recurring'), 'placeholder' => __('Credit Card Number', 'edd-recurring'), 'autocomplete' => false));
         $form_fields['cc_name'] = array('type' => 'text', 'options' => array('name' => 'edd-recurring-card-name', 'label' => __('Name on Card', 'edd-recurring'), 'placeholder' => __('Name on Card', 'edd-recurring'), 'autocomplete' => true));
         $form_fields['cvc_number'] = array('type' => 'text', 'options' => array('name' => 'edd-recurring-cvc-number', 'class' => 'small-text', 'label' => __('CVC Number', 'edd-recurring'), 'placeholder' => __('###', 'edd-recurring'), 'autocomplete' => false));
         $form_fields['exp_head'] = array('type' => 'legend', 'options' => array('text' => __('Card Expiration', 'edd-recurring')));
         $form_fields['exp_month'] = array('type' => 'month_dropdown');
         $form_fields['exp_year'] = array('type' => 'year_dropdown', 'number_of_years' => 10);
         $elements = apply_filters('edd_recurring_update_form_elements', $form_fields, $user_ID);
     }
     $form_output = '';
     if (isset($_GET['updated']) && $_GET['updated'] == true && !edd_get_errors()) {
         $form_output = '<p class="edd_success"><strong>' . __('Success', 'edd') . ':</strong> ' . __('Your profile has been edited successfully.', 'edd') . '</p>';
     }
     $form_output .= '<div id="edd-recurring-update-wrapper">';
     $form_output .= '<form action="' . remove_query_arg('updated', edd_get_current_page_url()) . '" id="edd-recurring-form" method="POST">';
     $form_input_html = '';
     if (!$show_cc_form) {
         // Iterate through all the form elements, and add them to the HTML
         foreach ($elements as $element) {
             switch ($element['type']) {
                 case 'month_dropdown':
                     $form_input_html .= EDD()->html->{$element}['type']();
                     break;
                 case 'year_dropdown':
                     $form_input_html .= EDD()->html->{$element}['type']('edd-recurring-exp-year', null, 0, $element['number_of_years']);
                     break;
                 case 'legend':
                     $form_input_html .= '<legend>' . $element['options']['text'] . '</legend>';
                     break;
                 default:
                     $form_input_html .= EDD()->html->{$element}['type']($element['options']);
                     $form_input_html .= '<br />';
                     break;
             }
         }
     }
     ob_start();
     edd_print_errors();
     $form_output .= ob_get_clean();
     $form_output .= apply_filters('edd_recurring_update_form_html', $form_input_html, $user_ID);
     $recurring_gateway = apply_filters('edd_recurring_update_gateway', '', $user_ID);
     $form_output .= '<input name="edd-recurring-update-gateway" type="hidden" value="' . $recurring_gateway . '" />';
     $form_output .= wp_nonce_field('update-payment', 'edd_recurring_update_nonce', true, false);
     $form_output .= '<input type="hidden" name="edd_action" value="recurring_update_payment" />';
     $form_output .= '<input type="submit" name="edd-recurring-update-submit" id="edd-recurring-update-submit" value="' . esc_attr(__('Update Payment', 'edd-recurring')) . '" />';
     $form_output .= '</form>';
     $form_output .= '</div>';
     return '<div id="edd_checkout_form_wrap">' . $form_output . '</div>';
 }
/**
 * Current Page URL
 *
 * @package  Easy Digital Downloads - Social Login
 * @since 1.0.0
 */
function edd_slg_get_current_page_url()
{
    $curent_page_url = remove_query_arg(array('oauth_token', 'oauth_verifier'), edd_get_current_page_url());
    return $curent_page_url;
}
/**
 * The payment mode select form
 *
 * @access      public
 * @since       1.2.2
 * @return      void
*/
function edd_payment_mode_select()
{
    $gateways = edd_get_enabled_payment_gateways();
    $page_URL = edd_get_current_page_url();
    do_action('edd_payment_mode_top');
    ?>
	<form id="edd_payment_mode" action="<?php 
    echo $page_URL;
    ?>
" method="GET">
		<fieldset id="edd_payment_mode_select">
			<?php 
    do_action('edd_payment_mode_before_gateways');
    ?>
			<p id="edd-payment-mode-wrap">
				<?php 
    echo '<select class="edd-select" name="payment-mode" id="edd-gateway">';
    echo '<option value="0">' . __('Select payment method', 'edd') . '</option>';
    foreach ($gateways as $gateway_id => $gateway) {
        echo '<option value="' . $gateway_id . '">' . $gateway['checkout_label'] . '</option>';
    }
    echo '</select>';
    ?>
			</p>
			<?php 
    do_action('edd_payment_mode_after_gateways');
    ?>
		</fieldset>
		<fieldset id="edd_payment_mode_submit" class="edd-no-js">
			<p id="edd-next-submit-wrap">
				<?php 
    echo edd_checkout_button_next();
    ?>
			</p>
		</fieldset>
	</form>
	<div id="edd_purchase_form_wrap"></div><!-- the checkout fields are loaded into this-->
	<?php 
    do_action('edd_payment_mode_bottom');
}
/**
 * Renders the payment mode form by getting all the enabled payment gateways and
 * outputting them as radio buttons for the user to choose the payment gateway. If
 * a default payment gateway has been chosen from the EDD Settings, it will be
 * automatically selected.
 *
 * @since 1.2.2
 * @return void
 */
function edd_payment_mode_select()
{
    $gateways = edd_get_enabled_payment_gateways(true);
    $page_URL = edd_get_current_page_url();
    do_action('edd_payment_mode_top');
    ?>
	<?php 
    if (edd_is_ajax_disabled()) {
        ?>
	<form id="edd_payment_mode" action="<?php 
        echo $page_URL;
        ?>
" method="GET">
	<?php 
    }
    ?>
		<fieldset id="edd_payment_mode_select">
			<?php 
    do_action('edd_payment_mode_before_gateways_wrap');
    ?>
			<div id="edd-payment-mode-wrap">
				<span class="edd-payment-mode-label"><?php 
    _e('Select Payment Method', 'edd');
    ?>
</span><br/>
				<?php 
    do_action('edd_payment_mode_before_gateways');
    foreach ($gateways as $gateway_id => $gateway) {
        $checked = checked($gateway_id, edd_get_default_gateway(), false);
        $checked_class = $checked ? ' edd-gateway-option-selected' : '';
        echo '<label for="edd-gateway-' . esc_attr($gateway_id) . '" class="edd-gateway-option' . $checked_class . '" id="edd-gateway-option-' . esc_attr($gateway_id) . '">';
        echo '<input type="radio" name="payment-mode" class="edd-gateway" id="edd-gateway-' . esc_attr($gateway_id) . '" value="' . esc_attr($gateway_id) . '"' . $checked . '>' . esc_html($gateway['checkout_label']);
        echo '</label>';
    }
    do_action('edd_payment_mode_after_gateways');
    ?>
			</div>
			<?php 
    do_action('edd_payment_mode_after_gateways_wrap');
    ?>
		</fieldset>
		<fieldset id="edd_payment_mode_submit" class="edd-no-js">
			<p id="edd-next-submit-wrap">
				<?php 
    echo edd_checkout_button_next();
    ?>
			</p>
		</fieldset>
	<?php 
    if (edd_is_ajax_disabled()) {
        ?>
	</form>
	<?php 
    }
    ?>
	<div id="edd_purchase_form_wrap"></div><!-- the checkout fields are loaded into this-->
	<?php 
    do_action('edd_payment_mode_bottom');
}
/**
 * Returns the URL to remove an item from the cart
 *
 * @since 1.0
 * @global $post
 * @param string $fee_id Fee ID
 * @return string $remove_url URL to remove the cart item
 */
function edd_remove_cart_fee_url($fee_id = '')
{
    global $post;
    if (defined('DOING_AJAX')) {
        $current_page = edd_get_checkout_uri();
    } else {
        if (is_page()) {
            $current_page = add_query_arg('page_id', $post->ID, home_url('index.php'));
        } else {
            if (is_singular()) {
                $current_page = add_query_arg('p', $post->ID, home_url('index.php'));
            } else {
                $current_page = edd_get_current_page_url();
            }
        }
    }
    $remove_url = add_query_arg(array('fee' => $fee_id, 'edd_action' => 'remove_fee'), $current_page);
    return apply_filters('edd_remove_fee_url', $remove_url);
}
/**
 * Login Form
 *
 * @access      private
 * @since       1.0
 * @return      string
*/
function edd_login_form($redirect = '')
{
    global $edd_options, $post;
    if ($redirect == '') {
        $redirect = edd_get_current_page_url();
    }
    ob_start();
    if (!is_user_logged_in()) {
        ?>
		<?php 
        // show any error messages after form submission
        edd_print_errors();
        ?>

		<form id="edd_login_form"  class="edd_form" action="" method="post">
			<fieldset>
				<legend><?php 
        _e('Log into Your Account', 'edd');
        ?>
</legend>
				<p>
					<label for="edd_user_Login"><?php 
        _e('Username', 'edd');
        ?>
</label>
					<input name="edd_user_login" id="edd_user_login" class="required" type="text" title="<?php 
        _e('Username', 'edd');
        ?>
"/>
				</p>
				<p>
					<label for="edd_user_pass"><?php 
        _e('Password', 'edd');
        ?>
</label>
					<input name="edd_user_pass" id="edd_user_pass" class="password required" type="password"/>
				</p>
				<p>
					<input type="hidden" name="edd_redirect" value="<?php 
        echo $redirect;
        ?>
"/>
					<input type="hidden" name="edd_login_nonce" value="<?php 
        echo wp_create_nonce('edd-login-nonce');
        ?>
"/>
					<input type="hidden" name="edd_action" value="user_login"/>
					<input id="edd_login_submit" type="submit" class="edd_submit" value="<?php 
        _e('Login', 'edd');
        ?>
"/>
				</p>
				<p class="edd-lost-password">
					<a href="<?php 
        echo wp_lostpassword_url();
        ?>
" title="<?php 
        _e('Lost Password', 'edd');
        ?>
">
						<?php 
        _e('Lost Password?', 'edd');
        ?>
					</a>
				</p>
			</fieldset>
		</form>
	<?php 
    } else {
        echo '<p class="edd-logged-in">' . __('You are already logged in', 'edd') . '</p>';
    }
    return ob_get_clean();
}
 /**
  * Calculate Discount towards Points
  * 
  * Handles to calculate the discount towards points
  * 
  * @package Easy Digital Downloads - Points and Rewards
  * @since 1.0.0
  **/
 public function edd_points_redeem_points()
 {
     global $current_user, $edd_options;
     //remove applied points discount
     if (isset($_GET['edd_points_remove_discount']) && !empty($_GET['edd_points_remove_discount']) && $_GET['edd_points_remove_discount'] == 'remove') {
         //get discount towards points
         $gotdiscount = EDD()->fees->get_fee('points_redeem');
         //check redeempoints set and cart is empty
         if (!empty($gotdiscount)) {
             //remove fees towards fees
             EDD()->fees->remove_fee('points_redeem');
             $redirecturl = remove_query_arg('edd_points_remove_discount', get_permalink());
             //redirect to current page
             wp_redirect($redirecturl);
             exit;
         }
     }
     //end if to check remove discount is called or not
     //get points plural label
     $pointslabel = isset($edd_options['edd_points_label']['plural']) && !empty($edd_options['edd_points_label']['plural']) ? $edd_options['edd_points_label']['plural'] : 'Points';
     //check apply discount button is clicked or not
     if (isset($_POST['edd_points_apply_discount']) && !empty($_POST['edd_points_apply_discount']) && $_POST['edd_points_apply_discount'] == __('Apply Discount', 'eddpoints')) {
         //calculate discount towards points
         $available_discount = $this->model->edd_points_get_discount_for_redeeming_points();
         //calcualte the redumption price
         EDD()->fees->add_fee($available_discount * -1, sprintf(__('%s Discount', 'eddpoints'), $pointslabel), 'points_redeem');
         wp_redirect(edd_get_current_page_url());
         exit;
     } else {
         //else change the fees if its changed from backend
         $gotdiscount = EDD()->fees->get_fee('points_redeem');
         if (isset($gotdiscount['amount'])) {
             //calculate discount towards points
             $available_discount = $this->model->edd_points_get_discount_for_redeeming_points();
             //calcualte the redumption price
             EDD()->fees->add_fee($available_discount * -1, sprintf(__('%s Discount', 'eddpoints'), $pointslabel), 'points_redeem');
         }
         //end if to check the user get already points discount or not
     }
 }
Beispiel #12
0
/**
 * Returns the URL to remove an item from the wish list
 *
 * @since 1.0
 * @global $post
 * @param int $cart_key Cart item key
 * @param object $post Download (post) object
 * @param bool $ajax AJAX?
 * @return string $remove_url URL to remove the wish list item
 */
function edd_wl_remove_item_url($cart_key, $post, $ajax = false)
{
    global $post;
    if (is_page()) {
        $current_page = add_query_arg('page_id', $post->ID, home_url('index.php'));
    } else {
        if (is_singular()) {
            $current_page = add_query_arg('p', $post->ID, home_url('index.php'));
        } else {
            $current_page = edd_get_current_page_url();
        }
    }
    $remove_url = add_query_arg(array('cart_item' => $cart_key, 'edd_action' => 'remove'), $current_page);
    return esc_url(apply_filters('edd_remove_item_url', $remove_url));
}
Beispiel #13
0
function eddc_user_commissions()
{
    global $user_ID;
    if (!is_user_logged_in()) {
        return;
    }
    $unpaid_paged = isset($_GET['eddcup']) ? absint($_GET['eddcup']) : 1;
    $paid_paged = isset($_GET['eddcp']) ? absint($_GET['eddcp']) : 1;
    $unpaid_commissions = eddc_get_unpaid_commissions(array('user_id' => $user_ID, 'number' => 20, 'paged' => $unpaid_paged));
    $paid_commissions = eddc_get_paid_commissions(array('user_id' => $user_ID, 'number' => 20, 'paged' => $paid_paged));
    $total_unpaid = eddc_count_user_commissions($user_ID, 'unpaid');
    $total_paid = eddc_count_user_commissions($user_ID, 'paid');
    $unpaid_offset = 20 * ($unpaid_paged - 1);
    $unpaid_total_pages = ceil($total_unpaid / 20);
    $paid_offset = 20 * ($paid_paged - 1);
    $paid_total_pages = ceil($total_paid / 20);
    $stats = '';
    if (eddc_user_has_commissions()) {
        // only show tables if user has commission data
        ob_start();
        ?>
			<div id="edd_user_commissions">

				<!-- unpaid -->
				<div id="edd_user_commissions_unpaid">
					<h3 class="edd_user_commissions_header"><?php 
        _e('Unpaid Commissions', 'eddc');
        ?>
</h3>
					<table id="edd_user_unpaid_commissions_table" class="edd_user_commissions">
						<thead>
							<tr class="edd_user_commission_row">
								<?php 
        do_action('eddc_user_commissions_unpaid_head_row_begin');
        ?>
								<th class="edd_commission_item"><?php 
        _e('Item', 'eddc');
        ?>
</th>
								<th class="edd_commission_amount"><?php 
        _e('Amount', 'eddc');
        ?>
</th>
								<th class="edd_commission_rate"><?php 
        _e('Rate', 'eddc');
        ?>
</th>
								<th class="edd_commission_date"><?php 
        _e('Date', 'eddc');
        ?>
</th>
								<?php 
        do_action('eddc_user_commissions_unpaid_head_row_end');
        ?>
							</tr>
						</thead>
						<tbody>
						<?php 
        $total = (double) 0;
        ?>
						<?php 
        if (!empty($unpaid_commissions)) {
            ?>
							<?php 
            foreach ($unpaid_commissions as $commission) {
                ?>
								<tr class="edd_user_commission_row">
									<?php 
                do_action('eddc_user_commissions_unpaid_row_begin', $commission);
                $item_name = get_the_title(get_post_meta($commission->ID, '_download_id', true));
                $commission_info = get_post_meta($commission->ID, '_edd_commission_info', true);
                $amount = $commission_info['amount'];
                $rate = $commission_info['rate'];
                ?>
									<td class="edd_commission_item"><?php 
                echo esc_html($item_name);
                ?>
</td>
									<td class="edd_commission_amount"><?php 
                echo edd_currency_filter(edd_format_amount($amount));
                ?>
</td>
									<td class="edd_commission_rate"><?php 
                echo $rate . '%';
                ?>
</td>
									<td class="edd_commission_date"><?php 
                echo date_i18n(get_option('date_format'), strtotime($commission->post_date));
                ?>
</td>
									<?php 
                do_action('eddc_user_commissions_unpaid_row_end', $commission);
                ?>
								</tr>
							<?php 
            }
            ?>
						<?php 
        } else {
            ?>
							<tr class="edd_user_commission_row edd_row_empty">
								<td colspan="4"><?php 
            _e('No unpaid commissions', 'eddc');
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
						</tbody>
					</table>
					<div id="edd_user_commissions_unpaid_total"><?php 
        _e('Total unpaid:', 'eddc');
        ?>
&nbsp;<?php 
        echo edd_currency_filter(edd_format_amount(eddc_get_unpaid_totals($user_ID)));
        ?>
</div>

					<div id="edd_commissions_unpaid_pagination" class="navigation">
					<?php 
        $big = 999999;
        echo paginate_links(array('base' => remove_query_arg('eddcup', edd_get_current_page_url()) . '%_%#edd_user_commissions_unpaid', 'format' => '?eddcup=%#%', 'current' => max(1, $unpaid_paged), 'total' => $unpaid_total_pages));
        ?>
					</div>

				</div><!--end #edd_user_commissions_unpaid-->

				<!-- paid -->
				<div id="edd_user_commissions_paid">
					<h3 class="edd_user_commissions_header"><?php 
        _e('Paid Commissions', 'eddc');
        ?>
</h3>
					<table id="edd_user_paid_commissions_table" class="edd_user_commissions">
						<thead>
							<tr class="edd_user_commission_row">
								<?php 
        do_action('eddc_user_commissions_paid_head_row_begin');
        ?>
								<th class="edd_commission_item"><?php 
        _e('Item', 'eddc');
        ?>
</th>
								<th class="edd_commission_amount"><?php 
        _e('Amount', 'eddc');
        ?>
</th>
								<th class="edd_commission_rate"><?php 
        _e('Rate', 'eddc');
        ?>
</th>
								<th class="edd_commission_date"><?php 
        _e('Date', 'eddc');
        ?>
</th>
								<?php 
        do_action('eddc_user_commissions_paid_head_row_end');
        ?>
							</tr>
						</thead>
						<tbody>
						<?php 
        $total = (double) 0;
        ?>
						<?php 
        if (!empty($paid_commissions)) {
            ?>
							<?php 
            foreach ($paid_commissions as $commission) {
                ?>
								<tr class="edd_user_commission_row">
									<?php 
                do_action('eddc_user_commissions_paid_row_begin', $commission);
                $item_name = get_the_title(get_post_meta($commission->ID, '_download_id', true));
                $commission_info = get_post_meta($commission->ID, '_edd_commission_info', true);
                $amount = $commission_info['amount'];
                $rate = $commission_info['rate'];
                ?>
									<td class="edd_commission_item"><?php 
                echo esc_html($item_name);
                ?>
</td>
									<td class="edd_commission_amount"><?php 
                echo edd_currency_filter($amount);
                ?>
</td>
									<td class="edd_commission_rate"><?php 
                echo $rate . '%';
                ?>
</td>
									<td class="edd_commission_date"><?php 
                echo date_i18n(get_option('date_format'), strtotime($commission->post_date));
                ?>
</td>
									<?php 
                do_action('eddc_user_commissions_paid_row_end', $commission);
                ?>
								</tr>
							<?php 
            }
            ?>
						<?php 
        } else {
            ?>
							<tr class="edd_user_commission_row edd_row_empty">
								<td colspan="4"><?php 
            _e('No paid commissions', 'eddc');
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
						</tbody>
					</table>
					<div id="edd_user_commissions_paid_total"><?php 
        _e('Total paid:', 'eddc');
        ?>
&nbsp;<?php 
        echo edd_currency_filter(edd_format_amount(eddc_get_paid_totals($user_ID)));
        ?>
</div>

					<div id="edd_commissions_paid_pagination" class="navigation">
					<?php 
        $big = 999999;
        echo paginate_links(array('base' => remove_query_arg('eddcp', edd_get_current_page_url()) . '%_%#edd_user_commissions_paid', 'format' => '?eddcp=%#%', 'current' => max(1, $paid_paged), 'total' => $paid_total_pages));
        ?>
					</div>

					<div id="edd_commissions_export">
						<p><strong><?php 
        _e('Export Paid Commissions', 'eddc');
        ?>
</strong></p>
						<form method="post" action="<?php 
        echo home_url();
        ?>
">
							<?php 
        echo EDD()->html->month_dropdown();
        ?>
							<?php 
        echo EDD()->html->year_dropdown();
        ?>
							<input type="hidden" name="edd_action" value="generate_commission_export"/>
							<input type="submit" class="edd-submit button" value="<?php 
        _e('Download CSV', 'eddc');
        ?>
"/>
						</form><br/>
					</div>

				</div><!--end #edd_user_commissions_paid-->

			</div><!--end #edd_user_commissions-->
		<?php 
        $stats = apply_filters('edd_user_commissions_display', ob_get_clean());
    }
    return $stats;
}
/**
 * Given a user id, provide a detailed list of commissions
 *
 * @param  integer $user_id Given a user id, get their commissions details
 * @return string           HTML markup for the commissions details
 */
function eddc_user_commissions($user_id = 0)
{
    $user_id = empty($user_id) ? get_current_user_id() : $user_id;
    // If still empty, exit
    if (empty($user_id)) {
        return;
    }
    $per_page = 20;
    $unpaid_paged = isset($_GET['eddcup']) ? absint($_GET['eddcup']) : 1;
    $paid_paged = isset($_GET['eddcp']) ? absint($_GET['eddcp']) : 1;
    $revoked_paged = isset($_GET['eddcrp']) ? absint($_GET['eddcrp']) : 1;
    $unpaid_commissions = eddc_get_unpaid_commissions(array('user_id' => $user_id, 'number' => $per_page, 'paged' => $unpaid_paged));
    $paid_commissions = eddc_get_paid_commissions(array('user_id' => $user_id, 'number' => $per_page, 'paged' => $paid_paged));
    $revoked_commissions = eddc_get_revoked_commissions(array('user_id' => $user_id, 'number' => $per_page, 'paged' => $paid_paged));
    $total_unpaid = eddc_count_user_commissions($user_id, 'unpaid');
    $total_paid = eddc_count_user_commissions($user_id, 'paid');
    $total_revoked = eddc_count_user_commissions($user_id, 'revoked');
    $unpaid_offset = $per_page * ($unpaid_paged - 1);
    $unpaid_total_pages = ceil($total_unpaid / $per_page);
    $paid_offset = $per_page * ($paid_paged - 1);
    $paid_total_pages = ceil($total_paid / $per_page);
    $revoked_offset = $per_page * ($revoked_paged - 1);
    $revoked_total_pages = ceil($total_revoked / $per_page);
    $page_prefix = false !== strpos(edd_get_current_page_url(), '?') ? '&' : '?';
    $stats = '';
    if (eddc_user_has_commissions($user_id)) {
        // only show tables if user has commission data
        ob_start();
        ?>
			<div id="edd_user_commissions">

				<!-- unpaid -->
				<div id="edd_user_commissions_unpaid">
					<h3 class="edd_user_commissions_header"><?php 
        _e('Unpaid Commissions', 'eddc');
        ?>
</h3>
					<table id="edd_user_unpaid_commissions_table" class="edd_user_commissions">
						<thead>
							<tr class="edd_user_commission_row">
								<?php 
        do_action('eddc_user_commissions_unpaid_head_row_begin');
        ?>
								<th class="edd_commission_item"><?php 
        _e('Item', 'eddc');
        ?>
</th>
								<th class="edd_commission_amount"><?php 
        _e('Amount', 'eddc');
        ?>
</th>
								<th class="edd_commission_rate"><?php 
        _e('Rate', 'eddc');
        ?>
</th>
								<th class="edd_commission_date"><?php 
        _e('Date', 'eddc');
        ?>
</th>
								<?php 
        do_action('eddc_user_commissions_unpaid_head_row_end');
        ?>
							</tr>
						</thead>
						<tbody>
						<?php 
        $total = (double) 0;
        ?>
						<?php 
        if (!empty($unpaid_commissions)) {
            ?>
							<?php 
            foreach ($unpaid_commissions as $commission) {
                ?>
								<tr class="edd_user_commission_row">
									<?php 
                do_action('eddc_user_commissions_unpaid_row_begin', $commission);
                $item_name = get_the_title(get_post_meta($commission->ID, '_download_id', true));
                $commission_info = get_post_meta($commission->ID, '_edd_commission_info', true);
                $amount = $commission_info['amount'];
                $rate = $commission_info['rate'];
                ?>
									<td class="edd_commission_item"><?php 
                echo esc_html($item_name);
                ?>
</td>
									<td class="edd_commission_amount">
										<?php 
                echo edd_currency_filter(edd_format_amount(edd_sanitize_amount($amount)));
                ?>
										<?php 
                if (eddc_commission_is_renewal($commission->ID)) {
                    ?>
											&nbsp;&olarr;
										<?php 
                }
                ?>
									</td>
									<td class="edd_commission_rate"><?php 
                echo $rate . '%';
                ?>
</td>
									<td class="edd_commission_date"><?php 
                echo date_i18n(get_option('date_format'), strtotime($commission->post_date));
                ?>
</td>
									<?php 
                do_action('eddc_user_commissions_unpaid_row_end', $commission);
                ?>
								</tr>
							<?php 
            }
            ?>
						<?php 
        } else {
            ?>
							<tr class="edd_user_commission_row edd_row_empty">
								<td colspan="4"><?php 
            _e('No unpaid commissions', 'eddc');
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
						</tbody>
					</table>
					<div id="edd_user_commissions_unpaid_total"><?php 
        _e('Total unpaid:', 'eddc');
        ?>
&nbsp;<?php 
        echo edd_currency_filter(edd_format_amount(eddc_get_unpaid_totals($user_id)));
        ?>
</div>

					<div id="edd_commissions_unpaid_pagination" class="navigation">
					<?php 
        $big = 999999;
        $search_for = array($big, '#038;');
        $replace_with = array('%#%', '&');
        echo paginate_links(array('base' => remove_query_arg('eddcup', str_replace($search_for, $replace_with, edd_get_current_page_url())) . '%_%', 'format' => $page_prefix . 'eddcup=%#%', 'current' => max(1, $unpaid_paged), 'total' => $unpaid_total_pages));
        ?>
					</div>

				</div><!--end #edd_user_commissions_unpaid-->

				<!-- paid -->
				<div id="edd_user_commissions_paid">
					<h3 class="edd_user_commissions_header"><?php 
        _e('Paid Commissions', 'eddc');
        ?>
</h3>
					<table id="edd_user_paid_commissions_table" class="edd_user_commissions">
						<thead>
							<tr class="edd_user_commission_row">
								<?php 
        do_action('eddc_user_commissions_paid_head_row_begin');
        ?>
								<th class="edd_commission_item"><?php 
        _e('Item', 'eddc');
        ?>
</th>
								<th class="edd_commission_amount"><?php 
        _e('Amount', 'eddc');
        ?>
</th>
								<th class="edd_commission_rate"><?php 
        _e('Rate', 'eddc');
        ?>
</th>
								<th class="edd_commission_date"><?php 
        _e('Date', 'eddc');
        ?>
</th>
								<?php 
        do_action('eddc_user_commissions_paid_head_row_end');
        ?>
							</tr>
						</thead>
						<tbody>
						<?php 
        $total = (double) 0;
        ?>
						<?php 
        if (!empty($paid_commissions)) {
            ?>
							<?php 
            foreach ($paid_commissions as $commission) {
                ?>
								<tr class="edd_user_commission_row">
									<?php 
                do_action('eddc_user_commissions_paid_row_begin', $commission);
                $item_name = get_the_title(get_post_meta($commission->ID, '_download_id', true));
                $commission_info = get_post_meta($commission->ID, '_edd_commission_info', true);
                $amount = $commission_info['amount'];
                $rate = $commission_info['rate'];
                ?>
									<td class="edd_commission_item"><?php 
                echo esc_html($item_name);
                ?>
</td>
									<td class="edd_commission_amount">
										<?php 
                echo edd_currency_filter(edd_format_amount(edd_sanitize_amount($amount)));
                ?>
										<?php 
                if (eddc_commission_is_renewal($commission->ID)) {
                    ?>
											&nbsp;&olarr;
										<?php 
                }
                ?>
									</td>
									<td class="edd_commission_rate"><?php 
                echo $rate . '%';
                ?>
</td>
									<td class="edd_commission_date"><?php 
                echo date_i18n(get_option('date_format'), strtotime($commission->post_date));
                ?>
</td>
									<?php 
                do_action('eddc_user_commissions_paid_row_end', $commission);
                ?>
								</tr>
							<?php 
            }
            ?>
						<?php 
        } else {
            ?>
							<tr class="edd_user_commission_row edd_row_empty">
								<td colspan="4"><?php 
            _e('No paid commissions', 'eddc');
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
						</tbody>
					</table>
					<div id="edd_user_commissions_paid_total"><?php 
        _e('Total paid:', 'eddc');
        ?>
&nbsp;<?php 
        echo edd_currency_filter(edd_format_amount(eddc_get_paid_totals($user_id)));
        ?>
</div>

					<div id="edd_commissions_paid_pagination" class="navigation">
					<?php 
        $big = 999999;
        $search_for = array($big, '#038;');
        $replace_with = array('%#%', '&');
        echo paginate_links(array('base' => remove_query_arg('eddcp', str_replace($search_for, $replace_with, edd_get_current_page_url())) . '%_%', 'format' => $page_prefix . 'eddcp=%#%', 'current' => max(1, $paid_paged), 'total' => $paid_total_pages));
        ?>
					</div>

				</div><!--end #edd_user_commissions_paid-->

				<!-- revoked -->
				<div id="edd_user_commissions_revoked">
					<h3 class="edd_user_commissions_header"><?php 
        _e('Revoked Commissions', 'eddc');
        ?>
</h3>
					<table id="edd_user_revoked_commissions_table" class="edd_user_commissions">
						<thead>
							<tr class="edd_user_commission_row">
								<?php 
        do_action('eddc_user_commissions_revoked_head_row_begin');
        ?>
								<th class="edd_commission_item"><?php 
        _e('Item', 'eddc');
        ?>
</th>
								<th class="edd_commission_amount"><?php 
        _e('Amount', 'eddc');
        ?>
</th>
								<th class="edd_commission_rate"><?php 
        _e('Rate', 'eddc');
        ?>
</th>
								<th class="edd_commission_date"><?php 
        _e('Date', 'eddc');
        ?>
</th>
								<?php 
        do_action('eddc_user_commissions_revoked_head_row_end');
        ?>
							</tr>
						</thead>
						<tbody>
						<?php 
        $total = (double) 0;
        ?>
						<?php 
        if (!empty($revoked_commissions)) {
            ?>
							<?php 
            foreach ($revoked_commissions as $commission) {
                ?>
								<tr class="edd_user_commission_row">
									<?php 
                do_action('eddc_user_commissions_revoked_row_begin', $commission);
                $item_name = get_the_title(get_post_meta($commission->ID, '_download_id', true));
                $commission_info = get_post_meta($commission->ID, '_edd_commission_info', true);
                $amount = $commission_info['amount'];
                $rate = $commission_info['rate'];
                ?>
									<td class="edd_commission_item"><?php 
                echo esc_html($item_name);
                ?>
</td>
									<td class="edd_commission_amount">
										<?php 
                echo edd_currency_filter(edd_format_amount(edd_sanitize_amount($amount)));
                ?>
										<?php 
                if (eddc_commission_is_renewal($commission->ID)) {
                    ?>
											&nbsp;&olarr;
										<?php 
                }
                ?>
									</td>
									<td class="edd_commission_rate"><?php 
                echo $rate . '%';
                ?>
</td>
									<td class="edd_commission_date"><?php 
                echo date_i18n(get_option('date_format'), strtotime($commission->post_date));
                ?>
</td>
									<?php 
                do_action('eddc_user_commissions_revoked_row_end', $commission);
                ?>
								</tr>
							<?php 
            }
            ?>
						<?php 
        } else {
            ?>
							<tr class="edd_user_commission_row edd_row_empty">
								<td colspan="4"><?php 
            _e('No revoked commissions', 'eddc');
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
						</tbody>
					</table>
					<div id="edd_user_commissions_revoked_total"><?php 
        _e('Total revoked:', 'eddc');
        ?>
&nbsp;<?php 
        echo edd_currency_filter(edd_format_amount(eddc_get_revoked_totals($user_id)));
        ?>
</div>

					<div id="edd_commissions_revoked_pagination" class="navigation">
					<?php 
        $big = 999999;
        $search_for = array($big, '#038;');
        $replace_with = array('%#%', '&');
        echo paginate_links(array('base' => remove_query_arg('eddcrp', str_replace($search_for, $replace_with, edd_get_current_page_url())) . '%_%', 'format' => $page_prefix . 'eddcrp=%#%', 'current' => max(1, $revoked_paged), 'total' => $revoked_total_pages));
        ?>
					</div>

				</div><!--end #edd_user_commissions_revoked-->

				<?php 
        if (!empty($total_paid)) {
            ?>
				<div id="edd_commissions_export">
					<?php 
            $args = array('user_id' => $user_id, 'number' => 1, 'orderby' => 'date', 'order' => 'ASC');
            $first_commission = eddc_get_paid_commissions($args);
            $first_year = date('Y', strtotime($first_commission[0]->post_date));
            $years_back = date('Y', current_time('timestamp')) - $first_year;
            $url = is_admin() ? admin_url('index.php') : home_url();
            ?>
					<h3><?php 
            _e('Export Paid Commissions', 'eddc');
            ?>
</h3>
					<form method="post" action="<?php 
            echo $url;
            ?>
">
						<?php 
            echo EDD()->html->month_dropdown();
            ?>
						<?php 
            echo EDD()->html->year_dropdown('year', 0, $years_back, 0);
            ?>
						<input type="hidden" name="user_id" value="<?php 
            echo $user_id;
            ?>
"/>
						<input type="hidden" name="edd_action" value="generate_commission_export"/>
						<input type="submit" class="edd-submit button" value="<?php 
            _e('Download CSV', 'eddc');
            ?>
"/>
					</form>
				</div>
				<?php 
        }
        ?>


			</div><!--end #edd_user_commissions-->
		<?php 
        $stats = apply_filters('edd_user_commissions_display', ob_get_clean());
    }
    return $stats;
}
    /**
     * Redeem Points Markup
     * 
     * Handles to show redeem points markup
     * 
     * @package Easy Digital Downloads - Points and Rewards
     * @since 1.0.0
     **/
    public function edd_points_redeem_point_markup()
    {
        global $current_user, $edd_options;
        if (!isset($_GET['payment-mode']) && count(edd_get_enabled_payment_gateways()) > 1 && !edd_is_ajax_enabled()) {
            return;
        }
        // Only show once a payment method has been selected if ajax is disabled
        //get points plural label
        $plurallabel = isset($edd_options['edd_points_label']['plural']) && !empty($edd_options['edd_points_label']['plural']) ? $edd_options['edd_points_label']['plural'] : 'Point';
        //get discount got by user via points
        $gotdiscount = EDD()->fees->get_fee('points_redeem');
        //get message from settings
        $redemptionmessage = $edd_options['edd_points_reedem_cart_messages'];
        //calculate discount towards points
        $available_discount = $this->model->edd_points_get_discount_for_redeeming_points();
        $button_color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : '';
        if (!empty($available_discount) && !empty($redemptionmessage) && empty($gotdiscount)) {
            //get discounte price from points
            $discountedpoints = $this->model->edd_points_calculate_points($available_discount);
            //get points label to show to user
            $points_label = $this->model->edd_points_get_points_label($discountedpoints);
            //display price to show to user
            $displaydiscprice = edd_currency_filter($available_discount);
            //show message on checkout page
            $points_replace = array("{points}", "{points_label}", "{points_value}");
            $replace_message = array($discountedpoints, $points_label, $displaydiscprice);
            $message = $this->model->edd_points_replace_array($points_replace, $replace_message, $redemptionmessage);
            ?>
 
			<fieldset class="edd-points-redeem-points-wrap">
				<form method="POST" action="" >
					<input type="submit" id="edd_points_apply_discount" name="edd_points_apply_discount" class="button edd-submit <?php 
            _e($button_color);
            ?>
 edd-points-apply-discount-button" value="<?php 
            _e('Apply Discount', 'eddpoints');
            ?>
" />
				</form>
				<div class="edd-points-redeem-message"><?php 
            echo $message;
            ?>
</div><!--.edd-points-checkout-message-->
			</fieldset><!--.edd-points-redeem-points-wrap-->
			<?php 
        }
        //end if cart total not empty
        //if points discount applied then show remove link
        if (!empty($gotdiscount)) {
            $removfeesurl = add_query_arg(array('edd_points_remove_discount' => 'remove'), edd_get_current_page_url());
            ?>
				<fieldset class="edd-points-checkout-message">
					<a href="<?php 
            echo $removfeesurl;
            ?>
" class="button edd-point-remove-discount-link edd-points-float-right"><?php 
            _e('Remove', 'eddpoints');
            ?>
</a>
					<div class="edd-points-remove-disocunt-message"><?php 
            printf(__('Remove %s Discount', 'eddpoints'), $plurallabel);
            ?>
</div><!--.edd-points-checkout-message-->
				</fieldset><!--.edd-points-redeem-points-wrap-->
			<?php 
        }
    }
/**
 * Receipt Shortcode
 *
 * Shows an order receipt.
 *
 * @since 1.4
 * @param array $atts Shortcode attributes
 * @param string $content
 * @return string
 */
function edd_receipt_shortcode($atts, $content = null)
{
    global $edd_receipt_args;
    $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'easy-digital-downloads'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt');
    $session = edd_get_purchase_session();
    if (isset($_GET['payment_key'])) {
        $payment_key = urldecode($_GET['payment_key']);
    } elseif ($edd_receipt_args['payment_key']) {
        $payment_key = $edd_receipt_args['payment_key'];
    } else {
        if ($session) {
            $payment_key = $session['purchase_key'];
        }
    }
    // No key found
    if (!isset($payment_key)) {
        return '<p class="edd-alert edd-alert-error">' . $edd_receipt_args['error'] . '</p>';
    }
    $payment_id = edd_get_purchase_id_by_key($payment_key);
    $user_can_view = edd_can_view_receipt($payment_key);
    // Key was provided, but user is logged out. Offer them the ability to login and view the receipt
    if (!$user_can_view && !empty($payment_key) && !is_user_logged_in() && !edd_is_guest_payment($payment_id)) {
        global $edd_login_redirect;
        $edd_login_redirect = edd_get_current_page_url();
        ob_start();
        echo '<p class="edd-alert edd-alert-warn">' . __('You must be logged in to view this payment receipt.', 'easy-digital-downloads') . '</p>';
        edd_get_template_part('shortcode', 'login');
        $login_form = ob_get_clean();
        return $login_form;
    }
    /*
     * Check if the user has permission to view the receipt
     *
     * If user is logged in, user ID is compared to user ID of ID stored in payment meta
     *
     * Or if user is logged out and purchase was made as a guest, the purchase session is checked for
     *
     * Or if user is logged in and the user can view sensitive shop data
     *
     */
    if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) {
        return '<p class="edd-alert edd-alert-error">' . $edd_receipt_args['error'] . '</p>';
    }
    ob_start();
    edd_get_template_part('shortcode', 'receipt');
    $display = ob_get_clean();
    return $display;
}
					<input name="edd_new_user_pass2" id="edd_new_user_pass2" class="password edd-input" type="password"/>
				</p>
				
				<p><?php 
    _e('Please note after changing your password, you must log back in.', 'edd');
    ?>
</p>

				<p>
					<input type="hidden" name="edd_profile_editor_nonce" value="<?php 
    echo wp_create_nonce('edd-profile-editor-nonce');
    ?>
"/>
					<input type="hidden" name="edd_action" value="edit_user_profile" />
					<input type="hidden" name="edd_redirect" value="<?php 
    echo esc_url(edd_get_current_page_url());
    ?>
" />
					<input name="edd_profile_editor_submit" id="edd_profile_editor_submit" type="submit" class="edd_submit" value="<?php 
    _e('Save Changes', 'edd');
    ?>
"/>
				</p>
			</div>

		</fieldset>
	</form><!-- #edd_profile_editor_form -->
	<?php 
} else {
    echo __('You need to login to edit your profile.', 'edd');
    echo edd_login_form();
/**
 * Remove Item URL
 *
 * Returns the URL to remove an item.
 *
 * @access      public
 * @since       1.0
 * @return      string
*/
function edd_remove_item_url($cart_key, $post, $ajax = false)
{
    global $post;
    $current_page = edd_get_current_page_url();
    $remove_url = add_query_arg(array('cart_item' => $cart_key, 'edd_action' => 'remove'), $current_page);
    return apply_filters('edd_remove_item_url', $remove_url);
}
/**
 * Returns the URL to remove an item from the cart
 *
 * @since 1.0
 * @global $post
 * @param string $fee_id Fee ID
 * @return string $remove_url URL to remove the cart item
 */
function edd_remove_cart_fee_url($fee_id = '')
{
    global $post;
    if (defined('DOING_AJAX')) {
        $current_page = edd_get_checkout_uri();
    } else {
        $current_page = edd_get_current_page_url();
    }
    $remove_url = add_query_arg(array('fee' => $fee_id, 'edd_action' => 'remove_fee', 'nocache' => current_time('timestamp')), $current_page);
    return apply_filters('edd_remove_fee_url', $remove_url);
}
/**
 * Handle redirections for SSL enforced checkouts
 *
 * @since 2.0
 * @return void
 */
function edd_enforced_ssl_redirect_handler()
{
    if (!edd_is_ssl_enforced() || !edd_is_checkout() || is_admin() || is_ssl()) {
        return;
    }
    if (edd_is_checkout() && false !== strpos(edd_get_current_page_url(), 'https://')) {
        return;
    }
    $uri = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    wp_safe_redirect($uri);
    exit;
}