Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to list each filename per downloadable product in WooCommerce?
    primarykey
    data
    text
    <p>I am using Woocommerce Plugin. In the downloadable product, how can I display the filename instead of product name? Now the Downloadable product looks like this in the page "My Account":</p> <pre><code>title--&gt;file1 title--&gt;file2. </code></pre> <p>Now I need to display that listing of file into filename. For example: in the "Order" page it should be like this:</p> <pre><code>title--&gt;Installer.zip(filename) title--&gt;Runner.zip(filename) </code></pre> <p>How can I list each filename in the downloadable product list?</p> <p>I am using the Woocommerce 2.0.4</p> <pre><code>&lt;?php /** * My Account */ global $woocommerce; ?&gt; &lt;?php $woocommerce-&gt;show_messages(); ?&gt; &lt;p&gt;&lt;?php printf( __('Hello, &lt;strong&gt;%s&lt;/strong&gt;. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and &lt;a href="%s"&gt;change your password&lt;/a&gt;.', 'kinetico'), $current_user-&gt;display_name, get_permalink(woocommerce_get_page_id('change_password'))); ?&gt;&lt;/p&gt; &lt;?php do_action('woocommerce_before_my_account'); ?&gt; &lt;?php if ($downloads = $woocommerce-&gt;customer-&gt;get_downloadable_products()) : ?&gt; &lt;h2&gt;&lt;?php _e('Available downloads', 'kinetico'); ?&gt;&lt;/h2&gt; &lt;ul class="digital-downloads"&gt; &lt;?php foreach ($downloads as $download) : ?&gt; &lt;li&gt;&lt;?php if (is_numeric($download['downloads_remaining'])) : ?&gt;&lt;span class="count"&gt;&lt;?php echo $download['downloads_remaining'] . _n(' download Remaining', ' downloads remaining', $download['downloads_remaining'], 'kinetico'); ?&gt;&lt;/span&gt;&lt;?php endif; ?&gt; &lt;a href="&lt;?php echo esc_url( $download['download_url'] ); ?&gt;"&gt;&lt;?php echo $download['download_name']; ?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php echo $download['download_name']; ?&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; &lt;?php add_filter( 'woocommerce_available_download_link', 'filter_wc_downloads_so_16142748', 10, 2 ); function filter_wc_downloads_so_16142748( $link, $download ) { // Create a WC_Order object and get the file URLs for this product $order = new WC_Order( $download['order_id'] ); $download_file_urls = $order-&gt;get_downloadable_file_urls( $download['product_id'], null, $download['download_id'] ); // Check each download URL and compare with the current URL // $key contains the real file URL and $value is the encoded URL foreach( $download_file_urls as $key =&gt; $value ) { if( $value == $download['download_url'] ) { $url_parts = explode( '/', parse_url( $key, PHP_URL_PATH ) ); $file_name = end( $url_parts ); $link = '&lt;a href="' . esc_url( $download['download_url'] ) . '"&gt;' . $download['download_name'] . '&lt;/a&gt; &lt;small&gt;( ' . $file_name . ' )&lt;/small&gt;'; } } return $link; }?&gt; &lt;h2&gt;&lt;?php _e('Recent Orders', 'kinetico'); ?&gt;&lt;/h2&gt; &lt;?php woocommerce_get_template('myaccount/my-orders.php', array( 'recent_orders' =&gt; $recent_orders )); ?&gt; &lt;h2&gt;&lt;?php _e('My Address', 'kinetico'); ?&gt;&lt;/h2&gt; &lt;p&gt;&lt;?php _e('The following addresses will be used on the checkout page by default.', 'kinetico'); ?&gt;&lt;/p&gt; &lt;?php woocommerce_get_template('myaccount/my-address.php'); ?&gt; &lt;?php do_action('woocommerce_after_my_account'); add_filter( 'woocommerce_available_download_link', 'filter_wc_downloads_so_16142748', 10, 2 ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload