Hi @cris123pp,
Try this:
$order_status = $this->order->get_status();
$order_status_name = wc_get_order_status_name( $order_status );
You can also display the order status name on your invoice, thought the PDF template action hooks, using this code snippet:
/**
* Show the order status after the order data
*/
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_order_status', 10, 2 );
function wpo_wcpdf_order_status ($template_type, $order) {
if ($template_type == 'invoice') {
$order_status = $order->get_status();
$order_status_name = wc_get_order_status_name( $order_status );
?>
<tr class="order-status">
<th>Order Status:</th>
<td><?php echo $order_status_name; ?></td>
</tr>
<?php
}
}
Let me know if it worked! 🙂
Thanks.
The order status worked using the second option, the first one keeps pulling the slug. Using the second, I would like the satus to appear on both the invoice and the packing slip. I tried to duplicate the code and change just the template but it didn’t work. About time, I would like to display only the order time next to the order date.
Plugin Contributor
Ewout
(@pomegranate)
@cris123pp the first code is identical to the second, with the only difference being that the second has some extra HTML. Are you sure you’re printing the correct value ($order_status_name)?
$order_status = $this->order->get_status();
$order_status_name = wc_get_order_status_name( $order_status );
you can also shorten this to a single line:
$order_status_name = wc_get_order_status_name( $this->order->get_status() );
This last option worked. Thank you very much. Best wordpress support.
I’m glad to know that it worked!
If you don’t mind and have the time, do you think you could leave us a review?
Thanks in advance and all the best with your store!