• Resolved creoadmin

    (@creoadmin)


    I LOVE your plugin! Thank you!

    I have added this code to show a custom field on my PDF Packing Slip:
    add_action( ‘wpo_wcpdf_after_order_details’, ‘wpo_wcpdf_teacher_name’, 10, 2 );
    function wpo_wcpdf_teacher_name ($template_type, $order) {
    if ($template_type == ‘packing-slip’) {
    $document = wcpdf_get_document( $template_type, $order );
    $document->custom_field(‘teacher_name’);
    }
    }

    How can I add the text phrase “Teacher Name:” to display?

    Thank you!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter creoadmin

    (@creoadmin)

    Also…
    I want to display my custom field “Student Name” as well. I would like this to display right before “Teacher Name”. How I do I do that?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @creoadmin,

    How can I add the text phrase “Teacher Name:” to display? I want to display my custom field “Student Name” as well. I would like this to display right before “Teacher Name”. How I do I do that?

    Use this code snippet to add the Student and Teacher name after the order details on the packing slip:

    /**
     * Add the Student and Teacher Name on the packing slip
     */
    add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_teacher_name', 10, 2 );
    function wpo_wcpdf_teacher_name ($template_type, $order) {
    	if ($template_type == 'packing-slip') {		
    		if( $student_name = $order->get_meta('student_name') ){
    			echo '<div><strong>Student Name</strong>: ' . $student_name . '</div>';
    		}
    		if( $teacher_name = $order->get_meta('teacher_name') ){
    			echo '<div><strong>Teacher Name</strong>: ' . $teacher_name . '</div>';
    		}
    	}
    }

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

    Let me know if it worked! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Showing Custom Notes’ is closed to new replies.