Skip to content

Instantly share code, notes, and snippets.

@mattpramschufer
Created January 31, 2019 17:11
Show Gist options
  • Save mattpramschufer/c26e5075872c2cc7ecb0c3e82bfcc3d2 to your computer and use it in GitHub Desktop.
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
<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 = '&#x221e;';
}
if ( is_numeric( $downloadLimit ) && is_numeric( $download['downloads_remaining'] ) ) {
$downloadsRemaining = ( $downloadLimit - $download['downloads_remaining'] );
} else {
$downloadsRemaining = '&#x221e;';
}
?>
<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