{"id":308,"date":"2015-01-25T02:01:06","date_gmt":"2015-01-25T02:01:06","guid":{"rendered":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/?page_id=308"},"modified":"2015-03-19T00:22:08","modified_gmt":"2015-03-19T00:22:08","slug":"stamping-custom-woocommerce-order-meta-data","status":"publish","type":"page","link":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/stamping-custom-woocommerce-order-meta-data","title":{"rendered":"Stamping Custom WooCommerce Order Meta Data"},"content":{"rendered":"<p>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.<\/p>\n<p>Lets say you are saving the following custom meta data with the order when a customer does a checkout:<\/p>\n<ul>\n<li>Course Name<\/li>\n<li>Course Teacher<\/li>\n<li>Course School<\/li>\n<li>Course Start Date<\/li>\n<li>Course End Date<\/li>\n<\/ul>\n<p>You want to stamp the above data when this user downloads the PDF file associated with this order.<\/p>\n<p>The following code snippet will do the job:<\/p>\n<pre>add_filter('filter_stamper_text_after_replacing_tags', 'woocommerce_custom_stamping', 10, 2);\r\nfunction stamper_woocommerce_custom_stamping($text_to_stamp, $additional_params)\r\n{\r\n    $order_id = $additional_params['transaction_id'];\r\n\r\n    \/\/Read the custom order meta data\r\n    $course_name = get_post_meta($order_id,'Course Name',true);\r\n    $course_teacher = get_post_meta($order_id,'Course Teacher',true);\r\n    $course_school = get_post_meta($order_id,'Course School',true);\r\n    $course_start_date = get_post_meta($order_id,'Course Start Date',true);\r\n    $course_end_date = get_post_meta($order_id,'Course End Date',true);\r\n\r\n    \/\/Crete the text to be stamped\r\n    $text_to_stamp = 'Licensed to '.$course_teacher.' - '.$course_name.' - '.$course_school.' - '.$course_start_date.' - '.$course_end_date;\r\n\r\n    return $text_to_stamp;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"_links":{"self":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/wp-json\/wp\/v2\/pages\/308"}],"collection":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":0,"href":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/wp-json\/wp\/v2\/pages\/308\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wp-pdf-stamper\/wp-json\/wp\/v2\/media?parent=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}