I've already renamed my order status 'completed' to 'paid' using this code
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' );
My problem is that I did a page template with a list of all my orders:
<?php
while ( $loop->have_posts() ) : $loop->the_post();
$order_id = $loop->post->ID;
$order = new WC_Order($order_id);
?>
<tr>
<td style="text-align:left;"><?php echo $order->get_order_number(); ?></td>
<td style="text-align:left;"><?php echo $order->billing_first_name; ?>
<?php echo $order->billing_last_name; ?></td>
<td style="text-align:left;"><?php echo $order->billing_company; ?></td>
<td style="text-align:left;"><?php echo $order->status; ?></td>
</tr>
<?php endwhile; ?>
And the $order->status
still returns 'completed'
instead of 'paid'
.
How can I solve this problem?
Thanks
This is normal and your this specific case you could use some additional code, creating a function to display your custom renamed status:
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
In your template page you will use it this way:
This code is tested and works.
Reference: Renaming WooCommerce Order Status