Skip Navigation

[Resolved] Show the shortcodes array with PHP

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 7 years ago.

Assisted by: Luo Yang.

Author
Posts
#589909

Hi Luo, i opened this extra ticket to spread the different questions on the same topic.

Concerning your reply #589663 :

I'd need to show that value via PHP on pages such as 'checkout'. I tried with a simple echo do shortcode but that didnt work out.
The shortcodes in question are:
[wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-nl"]"]
[wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-fr"]"]
and so on.
As you may know, there are about 15 of these (1 per region) and only 1 will show a value. So we should maybe need 'hide' the results from the other 14 shortcodes, to come to a simple clean line with 1 result.
How would that work??

PS i have a custom checkout temlate located in child theme/woocommerce/checkout/.. and line 39 is where i put that simple echo.

And: will this work (show result) on the woocommerce emails if i include the code in the mail templates?

Thanks and kind regards

#590095

Dear filip,

Q1) So we should maybe need 'hide' the results from the other 14 shortcodes, to come to a simple clean line with 1 result.
You can put all the shortcode you mentioned above into another content template, for example content template "all-in-one":

[wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-nl"]"]
[wpv-post-body view_template="show-the-label-values" id="[wpv-user field="wpcf-billing-addresses-fr"]"]
...

Then display them with only one shortcode of content template "all-in-one", for example:
[wpv-post-body view_template="all-in-one"]

You can display the content template "all-in-one" in your theme file with Views PHP function "render_view_template", for example, the ID of content template "all-in-one" is 123, then you can use below PHP codes:

echo render_view_template('123');

See our document:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template
render_view_template
Returns the content of a Content Template applied to a post.

Q2) will this work (show result) on the woocommerce emails if i include the code in the mail templates?
That depends on how do you setup the woocommerce emails, you can test it and start a new thread if there is any problem

#590335

Dear Luo, thanks! For external reasons I'll be picking this up again only after the weekend.

#590413

OK, please update this thread when you need more assistance. thanks