How to Pass [e2pdf-wc-order key="get_id"] Output to Another Shortcode’s Attribute

January 09, 2025 11:37:25
eliodata
Topics: 19
Messages: 57
Hello,

I’m trying to retrieve the current WooCommerce order ID inside my own custom shortcode when generating a PDF automatically.

If I place [e2pdf-wc-order key="get_id"] by itself in the template, it correctly displays the current order ID (for example, “268259”).

Also, if I manually hardcode [fsbdd_all_days order_id="268259"], it works perfectly for order ID 268259, and displays the full planning from my custom CPT.

However, if I attempt to do:

csharp
Copier le code
[fsbdd_all_days order_id="[e2pdf-wc-order key='get_id']"]
the ID does not get passed to my shortcode. Essentially, my shortcode does not receive the correct order ID.

How can I ensure that the value returned by [e2pdf-wc-order key='get_id'] is properly passed as the order_id attribute to my custom shortcode [fsbdd_all_days]?

Thank you in advance for your help!
January 09, 2025 12:36:28
E2Pdf
Topics: 7
Messages: 3617
Support
Hello,

Unfortunately, WordPress doesn't support nested shortcodes as attributes by default. However, it is possible to accomplish this task with some modifications to your shortcode function and additional PHP code:

1. Your shortcode should be modified to use the inner content as follows:

[fsbdd_all_days][e2pdf-wc-order key="get_id"][/fsbdd_all_days]

To do so, the shortcode function should be modified as follows:

https://codefile.io/f/uczvKXh78T

2. A filter should be added to your theme's functions.php file or as a PHP snippet to allow the shortcode to work as nested in the E2Pdf Template:

https://codefile.io/f/By0gUpCZDM

We would really appreciate your feedback at WordPress.org!
January 10, 2025 01:10:01
eliodata
Topics: 19
Messages: 57
Best support ever, as usual!
Thank you guys :)
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
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.
© 2017 - 2026, https://e2pdf.com

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.