order-downloads.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Order Downloads.
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/order/order-downloads.php.
  6. *
  7. * HOWEVER, on occasion WooCommerce will need to update template files and you
  8. * (the theme developer) will need to copy the new files to your theme to
  9. * maintain compatibility. We try to do this as little as possible, but it does
  10. * happen. When this occurs the version of the template file will be bumped and
  11. * the readme will list any important changes.
  12. *
  13. * @see https://docs.woocommerce.com/document/template-structure/
  14. * @author Automattic
  15. * @package WooCommerce/Templates
  16. * @version 3.3.0
  17. */
  18. if ( ! defined( 'ABSPATH' ) ) {
  19. exit;
  20. }
  21. ?>
  22. <section class="woocommerce-order-downloads">
  23. <?php if ( isset( $show_title ) ) : ?>
  24. <h2 class="woocommerce-order-downloads__title"><?php esc_html_e( 'Downloads', 'woocommerce' ); ?></h2>
  25. <?php endif; ?>
  26. <table class="woocommerce-table woocommerce-table--order-downloads shop_table shop_table_responsive order_details">
  27. <thead>
  28. <tr>
  29. <?php foreach ( wc_get_account_downloads_columns() as $column_id => $column_name ) : ?>
  30. <th class="<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
  31. <?php endforeach; ?>
  32. </tr>
  33. </thead>
  34. <?php foreach ( $downloads as $download ) : ?>
  35. <tr>
  36. <?php foreach ( wc_get_account_downloads_columns() as $column_id => $column_name ) : ?>
  37. <td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
  38. <?php
  39. if ( has_action( 'woocommerce_account_downloads_column_' . $column_id ) ) {
  40. do_action( 'woocommerce_account_downloads_column_' . $column_id, $download );
  41. } else {
  42. switch ( $column_id ) {
  43. case 'download-product':
  44. if ( $download['product_url'] ) {
  45. echo '<a href="' . esc_url( $download['product_url'] ) . '">' . esc_html( $download['product_name'] ) . '</a>';
  46. } else {
  47. echo esc_html( $download['product_name'] );
  48. }
  49. break;
  50. case 'download-file':
  51. echo '<a href="' . esc_url( $download['download_url'] ) . '" class="woocommerce-MyAccount-downloads-file button alt">' . esc_html( $download['download_name'] ) . '</a>';
  52. break;
  53. case 'download-remaining':
  54. echo is_numeric( $download['downloads_remaining'] ) ? esc_html( $download['downloads_remaining'] ) : esc_html__( '&infin;', 'woocommerce' );
  55. break;
  56. case 'download-expires':
  57. if ( ! empty( $download['access_expires'] ) ) {
  58. echo '<time datetime="' . esc_attr( date( 'Y-m-d', strtotime( $download['access_expires'] ) ) ) . '" title="' . esc_attr( strtotime( $download['access_expires'] ) ) . '">' . esc_html( date_i18n( get_option( 'date_format' ), strtotime( $download['access_expires'] ) ) ) . '</time>';
  59. } else {
  60. esc_html_e( 'Never', 'woocommerce' );
  61. }
  62. break;
  63. }
  64. }
  65. ?>
  66. </td>
  67. <?php endforeach; ?>
  68. </tr>
  69. <?php endforeach; ?>
  70. </table>
  71. </section>