Custom pdf only for specific product

WooCommerce
20 November, 2021 06:20:38
itautomation
Topics: 5
Messages: 15
Dear e2pdf support,

we are currently setting up an online shop with WooCommerce and require generating a pdf for each product X that is configured in our shop.

In other words, not for each ordered cart, but for each time s/o orders the product X, this pdf needs to be generated. It should only be available for us, not the customer (this pdf is used for production), and it requires listing the configuration parameters of product X (like color, wood type, ...). Is this use case in general possible?

We are also looking forward to the WooCommerce documentation, and currently having a hard time to get started. Is there any pre-published documentation already available, or an ETA of when you are going to release the docu?
Or, would it be possible to share basic codes already on how to access configuration parameters of a certain product in the e2pdf template?

Thanks a lot for your help, and this great product (which we used with FormidableForms already successfully in the past)!

Best Regards
Sören
20 November, 2021 08:52:55
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

We are sorry for inconvenience with documentation, we are working on it however due the complex of WooCoomerce and a lot of information which can be pulled from, it's taking a bit more time than we expected. We hope that we finally release it till the end of this year. Currently most of available shortcodes located under "Visual Mapper" or as example under "Auto PDF". if E2Pdf Template Connected to "Products" / "Variations" - "Visual Mapper" has 13 sections (Screenshot 1), if E2Pdf Template connected to "Orders" it will be almost similar but a bit with other shortcodes and its structure as same information must be retrieved with different ways in "Product" or "Order" context:

Product - Static data of Product
Product Common - Static data of Product
Product Attributes - Attributes of Product
Product Special Shortcodes - Data which can be pulled via complex "foreach" shortcode it iterate over product item meta data or all attributes (unfortunately it's also not yet documented as it's still under "beta").
Product Meta Keys - Meta Keys of the Product
Product Taxonomy - Taxonomies of the Product
Order Product - Data of purchased Product, usually it contains some dynamic data like custom fields, etc.
Order Product Item Meta Keys - Meta Data of Purchased Product, usually it contains some dynamic data like custom fields, etc.
Order - Data of the Order (if product purchased)
Order Special Shortcodes - Data which can be pulled via complex "foreach" shortcode it iterate over order item meta
Order Meta Keys - Meta Keys of Order
Order Taxonomy - Taxonomies of Order
Order Item Meta Keys - Product item meta keys

So depending on how you are using configuration parameters it will depend which shortcodes to use. If it's attributes - you will need to look into "Product Attributes" section. If you are using addon fields - you will need to use "Order Product Item Meta Keys" section.

As about functionality, the process will look like this, correct us if we are wrong:
User purchase some Product X -> You must be able to generate PDF connected to this Order and to the Product X which parameters were checked by user.

If so, unfortunately this functionality works only partially for your needs:

1. You can connect E2Pdf Template to "Products" / "Variations" and:
- Currently shortcodes can be used as "File Download URL" under "Product" - but it will not fit your needs as you mention that only administrators must have access to generated PDF.
- It's possible to use shortcode [e2pdf-attachment id="1" dataset="32"], where 1 is the ID of E2Pdf Template connected to "Products" and "32" is the Product ID. In this case E2Pdf will send PDF as attachment to administrators (depending on in which "Email Additional Content" shortcode will be added) but only if it will be purchased product with ID: 32. (Screenshot 2). It will slow down a bit the process of submission order as PDF must be sent on "Order" submission step.

As we see you must be able to export data via "E2Pdf" -> "Export" with selecting "E2Pdf Template" -> "Product" and "Order" however currently E2Pdf can export only for "Product" data but without "Order" information. We are working on extending this functionality to be able to choose also from which order it must added order item meta data information...

OR

2. You can connect E2Pdf Template to "Orders" and in this case you will be able to export data via "E2Pdf" -> "Export" for specified product, however in this case you will need to use some specified shortcodes inside E2Pdf Template to get exact product data from "Order Product Item Meta Keys" or if it's attribute from "Product Attributes" section but with difference:

By default it will be generated shortcodes from "Visual Mapper" as:
[e2pdf-wc-product key="_product_id" order_item_meta="true" index="0"]

[e2pdf-wc-product key="get_attribute" attribute="custom-attribute" show="value" index="0"]

You will need to modify it as:
[e2pdf-wc-product key="_product_id" order_item_meta="true" id="32"]

[e2pdf-wc-product key="get_attribute" attribute="custom-attribute" show="value" id="32"]

* replace index="0" with id="32". It will output information for Product with ID "32" as by default "index" is the "index" product added to order but you need to get information from exact product id. Attributes will be showing always but "order_item_meta" will be showed only if Product with ID 32 purchased with current "Order" for which you are trying to export PDF.

P.S. To use 2nd option you will need also to update plugin to latest RC version 1.17.05 as by default "Order Product Item Meta Keys" shortcodes not added to current stable version: https://e2pdf.com/support/desk/how-to-update-plugin-to-rc-release-candidate-version-from-e2pdf-com.

