WC_Meta_Box_Order_Downloads::output
Output the metabox.
Method of the class: WC_Meta_Box_Order_Downloads{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Meta_Box_Order_Downloads::output( $post );
WC_Meta_Box_Order_Downloads::output() WC Meta Box Order Downloads::output code WC 10.7.0
<?php
public static function output( $post ) {
if ( $post instanceof WC_Order ) {
$order_id = $post->get_id();
} else {
$order_id = $post->ID;
}
?>
<div class="order_download_permissions wc-metaboxes-wrapper">
<div class="wc-metaboxes">
<?php
$data_store = WC_Data_Store::load( 'customer-download' );
$download_permissions = array();
if ( 0 !== $order_id ) {
$download_permissions = $data_store->get_downloads(
array(
'order_id' => $order_id,
'orderby' => 'product_id',
)
);
}
$product = null;
$loop = 0;
$file_counter = 1;
if ( $download_permissions && count( $download_permissions ) > 0 ) {
foreach ( $download_permissions as $download ) {
if ( ! $product || $product->get_id() !== $download->get_product_id() ) {
$product = wc_get_product( $download->get_product_id() );
$file_counter = 1;
}
// don't show permissions to files that have since been removed.
if ( ! $product || ! $product->exists() || ! $product->has_file( $download->get_download_id() ) ) {
continue;
}
// Show file title instead of count if set.
$file = $product->get_file( $download->get_download_id() );
// translators: file name.
$file_count = isset( $file['name'] ) ? $file['name'] : sprintf( __( 'File %d', 'woocommerce' ), $file_counter );
include __DIR__ . '/views/html-order-download-permission.php';
$loop++;
$file_counter++;
}
}
?>
</div>
<div class="toolbar">
<p class="buttons">
<select id="grant_access_id" class="wc-product-search" name="grant_access_id[]" multiple="multiple" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations"></select>
<button type="button" class="button grant_access">
<?php esc_html_e( 'Grant access', 'woocommerce' ); ?>
</button>
</p>
<div class="clear"></div>
</div>
</div>
<?php
}