jimleeder123 Posted June 18, 2016 Share Posted June 18, 2016 I've got a function in my WordPress functions file that sends a Word doc based on what venue the ordered product is from. However I also need to be able to paste variables such as the customer name and others onto the specified word document. It also needs to be in specific places. How can I go about doing this? Please let me know if you have any idea or don't understand me! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/301357-paste-variables-onto-a-word-doc-on-order-submission/ Share on other sites More sharing options...
Jacques1 Posted June 18, 2016 Share Posted June 18, 2016 (edited) Are you talking about the modern OOXML format (.docx) or the legacy MS-DOC format (.doc)? If it's OOXML, templating is very easy, and there are libraries like PhpWord which support this out of the box. It's the old binary MS-DOC format, this will be a lot harder. Edited June 18, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301357-paste-variables-onto-a-word-doc-on-order-submission/#findComment-1533787 Share on other sites More sharing options...
Barand Posted June 18, 2016 Share Posted June 18, 2016 Another approach is use Word's mail merge feature and create a data file (.csv perhaps) with the data that needs to be inserted. Quote Link to comment https://forums.phpfreaks.com/topic/301357-paste-variables-onto-a-word-doc-on-order-submission/#findComment-1533788 Share on other sites More sharing options...
jimleeder123 Posted June 20, 2016 Author Share Posted June 20, 2016 The data will be going through WooCommerce. Also the file type is .docx. So how would I go about using this PHPWord thing please? Quote Link to comment https://forums.phpfreaks.com/topic/301357-paste-variables-onto-a-word-doc-on-order-submission/#findComment-1533831 Share on other sites More sharing options...
Jacques1 Posted June 20, 2016 Share Posted June 20, 2016 See the link in my reply. You can literally copy and paste the code. Quote Link to comment https://forums.phpfreaks.com/topic/301357-paste-variables-onto-a-word-doc-on-order-submission/#findComment-1533835 Share on other sites More sharing options...
jimleeder123 Posted July 8, 2016 Author Share Posted July 8, 2016 I've had a quick look. Can this be used with an existing word document in my web files? Quote Link to comment https://forums.phpfreaks.com/topic/301357-paste-variables-onto-a-word-doc-on-order-submission/#findComment-1534352 Share on other sites More sharing options...
Jacques1 Posted July 8, 2016 Share Posted July 8, 2016 If you add placeholders, yes. Quote Link to comment https://forums.phpfreaks.com/topic/301357-paste-variables-onto-a-word-doc-on-order-submission/#findComment-1534354 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.