Created
January 31, 2019 17:11
-
-
Save mattpramschufer/c26e5075872c2cc7ecb0c3e82bfcc3d2 to your computer and use it in GitHub Desktop.
Test patch for removing PHP warning Warning: A non-numeric value encountered in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id='downloads-wrapper'> | |
<?php if ( count( $downloads ) > 0 ) : ?> | |
<h2><?php echo apply_filters( 'woocommerce_my_account_my_downloads_title', __( $heading, 'woocommerce' ) ); ?></h2> | |
<ul class="wc-my-downloads-digital-downloads"> | |
<?php foreach ( $downloads as $download ) : ?> | |
<?php | |
// Get order date | |
$order = new WC_Order( $download['order_id'] ); | |
$orderDate = date( 'm/d/Y', strtotime( $order->get_date_completed() ) ); | |
$items = $order->get_items(); | |
$downloadLimit = get_post_meta( $download['product_id'], '_download_limit', true ); | |
if ( $downloadLimit < 0 ) { | |
$downloadLimit = '∞'; | |
} | |
if ( is_numeric( $downloadLimit ) && is_numeric( $download['downloads_remaining'] ) ) { | |
$downloadsRemaining = ( $downloadLimit - $download['downloads_remaining'] ); | |
} else { | |
$downloadsRemaining = '∞'; | |
} | |
?> | |
<li> | |
<?php if ( $showDate ) : echo $orderDate . ' - '; endif; ?> | |
<?php do_action( 'woocommerce_available_download_start', $download ); ?> | |
<?php if ( is_numeric( $download['downloads_remaining'] ) && $showDownloads ) : ?> | |
Downloaded <?php echo $downloadsRemaining; ?> time(s) | |
<?php endif; ?> | |
<?php if ( $showDownloadCount ) : ?> | |
<?php echo apply_filters( 'woocommerce_available_download_count', '<span class="wc-my-downloads-count">' . $download['downloads_remaining'] . '</span> / ', $download ); ?> | |
<?php echo apply_filters( 'woocommerce_available_available_download_count', '<span class="wc-my-downloads-available-count">' . $downloadLimit . ' downloads remaining. </span>', $download ); ?> | |
<?php endif; ?> | |
<?php echo apply_filters( 'woocommerce_available_download_link', '<a href="' . esc_url( $download['download_url'] ) . '" class="wc-my-downloads-download-link">' . $download['download_name'] . '</a>', $download ); ?> | |
<?php do_action( 'woocommerce_available_download_end', $download ); ?> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
<?php else: ?> | |
<?php echo $no_downloads; ?> | |
<?php endif; ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment