/**
  * Gets a user's downloadable products if they are logged in
  *
  * @return array Array of downloadable products
  */
 public static function get_downloadable_products()
 {
     global $wpdb;
     $downloads = array();
     if (is_user_logged_in()) {
         $fflcommerce_orders = new fflcommerce_orders();
         $fflcommerce_orders->get_customer_orders(get_current_user_id());
         if ($fflcommerce_orders->orders) {
             $user_info = get_userdata(get_current_user_id());
             foreach ($fflcommerce_orders->orders as $order) {
                 if ($order->status == 'completed') {
                     $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}fflcommerce_downloadable_product_permissions WHERE order_key = %s AND user_id = %d;", $order->order_key, get_current_user_id()));
                     if ($results) {
                         foreach ($results as $result) {
                             $_product = new fflcommerce_product_variation($result->product_id);
                             $download_name = $_product->ID ? get_the_title($_product->ID) : get_the_title($result->product_id);
                             if (isset($_product->variation_data)) {
                                 $download_name .= ' (' . fflcommerce_get_formatted_variation($_product, array(), true) . ')';
                             }
                             $downloads[] = array('download_url' => add_query_arg('download_file', $result->product_id, add_query_arg('order', $result->order_key, add_query_arg('email', $user_info->user_email, home_url()))), 'product_id' => $result->product_id, 'download_name' => $download_name, 'order_key' => $result->order_key, 'downloads_remaining' => $result->downloads_remaining);
                         }
                     }
                 }
             }
         }
     }
     return apply_filters('fflcommerce_downloadable_products', $downloads);
 }
예제 #2
0
    ?>
		<th><span class="nobr"><?php 
    _e('Total', 'fflcommerce');
    ?>
</span></th>
		<th colspan="2"><span class="nobr"><?php 
    _e('Status', 'fflcommerce');
    ?>
</span></th>
		<?php 
    do_action('fflcommerce_my_account_orders_thead');
    ?>
	</tr>
	</thead>
	<tbody><?php 
    $orders = new fflcommerce_orders();
    $orders->get_customer_orders(get_current_user_id(), $recent_orders);
    if ($orders->orders) {
        foreach ($orders->orders as $order) {
            /** @var $order fflcommerce_order */
            if ($order->status == 'pending') {
                foreach ($order->items as $item) {
                    $_product = $order->get_product_from_item($item);
                    $temp = new fflcommerce_product($_product->ID);
                    if ($temp->managing_stock() && (!$temp->is_in_stock() || !$temp->has_enough_stock($item['qty']))) {
                        $order->cancel_order(sprintf(__("Product - %s - is now out of stock -- Canceling Order", 'fflcommerce'), $_product->get_title()));
                        ob_get_clean();
                        wp_safe_redirect(apply_filters('fflcommerce_get_myaccount_page_id', get_permalink(fflcommerce_get_page_id('myaccount'))));
                        exit;
                    }
                }