php - 将 ACF 字段添加到 WooCommerce 订单列表列
问题描述
我已经尝试过这段代码,它添加了列并添加数据仅显示“确认未更新”我想显示此元数据“acknowledge_noo”,这是“acknowledge_noo”ACF 字段
add_filter( 'yith_wcfm_print_shortcode_template_args', 'yith_wcfm_print_shortcode_template_args', 20 );
if ( ! function_exists( 'yith_wcfm_print_shortcode_template_args' ) ) {
function yith_wcfm_print_shortcode_template_args( $cols ) {
$columns = $cols['columns'];
$keys = array_keys( $columns );
$first = array_slice( $columns, 0, $ship_to_pos );
$last = array_slice( $columns, $ship_to_pos + 1 );
$billing_to_col = array( 'acknowledge' => __( 'Acknowledge', 'yith-frontend-manager-for-woocommerce') );
$cols['columns'] = array_merge( $first,$billing_to_col, $last );
return $cols;
}
}
add_action( 'yith_wcfm_order_cols', 'yith_wcfm_order_biloing_to_coll', 10, 2 );
if ( ! function_exists( 'yith_wcfm_order_biloing_to_coll' ) ) {
function yith_wcfm_order_biloing_to_coll( $column, $post) {
if ( 'acknowledge' == $column ) {
global $post;
if ( $address = $order = wc_get_order( $post->ID ) ) {
$address = wc_get_order_item_meta( $item_id, 'acknowledge_noo', true );
$tooltip = __('Print details', 'textdomain');
echo '<a href="/wp-content/uploads/customerpdf/'.$address.'.pdf" data-tip="'.$tooltip.'" target="_blank">'.$address.'</a>';
}
else {
echo 'Acknowledge Not Updated';
}
}
}
}
解决方案
推荐阅读
- c - 执行有界加法的最有效方法是什么?
- ffmpeg - ffmpeg 从 h264 转换为网络服务器
- rust - 为什么我的 rust 函数会出现“返回引用当前函数拥有的数据的值”错误?
- jdbc - 与 Domino v12 的 JDBC 连接
- javascript - 如何比较具有相同对象属性的两个值?
- postgresql - 将表名作为参数传递给 Postgresql
- google-chrome-devtools - 如何从另一台机器访问 chromebook 上的 chrome 开发工具
- javascript - 状态改变回调函数
- android - W/DownloadManager:中止下载请求 17:无法创建目标文件 /storage/emulated/0/Ringtone/Fav_Ringtone.mp3
- python - 如何在 C++ 中读取羽毛文件时启用内存映射