Php WooCommerce-重命名批量操作在管理订单列表中的完成状态
我已使用此代码将订单状态“已完成”重命名为“已付款”Php WooCommerce-重命名批量操作在管理订单列表中的完成状态,php,wordpress,woocommerce,status,orders,Php,Wordpress,Woocommerce,Status,Orders,我已使用此代码将订单状态“已完成”重命名为“已付款” function wc_renaming_order_status( $order_statuses ) { foreach ( $order_statuses as $key => $status ) { $new_order_statuses[ $key ] = $status; if ( 'wc-completed' === $key ) { $order_statu
function wc_renaming_order_status( $order_statuses ) {
foreach ( $order_statuses as $key => $status ) {
$new_order_statuses[ $key ] = $status;
if ( 'wc-completed' === $key ) {
$order_statuses['wc-completed'] = _x( 'Paid', 'Order status', 'woocommerce' );
}
}
return $order_statuses;
}
add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );
现在我需要在我的订单管理列表中重命名批量选项。
我使用了以下代码:
add_action('admin_footer-edit.php', 'custom_bulk_admin_footer');
function custom_bulk_admin_footer() {
global $post_type;
if($post_type == 'shop_order') {
?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('<option>').val('shipped').text('<?php _e('Mark as shipped')?>').appendTo("select[name='action']");
jQuery('<option>').val('shipped').text('<?php _e('Mark as shipped')?>').appendTo("select[name='action2']");
});
</script>
<?php
}
}
add_action('admin_footer-edit.php','custom_bulk_admin_footer');
函数自定义\批量\管理\页脚(){
全球$post_类型;
如果($post\U type=='shop\U order'){
?>
jQuery(文档).ready(函数(){
jQuery(“”).val(“”).text(“”).appendTo(“选择[name='action']);
jQuery(“”).val(“”).text(“”).appendTo(“选择[name='action2']);
});
可以使用wordpress本机函数。您将得到以下结果:
代码如下:
add_filter('gettext', 'wc_renaming_bulk_status', 20, 3);
function wc_renaming_bulk_status( $translated_text, $untranslated_text, $domain ) {
if( is_admin()) {
if( $untranslated_text == 'Mark complete' )
$translated_text = __( 'Mark paid','theme_text_domain' );
}
return $translated_text;
}
这段代码位于活动子主题(或主题)的function.php文件或任何插件文件中
此代码经过测试并正常工作。