has_file() Closes #1275.
This commit is contained in:
parent
a322a83a7d
commit
2e96d554ce
|
@ -670,11 +670,11 @@ class WC_Order {
|
|||
/** Gets a downloadable products file url */
|
||||
function get_downloadable_file_url( $item_id, $variation_id ) {
|
||||
|
||||
$download_id = ($variation_id>0) ? $variation_id : $item_id;
|
||||
$download_id = $variation_id > 0 ? $variation_id : $item_id;
|
||||
|
||||
$user_email = $this->billing_email;
|
||||
|
||||
return add_query_arg('download_file', $download_id, add_query_arg('order', $this->order_key, add_query_arg('email', $user_email, trailingslashit( home_url() ))));
|
||||
return add_query_arg( 'download_file', $download_id, add_query_arg( 'order', $this->order_key, add_query_arg( 'email', $user_email, trailingslashit( home_url() ) ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -269,6 +269,17 @@ class WC_Product {
|
|||
if ( $this->downloadable == 'yes' ) return true; else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a downloadable product has a file attached to it
|
||||
*/
|
||||
function has_file() {
|
||||
if ( ! $this->is_downloadable() )
|
||||
return false;
|
||||
|
||||
if ( apply_filters( 'woocommerce_file_download_path', get_post_meta( $this->id, '_file_path', true ), $this->id ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a product is virtual (has no shipping)
|
||||
*/
|
||||
|
|
|
@ -152,6 +152,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
|
||||
= 1.6.2 - 20/07/2012 =
|
||||
* Feature - Added google analytics event tracking for add to cart buttons (thanks to Max Rice)
|
||||
* Feature - WC_Product::has_file() for detecting if a downloadable product has a file set
|
||||
* Tweak - Hide admin order comments box if they are disabled
|
||||
* Tweak - Added mini-cart.php template for the cart widget output
|
||||
* Tweak - Simplified the product data write panels
|
||||
|
|
|
@ -28,7 +28,7 @@ foreach ($items as $item) :
|
|||
echo ($show_sku && $_product->get_sku()) ? ' (#' . $_product->get_sku() . ')' : '';
|
||||
|
||||
// File URL
|
||||
echo ($show_download_links && $_product->exists() && $_product->is_downloadable()) ? '<br/><small>'.__('Download:', 'woocommerce').' <a href="' . $order->get_downloadable_file_url( $item['id'], $item['variation_id'] ) . '" target="_blank">' . $order->get_downloadable_file_url( $item['id'], $item['variation_id'] ) . '</a></small>' : '';
|
||||
echo ( $show_download_links && $_product->exists() && $_product->is_downloadable() && $_product->has_file() ) ? '<br/><small>' . __( 'Download:', 'woocommerce' ) . ' <a href="' . $order->get_downloadable_file_url( $item['id'], $item['variation_id'] ) . '" target="_blank">' . $order->get_downloadable_file_url( $item['id'], $item['variation_id'] ) . '</a></small>' : '';
|
||||
|
||||
// Variation
|
||||
echo ($item_meta->meta) ? '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>' : '';
|
||||
|
|
|
@ -49,7 +49,7 @@ $order = new WC_Order( $order_id );
|
|||
$item_meta = new order_item_meta( $item['item_meta'] );
|
||||
$item_meta->display();
|
||||
|
||||
if ($_product->exists() && $_product->is_downloadable() && ($order->status=='completed' || (get_option('woocommerce_downloads_grant_access_after_payment')=='yes' && $order->status=='processing'))) :
|
||||
if ( $_product->exists() && $_product->is_downloadable() && $_product->has_file() && ( $order->status=='completed' || ( get_option( 'woocommerce_downloads_grant_access_after_payment' ) == 'yes' && $order->status == 'processing' ) ) ) :
|
||||
|
||||
echo '<br/><small><a href="' . $order->get_downloadable_file_url( $item['id'], $item['variation_id'] ) . '">' . __('Download file →', 'woocommerce') . '</a></small>';
|
||||
|
||||
|
|
Loading…
Reference in New Issue