Change To be able to download order data from all products removed (#41449)

This commit is contained in:
Barry Hughes 2023-12-06 04:57:41 -08:00 committed by GitHub
commit 4c57f72574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Adds new hook `woocommerce_order_downloads_table_show_downloads` to control rendering of the downloads table (classic templates only).

View File

@ -2723,10 +2723,30 @@ if ( ! function_exists( 'woocommerce_order_details_table' ) ) {
return;
}
$order = wc_get_order( $order_id );
if ( ! $order ) {
return;
}
wc_get_template(
'order/order-details.php',
array(
'order_id' => $order_id,
'order_id' => $order_id,
/**
* Determines if the order downloads table should be shown (in the context of the order details
* template).
*
* By default, this is true if the order has at least one dowloadable items and download is permitted
* (which is partly determined by the order status). For special cases, though, this can be overridden
* and the downloads table can be forced to render (or forced not to render).
*
* @since 8.5.0
*
* @param bool $show_downloads If the downloads table should be shown.
* @param WC_Order $order The related order.
*/
'show_downloads' => apply_filters( 'woocommerce_order_downloads_table_show_downloads', ( $order->has_downloadable_item() && $order->is_download_permitted() ), $order ),
)
);
}

View File

@ -12,7 +12,9 @@
*
* @see https://woo.com/document/template-structure/
* @package WooCommerce\Templates
* @version 7.8.0
* @version 8.5.0
*
* @var bool $show_downloads Controls whether the downloads table should be rendered.
*/
defined( 'ABSPATH' ) || exit;
@ -27,7 +29,6 @@ $order_items = $order->get_items( apply_filters( 'woocommerce_purchase
$show_purchase_note = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) );
$show_customer_details = is_user_logged_in() && $order->get_user_id() === get_current_user_id();
$downloads = $order->get_downloadable_items();
$show_downloads = $order->has_downloadable_item() && $order->is_download_permitted();
if ( $show_downloads ) {
wc_get_template(