Show download file names when linking. Shortens links and therefore closes #2631. cc @coenjacobs
This commit is contained in:
parent
8098754913
commit
c247ca0bb7
|
@ -1159,7 +1159,9 @@ class WC_Order {
|
|||
$file_urls = array();
|
||||
foreach ( $results as $result ) {
|
||||
if ( $_product->has_file( $result->download_id ) ) {
|
||||
$file_urls[] = add_query_arg( array( 'download_file' => $download_file, 'order' => $this->order_key, 'email' => $user_email, 'key' => $result->download_id ), trailingslashit( home_url() ) );
|
||||
|
||||
$file_urls[ $_product->get_file_download_path( $result->download_id ) ] = add_query_arg( array( 'download_file' => $download_file, 'order' => $this->order_key, 'email' => $user_email, 'key' => $result->download_id ), trailingslashit( home_url() ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -174,6 +174,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Tweak - WC_START in checkout json requests to prevent notices breaking checkout.
|
||||
* Tweak - Add filters to product images and thumbnails.
|
||||
* Tweak - IPN email mismatch puts order on-hold.
|
||||
* Tweak - Download file links show filename as part of link.
|
||||
* Fix - Samoa -> Western Samoa
|
||||
* Fix - Re-applied image setting tooltips
|
||||
* Fix - Post code ranges (taxes) on insert.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates/Emails
|
||||
* @version 1.6.4
|
||||
* @version 2.0.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -32,17 +32,25 @@ foreach ($items as $item) :
|
|||
echo ($show_sku && $_product->get_sku()) ? ' (#' . $_product->get_sku() . ')' : '';
|
||||
|
||||
// File URLs
|
||||
if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) :
|
||||
if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) {
|
||||
|
||||
$download_file_urls = $order->get_downloadable_file_urls( $item['product_id'], $item['variation_id'], $item );
|
||||
foreach ( $download_file_urls as $i => $download_file_url ) :
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
||||
echo '<br/><small>';
|
||||
|
||||
if ( count( $download_file_urls ) > 1 ) {
|
||||
echo sprintf( __('Download %d:', 'woocommerce' ), $i + 1 );
|
||||
} elseif ( $i == 0 )
|
||||
echo __( 'Download:', 'woocommerce' );
|
||||
echo ' <a href="' . $download_file_url . '" target="_blank">' . $download_file_url . '</a></small>';
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
echo ' <a href="' . $download_file_url . '" target="_blank">' . basename( $file_url ) . '</a></small>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Variation
|
||||
echo ($item_meta->meta) ? '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>' : '';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 1.6.4
|
||||
* @version 2.0.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -35,9 +35,9 @@ $order = new WC_Order( $order_id );
|
|||
</tfoot>
|
||||
<tbody>
|
||||
<?php
|
||||
if (sizeof($order->get_items())>0) :
|
||||
if (sizeof($order->get_items())>0) {
|
||||
|
||||
foreach($order->get_items() as $item) :
|
||||
foreach($order->get_items() as $item) {
|
||||
|
||||
$_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
|
||||
|
||||
|
@ -50,26 +50,33 @@ $order = new WC_Order( $order_id );
|
|||
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
||||
$item_meta->display();
|
||||
|
||||
if ( $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted() ) :
|
||||
if ( $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted() ) {
|
||||
|
||||
$download_file_urls = $order->get_downloadable_file_urls( $item['product_id'], $item['variation_id'], $item );
|
||||
foreach ( $download_file_urls as $i => $download_file_url ) :
|
||||
echo '<br/><small><a href="' . $download_file_url . '">' . sprintf( __( 'Download file %s →', 'woocommerce' ), ( count( $download_file_urls ) > 1 ? $i + 1 : '' ) ) . '</a></small>';
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
$i = 0;
|
||||
$links = array();
|
||||
|
||||
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
||||
|
||||
$links[] = '<small><a href="' . $download_file_url . '">' . sprintf( __( 'Download file%s', 'woocommerce' ), ( count( $download_file_urls ) > 1 ? ' ' . ( $i + 1 ) . ': ' : ': ' ) ) . basename( $file_url ) . '</a></small>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo implode( '<br/>', $links );
|
||||
}
|
||||
|
||||
echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';
|
||||
|
||||
// Show any purchase notes
|
||||
if ($order->status=='completed' || $order->status=='processing') :
|
||||
if ($purchase_note = get_post_meta( $_product->id, '_purchase_note', true)) :
|
||||
if ($order->status=='completed' || $order->status=='processing') {
|
||||
if ($purchase_note = get_post_meta( $_product->id, '_purchase_note', true))
|
||||
echo '<tr class="product-purchase-note"><td colspan="3">' . apply_filters('the_content', $purchase_note) . '</td></tr>';
|
||||
endif;
|
||||
endif;
|
||||
}
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
}
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_order_items_table', $order );
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue