Merge pull request #1923 from Geczy/fix-invalid-foreach-dll

Fix 'Invalid argument supplied for foreach()' when no file for download
This commit is contained in:
Mike Jolley 2012-12-05 08:28:18 -08:00
commit 5c0c7b4ff5
1 changed files with 4 additions and 2 deletions

View File

@ -980,8 +980,10 @@ function woocommerce_downloadable_product_permissions( $order_id ) {
$product_id = ($item['variation_id']>0) ? $item['variation_id'] : $item['product_id'];
$file_download_paths = apply_filters( 'woocommerce_file_download_paths', get_post_meta( $product_id, '_file_paths', true ), $product_id, $order_id, $item );
foreach ( $file_download_paths as $download_id => $file_path ) {
woocommerce_downloadable_file_permission( $download_id, $product_id, $order );
if ( !empty($file_download_paths) ) {
foreach ( $file_download_paths as $download_id => $file_path ) {
woocommerce_downloadable_file_permission( $download_id, $product_id, $order );
}
}
endif;