• Resolved cris123pp

    (@cris123pp)


    It already has a code to add the order status to the invoice, but it only leaves the status slug and not the name. How can I change this in this code: <?php echo $this->order->get_status(); ?>

    How can I display the time?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    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! ??

    Thread Starter cris123pp

    (@cris123pp)

    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() );
    
    Thread Starter cris123pp

    (@cris123pp)

    This last option worked. Thank you very much. Best wordpress support.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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!

    Thread Starter cris123pp

    (@cris123pp)

    Count on me!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Order Status’ is closed to new replies.