It looks a bit complicated however we will do our best to explain all possible combinations in our documentation soon.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
20 November, 2021 14:07:23
itautomation
Topics: 5
Messages: 15
Thanks a lot for your fast and detailed response! Really appreciate it.

We will review and test out the approaches you mentioned, and in case of question come back to you on this thread.

Looking forward to the docu already :-)
23 November, 2021 06:49:51
itautomation
Topics: 5
Messages: 15
Dear e2pdf support team,

thanks again for the information so far.

We could successfully insert configuration items from a Formidable-Form-based product order in WooCommerce to our pdf form by using "order item meta keys". However, configuration fields, where images can be selected, are not properly displayed in the pdf form. Instead html code is shown (<div class="frm_has_image_options"><span class="frm_show_images frm_image_option_cpntainer ...). Is there any possibility to only show the associated value instead of trying to display the image?

Furthermore we have selectable items in our configuration form. Now we want to only display items, that have been selected. With formidable form extension we solved this by using [if 602 like="..."]....[/if 602] where 602 is an ID. Is there a similar solution for woocommerce extension?

Thanks a lot again!

Best Regards
Sören
23 November, 2021 09:27:48
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

Unfortunately Formidable Forms syntax not yet available under WooCommerce "Products", however we have this point of integration in our TODO list. Such integration was already done for Gravity Forms but due the more complex structure of Formidable Forms plugin we have delay in implementation for Formidable Forms.

So to show only "Value" you can try to use shortcode wrapper with "strip_tags" and "trim" filter to have only value without image (If it's present in HTML code):

[e2pdf-format-output filter="strip_tags,trim"][e2pdf-wc-product key="Images" order_item_meta="true"][/e2pdf-format-output]

As about "if" conditions unfortunately there is no yet globally implemented inline conditional logic, however can you please add some screenshots of "Value" of the "HTML" object which you setup? Maybe we will be able to offer some other solution, until the full integration of Formidable Forms + WooCommerce will be implemented.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
24 November, 2021 13:39:10
itautomation
Topics: 5
Messages: 15
Dear e2pdf support team,

the first part worked already, great!

For the "if" conditions: Find attached a screenshot of such an exemplary value. Does any other solution come to your mind to only display those items, that have been selected?
If not, is there any rough ETA for the globally implemented inline conditional logic?

Thanks a lot again!

Best Regards
Sören
25 November, 2021 01:03:51
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

You can try to use some of following solutions:

1. If you need to print all selected options you can create "HTML" object, set "Disable WYSIWYG Editor" and use shortcode inside (Screenshot 1) as:

[e2pdf-foreach shortcode="e2pdf-wc-product" key="get_formatted_meta_data" index="0"][e2pdf-wc-product key="get_formatted_meta_data" index="0" path="[e2pdf-foreach-key].display_key"]: [e2pdf-format-output filter="replace,strip_tags,trim" search="<\/li><li>" replace=", "][e2pdf-wc-product key="get_formatted_meta_data" index="0" path="[e2pdf-foreach-key].display_value"][/e2pdf-format-output]<br>
[/e2pdf-foreach]


It will iterate over all product item meta and will output it as Key: Value.

2. You can try to create "HTML" object and "Merge" value dynamically. Screenshot 2.

In example:
1st action: If [e2pdf-wc-product key="Schwenktisch - 40 x 22 cm" order_item_meta="true" index="0"] is not empty then we add to block "Value": Some value: [e2pdf-wc-product key="Schwenktisch - 40 x 22 cm" order_item_meta="true" index="0"]<br>

2nd action: If [e2pdf-wc-product key="Other Key" order_item_meta="true" index="0"] is not empty then we add to block "Value": Some other value: [e2pdf-wc-product key="Other Key" order_item_meta="true" index="0"]<br>

So it will dynamically generate final value by "merging" it.

3. You can try to use "Hide" and "Change" position action if you do not have a lot of properties to output. Screenshot 3, 4, 5.
For this you need to create elements on needed positions and:

For 1st block:
- check if it's "Empty" and "Hide" if Yes.

For 2nd block:
- check if it's "Empty" and "Hide" if Yes.
- check if 1st block is "Empty" and change "Top" position to the value of 1st block "height" + space below.

For 3rd block:
- check if it's "Empty" and "Hide" if Yes.
- check if 1st block is "Empty" and change "Top" position to the value of 1st block "height" + space below.
- check if 2nd block is "Empty" and change "Top" position to the value of 2nd block "height" + space below.

For 4th block:
- check if it's "Empty" and "Hide" if Yes.
- check if 1st block is "Empty" and change "Top" position to the value of 1st block "height" + space below.
- check if 2nd block is "Empty" and change "Top" position to the value of 2nd block "height" + space below.
- check if 3rd block is "Empty" and change "Top" position to the value of 3rd block "height" + space below.

Unfortunately there is no yet ETA when global inline "if" conditionals logic will be released but it's approximately expected in 1st quarter of 2022.

Let us know please if any of this solutions can work for you. If not, let us know please a bit more information about expected output and the logic which must be done.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
30 November, 2021 08:33:45
itautomation
Topics: 5
Messages: 15
Dear e2pdf support team,

thanks a lot for this amazing support! It helped, and indeed this worked for us.

Now, one more question:

We switched the item for our pdf form from "Order" to "Product", so the pdf is only created for a product with a specific ID. If that product has been selected multiple times in one order, we create multiple pdfs, this part works, but they mostly contain the same data (all from the first product in the order). Is it possible to take data from each configured product for each pdf in one order?

Actually, this works in the first screenshot (where we use e2pdf-wc-product), but not in the second case (where we use e2pdf-wc-order). How could we access the respective product data in the second case?

Thanks a lot!

Best Regards
Sören
30 November, 2021 23:32:19
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

In case if your E2Pdf Template connected to "Products" - it will be correctly to use [e2pdf-wc-product] shortcodes to get correct data for specified product in "Order" as [e2pdf-wc-product key="Holzart (bis Classic)" order_item_meta="true"]. This must work if [e2pdf-download] shortcode used as "Product File URL" or [e2pdf-attachment] shortcodes used inside "Additional Mail Content" and E2Pdf Template connected to "Products".

In "Order" instance it must be used "index" attribute to get information for specified ordered product as:

[e2pdf-wc-order key="line_item" subkey="Holzart (bis Classic)" index="0" order_item_meta="true"] - must get information from 1st Product added to Order.

[e2pdf-wc-order key="line_item" subkey="Holzart (bis Classic)" index="1" order_item_meta="true"] - must get information from 2nd Product added to Order.

and so on.

If it will not work or we miss-understand the task, clarify please more information where and how do you use E2Pdf Shortcodes ([e2pdf-download]/[e2pdf-attachment], and which behavior do you try to create?

We remain at your service.
We would really appreciate your feedback at WordPress.org!
3 December, 2021 06:38:00
itautomation
Topics: 5
Messages: 15
Dear e2pdf support team,

great, we now tranformed all shortcodes to use [e2pdf-wc-product], and it works just fine. Thanks!

Two more minor questions:
* Is there a shortcode to add the index of the product for e2pdf? Say, the customer ordered two times the same product, we would like to be able to differentiate the two generated forms. Or would you propose using unique auto-increment-IDs for this? But then it would not only be unique inside the same order, but also globally across orders.
* Is there a e2pdf shortcode filter to go from "1x (395 €)" to "1x", so to filter out the price tag at the end? Do you support regex filter/replacements or such things?

By the way, if you like to showcase any WooCommerce-related workflow with e2pdf in the future, we can share details on our workflow. Might give others more insights on what's possible with e2pdf. Just as a small thanks for the great support here, as I already wrote my feedback on WordPress.org.

Best Regards
Sören
3 December, 2021 08:21:51
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

1. By default it's not possible, however it must be possible to do with some custom PHP filters or we can review the possibility to add this feature in future. Can you let us know please:
1.1 To which item is connected E2Pdf Template "Orders" / "Products"?
1.2 Do you need index start from 0? 1? Custom?
1.3 Do you need the "index" to output among all products purchased? or just with same Product IDs?
1.4 Which shortcodes do you currently use to get data from product? [e2pdf-wc-product key="get_quantity" order="true"] or [e2pdf-wc-product key="get_quantity" order="true" index="0"] or other?

2. As about truncating the "Value", E2Pdf has regex filter however it's global to the element. See please screenshot attached. Keep in mind please that "HTML" value can convert some "HTML" entities and it could be need to use unconverted value inside "Preg Replace Pattern". To get original "source" you can temporary use "textarea".

If it will not fit your needs, it also must be possible to use as:
[e2pdf-format-output explode="( " output="{0}"][...shortcode which get value...][/e2pdf-format]
But in this case the format must be same for all values as it will split value by " (" and will output only first part.

P.S. Thank you for your offer, we will think how it can be integrated. We have in plans to prepare some page with templates examples or pdf results / links for built solutions with E2Pdf but it's far away in plans.
We would really appreciate your feedback at WordPress.org!
6 December, 2021 07:24:12
itautomation
Topics: 5
Messages: 15
Dear support,

1. Here our answers to your questions:
1.1. We are connected to Products
1.2. As computer scientists we tend towards 0, but display-wise 1 is better. Making it configurable: Even better :-)
1.3. Just with same Product IDs is good enough
1.4. We are using: [e2pdf-wc-product key="Modell" order_item_meta="true"]

2. Works like a charm - thanks!

Best Regards
Sören
6 December, 2021 23:38:38
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

Can you try please add code to your functions.php or as PHP Snippet: https://codeshare.io/DZvloE

Inside E2Pdf Template use shortcode:
[e2pdf-wc-product key="item_response_hook" subkey="index" order="true"]

Let us know please if solution will work for you. Thank you.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
8 December, 2021 06:20:13
itautomation
Topics: 5
Messages: 15
Dear e2pdf Support,

the solution works like a charm - awesome!

Thank you again very much. You really helped us here with outstanding support - we already gave our feedback at WordPress.org.

Best Regards
Sören