为了显示自定义数据,我使用这个钩子“woocommerce_checkout_create_order_line_item”。他工作得很好。但它在三个地方显示数据 - 管理面板(按顺序)、订单详细信息和个人帐户。我需要仅在管理面板中显示数据。怎么做?我的代码
add_action( 'woocommerce_checkout_create_order_line_item', 'wdm_add_custom_order_line_item_meta', 10, 4 );
function wdm_add_custom_order_line_item_meta( $item, $cart_item_key, $values, $order )
{
if ( array_key_exists( 'file', $values ) ) {
$product_id = $item->get_product_id();
$permfile = $values['file'];
$basePath = plugin_base_url();
$fileid = $permfile;
....
$item->add_meta_data('File','<button > <a href="'.$fileid.'" download>' . Download. '</a></button>');
}
}
Run Code Online (Sandbox Code Playgroud)