I have two tables in my PDF and, for each, I would like to display a column (<td class="travel" for both) only if {select-10} is "Travel Set". Google searches provide script solutions, but I'm not sure I can apply those ... ? Thanks in advance!
... so the code is the same. The if statement works well when the index is 1. It is not working when the index is 2.
Re: the class, I have it added to the td. But I'm wondering if I have to add the if statement to each td or if I can apply the if statement to entire class at once.
January 21, 2025 16:46:07
recuniforms
Topics: 8
Messages: 47
I may have discovered the problem.
January 21, 2025 16:55:13
recuniforms
Topics: 8
Messages: 47
I believe the problem is that it isn't handling the nested if statement. Here is what I'm trying to do:
Unfortunately, yes, nested [e2pdf-if] shortcodes aren't supported, so the shortcode needs to be rebuilt.
Could you please clarify the behavior? Do you need to display:
1. The entire block only when {select-10} is set to "Travel Set" and {select-8} is part of an array?
Or
2. Should it just be a "td" element with a class "travel" when {select-10} is set to "Travel Set," while {select-8} is always displayed but in "td" without class "travel"?
January 22, 2025 06:31:57
recuniforms
Topics: 8
Messages: 47
If I'm understanding correctly, it's neither.
I need anything with class = "travel" to display when {select-10} is "Travel Set." I need it to be hidden when any other option is selected. The code above accomplished that, but it stopped the nested if statement from working properly.
The nested if statement is a conversion based on user input: if the user selects a certain series of jerseys, it uses a certain 1-to-1 conversion; if it's another series of uniforms, it uses a different 1-to-1 conversion.
So for example:
- if the user selects Alpine Kit for {select-8}, Youth S becomes 3XS
- if the user select Abstract Kit {select 6}, Youth S becomes 5XS
So the three columns of the output here becomes:
SKU 1 / SKU 2 / Size
3XS / 5XS / Youth S
There is also a second table that displays an image of the second jersey where the second column is class = "travel." I don't want that column to display either.
The support desk helped me with this code previously.
But if the user did not select "Travel Set", I do not want the SKU 2 column to be displayed.
I hope I'm explaining it well!
January 22, 2025 08:08:49
E2Pdf
Topics: 7
Messages: 3617
Support
The [e2pdf-if] shortcode supports multiple conditions using [&&]: https://e2pdf.com/docs/shortcodes/logic/e2pdf-if#delimiters. Based on your description, it seems you should be able to move the "td" element into the [e2pdf-if-do] shortcode and apply multiple conditions:
This will output the "td" element with the "travel" class and replaced values only if {select-10} equals "Travel Set" and {select-8} is in the array.
January 22, 2025 14:49:06
recuniforms
Topics: 8
Messages: 47
Thank you!
I think that should work if I modify it slightly. If I'm understanding correctly, as is, the td will display when:
- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-8} is not in the array (if else)
The trouble that the td still displays when {select-10} =/= "Travel Set", but {select-8} is not in the array.
I need td to display when:
- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-10} = "Travel Set" AND {select-8} is in the array (a second &&)
I don't want the td to display when {select-10} =/= "Travel Set" regardless of whether {select-8} is in the array.
I tried briefly, but didn't get it to work (though it doesn't seem terribly complicated). I should be able to have multiple if statements (not nested) before the else, correct?
January 22, 2025 14:49:07
recuniforms
Topics: 8
Messages: 47
Thank you!
I think that should work if I modify it slightly. If I'm understanding correctly, as is, the td will display when:
- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-8} is not in the array (if else)
The trouble that the td still displays when {select-10} =/= "Travel Set", but {select-8} is not in the array.
I need td to display when:
- {select-10} = "Travel Set" AND {select-8} is in the array
OR WHEN
- {select-10} = "Travel Set" AND {select-8} is in the array (a second &&)
I don't want the td to display when {select-10} =/= "Travel Set" regardless of whether {select-8} is in the array.
I tried briefly, but didn't get it to work (though it doesn't seem terribly complicated). I should be able to have multiple if statements (not nested) before the else, correct?
It should replace values if {select-10} is Travel Set, regardless of whether the values are in the array or not.
January 23, 2025 05:14:32
recuniforms
Topics: 8
Messages: 47
That worked! Thank you!
January 23, 2025 17:58:21
recuniforms
Topics: 8
Messages: 47
I spoke a little too soon!
It works great when {select-10} = Travel Set, but when {Select-10} =/= Travel Set, it's still showing the cell (though blank). I'd like the cell to be hidden when {Select-10} =/= Travel Set (which should should be the [e2pdf-if-else] condition).
See the attached example.
Here is the code (which is the same you sent previously):
The cell in top row is being hidden properly (it would say Size SKU 2) -- hence why there is one less column in the top row -- but rows 2-6 are displaying blank cells.
January 23, 2025 22:56:07
E2Pdf
Topics: 7
Messages: 3617
Support
Your "td" element is currently outside the "[e2pdf-if]" condition, so it is always being displayed. If you want it to appear only when {select-10} is set to "Travel Set" you need to move it inside the "[e2pdf-if-do]" shortcode of "[e2pdf-if]" conditions: https://codefile.io/f/aVuG2FgwfW.
If this doesn't resolve the issue, please copy all the HTML code you're using and upload it to https://codefile.io.
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements.
By clicking "Accept Selected", you consent to use of selected cookies according to our
Cookie Policy.