• Resolved darrenmaximo

    (@darrenmaximo)


    hi, Im using custom template and would like to know how to display or add the customer ID inside the table in pdf invoice. thanks.

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

    (@yordansoares)

    Hi @darrenmaximo,

    Try this code snippet to achieve what you want:

    /**
     * PDF Invoices & Packing Slips for WooCommerce:
     * Add the customer ID after the item meta
     */
    add_action( 'wpo_wcpdf_after_item_meta', function( $document_type, $item, $order ) {
    	if( $customer_id = $order->get_customer_id() ) {
    		echo "<small>Customer ID: {$customer_id}</small>";
    	}
    } , 10, 3 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Please note that the item hooks are repeated for each product item in the order, therefore, if you have 3 items there, the customer ID will be printed after the item meta within all the item lines

    However, if you prefer to add it manually somewhere within your custom PDF template, use this method to get the Customer ID:

    $customer_id = $order->get_customer_id();
    Thread Starter darrenmaximo

    (@darrenmaximo)

    hi, I tried using this,

    $customer_id = $order->get_customer_id();

    but it always displays the value of 0 regarding any customers.

    Thanks again.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom template customer details’ is closed to new replies.