3 php wordpress orders woocommerce hook-woocommerce
我正在尝试找到一种方法,如何在 WooCommerce 订单视图的名称下方添加客户电话和电子邮件。请参阅图片以供参考,我需要在其中添加此信息。
以下代码将在后端订单列表中的订单号下添加计费电话和电子邮件(仅适用于 Woocommerce 3.3+):
add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 50, 2 );
function custom_orders_list_column_content( $column, $post_id ) {
if ( $column == 'order_number' )
{
global $the_order;
if( $phone = $the_order->get_billing_phone() ){
$phone_wp_dashicon = '<span class="dashicons dashicons-phone"></span> ';
echo '<br><a href="tel:'.$phone.'">' . $phone_wp_dashicon . $phone.'</a></strong>';
}
if( $email = $the_order->get_billing_email() ){
echo '<br><strong><a href="mailto:'.$email.'">' . $email . '</a></strong>';
}
}
}
Run Code Online (Sandbox Code Playgroud)
代码位于活动子主题(活动主题)的 function.php 文件中。测试和工作。
| 归档时间: |
|
| 查看次数: |
1427 次 |
| 最近记录: |