Skip to content

Commit

Permalink
Remove diff code block from wc-customer
Browse files Browse the repository at this point in the history
  • Loading branch information
toddlahman committed Jun 27, 2014
1 parent bad8225 commit f6c3f4d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 75 deletions.
74 changes: 0 additions & 74 deletions includes/class-wc-customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,81 +550,7 @@ public function get_downloadable_products() {
$downloads = array();

if ( is_user_logged_in() ) {

// Get results from valid orders only
$results = $wpdb->get_results( $wpdb->prepare( "
SELECT permissions.*
FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions as permissions
LEFT JOIN {$wpdb->posts} as posts ON permissions.order_id = posts.ID
WHERE user_id = %s
AND permissions.order_id > 0
AND posts.post_status = 'publish'
AND
(
permissions.downloads_remaining > 0
OR
permissions.downloads_remaining = ''
)
AND
(
permissions.access_expires IS NULL
OR
permissions.access_expires >= %s
)
GROUP BY permissions.download_id
ORDER BY permissions.order_id, permissions.product_id, permissions.permission_id;
", get_current_user_id(), date( 'Y-m-d', current_time( 'timestamp' ) ) ) );

if ( $results ) {
foreach ( $results as $result ) {
if ( ! $order || $order->id != $result->order_id ) {
// new order
$order = new WC_Order( $result->order_id );
$_product = null;
}

// Downloads permitted?
if ( ! $order->is_download_permitted() ) {
continue;
}

if ( ! $_product || $_product->id != $result->product_id ) {
// new product
$file_number = 0;
$_product = get_product( $result->product_id );
}

// Check product exists and has the file
if ( ! $_product || ! $_product->exists() || ! $_product->has_file( $result->download_id ) ) {
continue;
}

$download_file = $_product->get_file( $result->download_id );
// Download name will be 'Product Name' for products with a single downloadable file, and 'Product Name - File X' for products with multiple files
$download_name = apply_filters(
'woocommerce_downloadable_product_name',
$_product->get_title() . ' – ' . $download_file['name'],
$_product,
$result->download_id,
$file_number
);

$downloads[] = array(
'download_url' => add_query_arg( array( 'download_file' => $result->product_id, 'order' => $result->order_key, 'email' => $result->user_email, 'key' => $result->download_id ), home_url( '/' ) ),
'download_id' => $result->download_id,
'product_id' => $result->product_id,
'download_name' => $download_name,
'order_id' => $order->id,
'order_key' => $order->order_key,
'downloads_remaining' => $result->downloads_remaining
);

$file_number++;
}
}

$downloads = wc_get_customer_available_downloads( get_current_user_id() );

}

return apply_filters( 'woocommerce_customer_get_downloadable_products', $downloads );
Expand Down
2 changes: 1 addition & 1 deletion includes/wc-user-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ function wc_get_customer_available_downloads( $customer_id ) {
);

$downloads[] = array(
'download_url' => add_query_arg( array( 'download_file' => $result->product_id, 'order' => $result->order_key, 'email' => $result->user_email, 'key' => $result->download_id ), home_url( '/', 'http' ) ),
'download_url' => add_query_arg( array( 'download_file' => $result->product_id, 'order' => $result->order_key, 'email' => $result->user_email, 'key' => $result->download_id ), home_url( '/' ) ),
'download_id' => $result->download_id,
'product_id' => $result->product_id,
'download_name' => $download_name,
Expand Down

0 comments on commit f6c3f4d

Please sign in to comment.