In this tutorial I will explain how you can read some custom order meta data from WooCommerce (if you have saved it during a checkout) and stamp it in the PDF file.
Lets say you are saving the following custom meta data with the order when a customer does a checkout:
- Course Name
- Course Teacher
- Course School
- Course Start Date
- Course End Date
You want to stamp the above data when this user downloads the PDF file associated with this order.
The following code snippet will do the job:
add_filter('filter_stamper_text_after_replacing_tags', 'woocommerce_custom_stamping', 10, 2); function stamper_woocommerce_custom_stamping($text_to_stamp, $additional_params) { $order_id = $additional_params['transaction_id']; //Read the custom order meta data $course_name = get_post_meta($order_id,'Course Name',true); $course_teacher = get_post_meta($order_id,'Course Teacher',true); $course_school = get_post_meta($order_id,'Course School',true); $course_start_date = get_post_meta($order_id,'Course Start Date',true); $course_end_date = get_post_meta($order_id,'Course End Date',true); //Crete the text to be stamped $text_to_stamp = 'Licensed to '.$course_teacher.' - '.$course_name.' - '.$course_school.' - '.$course_start_date.' - '.$course_end_date; return $text_to_stamp; }