• Resolved ssrw

    (@rwps)


    Good afternoon.

    I’m wondering if it is possible to show the PO number that the customer has entered on their “My Account, Orders” page and also on the thank you page after ordering.

    Right now it does state that the payment is Purchase Order, but I’d love it if they could see their PO number as well.

    Thanks for your help with this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Fauzan Azizie

    (@fauzanade)

    Hi @rwps,

    You can use the following snippet to add the custom PO Number on the My Order table and add the PO number on the thank you page.

    
    // Add PO Number Column on My Orders Table
    add_action( 'woocommerce_my_account_my_orders_column_po-number' , 'add_igfw_po_number',10,1 ); 
    function add_igfw_po_number( $order ) {
    	   $po_number = get_post_meta( $order->get_id(), 'igfw_purchase_order_number', true );
    	   echo $po_number;
    
    }
    
    add_filter( 'woocommerce_account_orders_columns', 'new_orders_columns',10,1 );
    function new_orders_columns( $columns) {
    
        // Add new column. Kept simple to play nice with other filters.
        $columns['po-number'] = __( 'PO Number', 'woocommerce' );   
    
        return $columns;
    }
    
    // Add PO Number on Thank You Page
    add_action('woocommerce_thankyou_igfw_invoice_gateway', 'igfw_show_po_number_on_thank_you_page', 10, 1);
    function igfw_show_po_number_on_thank_you_page($order_id) {
        $order = wc_get_order($order_id);
        $po_number = $order->get_meta('igfw_purchase_order_number', true);
        echo '<p><strong>PO Number:</strong> ' . $po_number . '</p>';
    }
    

    Please kindly add it to your child theme’s function.php

    Thread Starter ssrw

    (@rwps)

    @fauzanade

    Thank you! That worked great!!!!

    One more question. When I’m on the my account orders, I see the PO in the table, but if I click on the “view” button to look at the order, it does not show the PO there.

    Is it possible to have a snippet that will also accomplish showing it on the order when viewing?

    ETA:

    I also thought of something that may not be possible but thought I’d ask…. Is it possible that the PO number column on my account orders (and the note on the thank you page) only shows if there is a PO order and not for users that don’t have PO orders? I have a specific user role for people that can purchase with a PO and no one else sees the option for PO ordering. Hope that makes sense…

    • This reply was modified 1 year ago by ssrw.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show PO Number on My Account Orders and Thank You Page’ is closed to new replies.