From 24c57f35fd554e833f3583b843cbfa6d26084f92 Mon Sep 17 00:00:00 2001 From: Leonard Date: Sat, 19 Oct 2013 13:56:57 +0100 Subject: [PATCH] Fix: Download permissions not granted on order completion. $downloads was being built from a function that tried to read from the permissions table and not from the correct post meta which it actually needed. This resulted in having to manually grant permissions for each order made. Original symptom was download links not appearing on order completion screen or completion e-mail. --- includes/wc-order-functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/wc-order-functions.php b/includes/wc-order-functions.php index 588cefe6676..8220dbaf5d1 100644 --- a/includes/wc-order-functions.php +++ b/includes/wc-order-functions.php @@ -116,9 +116,9 @@ function woocommerce_downloadable_product_permissions( $order_id ) { $_product = $order->get_product_from_item( $item ); if ( $_product && $_product->exists() && $_product->is_downloadable() ) { - $downloads = $order->get_item_downloads( $item ); + $downloads = get_post_meta( $product_id, '_downloadable_files' ) ; - foreach ( $downloads as $download_id => $download ) + foreach ( $downloads[0] as $download_id => $download ) woocommerce_downloadable_file_permission( $download_id, $item['variation_id'] > 0 ? $item['variation_id'] : $item['product_id'], $order ); } }