Display product URL only if is not hidden in downloads list

Fixes #17925
This commit is contained in:
Claudio Sanches 2017-11-28 10:18:43 -02:00
parent 3cc84a1821
commit def87b74bf
2 changed files with 6 additions and 2 deletions

View File

@ -1349,6 +1349,7 @@ class WC_Order extends WC_Abstract_Order {
'download_id' => $file['id'], 'download_id' => $file['id'],
'product_id' => $product->get_id(), 'product_id' => $product->get_id(),
'product_name' => $product->get_name(), 'product_name' => $product->get_name(),
'product_url' => $product->is_visible() ? $product->get_permalink() : '', // Since 3.3.0.
'download_name' => $file['name'], 'download_name' => $file['name'],
'order_id' => $this->get_id(), 'order_id' => $this->get_id(),
'order_key' => $this->get_order_key(), 'order_key' => $this->get_order_key(),

View File

@ -43,8 +43,11 @@ if ( ! defined( 'ABSPATH' ) ) {
} else { } else {
switch ( $column_id ) { switch ( $column_id ) {
case 'download-product' : ?> case 'download-product' : ?>
<a href="<?php echo esc_url( get_permalink( $download['product_id'] ) ); ?>"><?php echo esc_html( $download['product_name'] ); ?></a> <?php if ( $download['product_url'] ) : ?>
<?php <a href="<?php echo esc_url( $download['product_url'] ); ?>"><?php echo esc_html( $download['product_name'] ); ?></a>
<?php else : ?>
<?php echo esc_html( $download['product_name'] ); ?>
<?php endif;
break; break;
case 'download-file' : ?> case 'download-file' : ?>
<a href="<?php echo esc_url( $download['download_url'] ); ?>" class="woocommerce-MyAccount-downloads-file button alt"><?php echo esc_html( $download['download_name'] ); ?></a> <a href="<?php echo esc_url( $download['download_url'] ); ?>" class="woocommerce-MyAccount-downloads-file button alt"><?php echo esc_html( $download['download_name'] ); ?></a>