小编Any*_*roz的帖子

仅在 WooCommerce 管理订单上显示自定义订单项目元数据

为了显示自定义数据,我使用这个钩子“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)

在此输入图像描述

php wordpress backend orders woocommerce

4
推荐指数
1
解决办法
3275
查看次数

标签 统计

backend ×1

orders ×1

php ×1

woocommerce ×1

wordpress ×1