• Resolved ldjs

    (@ldjs)


    Is it possible to add the current status of the order to an invoice? For example, if an order has the “Processing” status, could that be printed on the invoice somewhere? If so, how can that be done?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @ldjs,

    We have developed a code snippet to achieve this. Copy the below code to your active theme’s functions.php to print order status along with the From Address part.

    add_filter('wf_alter_shipmentlabel_from_address', 'wf_include_order_status', 10, 3);
    
    function wf_include_order_status($from_address, $order, $address) {
    
       $order = ( WC()->version < '2.7.0' ) ? new WC_Order($order_id) : new wf_order($order);
       $from_address .= '<br>'.'Order Status: '.$order->get_status();
       return $from_address;
    }

    Hope this helps. If you like the plugin and support, please leave us a review.

    Thread Starter ldjs

    (@ldjs)

    Thank you, that works well. I do have one problem though, since I changed the name of the “Completed” status to “Paid” in WooCommerce, it still shows up as “completed” on the invoices even though it shows up as “Paid” in my order status section. Is there a way to fix this? Thanks again.

    Plugin Author WebToffee

    (@webtoffee)

    Hi @ldjs,

    We have optimized the code snippet to better suit your requirement. Please replace the previous snippet with below one.

    add_filter('wf_alter_shipmentlabel_from_address', 'wf_include_order_status', 10, 3);
    
    function wf_include_order_status($from_address, $order, $address) {
    
      $order = ( WC()->version < '2.7.0' ) ? new WC_Order($order_id) : new wf_order($order);
      $order_status = $order->get_status();
      if($order_status == 'completed')
      {
         $order_status = 'paid'; 
      }
      $from_address .= '<br><p style="text-transform: capitalize;">'.'Order Status: '.$order_status.'</p>';
      return $from_address;
    }

    Hope all looks good now. If you like the plugin and support, please leave us a review.

    Thread Starter ldjs

    (@ldjs)

    Thanks, that worked perfectly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add order status to invoice’ is closed to new replies.