Skip Navigation

[Resolved] Information from content template still not showing up in email

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.

This topic contains 19 replies, has 2 voices.

Last updated by maiS 2 months ago.

Assigned support staff: Waqar.

Author
Posts
#1902109

Hi Waqar,

In this ticket we worked on pulling information from the content template to the confirmaiton and order emails so that people can see what kind of camp they bought. But i just made a test and no information except the camp name and price are being pulled into the email.

Here is the ticket we worked in: https://toolset.com/forums/topic/add-information-to-email-continued/

I need these data pulled:
Startdato (start date)
Slutdato (end date)
Alder og Niveau (Age and Level)
Overnatning (Sleep over)
Træner (It means "coach" and i just need the first one listed)
Adresse (address of the camp)

Can you help?

#1902749

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Mai,

I've checked your website and couldn't find the second code snippet related to "woocommerce_email_before_order_table".
( ref: https://toolset.com/forums/topic/add-information-to-email-continued/page/2/#post-1885927 )

Can you please share where and how you've included it and also share the exact steps that you've used for the testing?

regards,
Waqar

#1904133

Hi Waqar,

As test i just added a camp to cart via the "add to cart" button on the camp template - then i proceeded to checkout and finished the checkout as normal.

I am sorry, I have not put in any snippet i think - does it go to the functions.php? Sorry!

#1905363

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Yes, the second code snippet from my reply https://toolset.com/forums/topic/add-information-to-email-continued/page/2/#post-1885927 ( screenshot: hidden link ), also needs to be placed at the bottom of the active theme's "functions.php" file.

As an example, I've added a simple content template "Test CT to show camp details in the email" with ID "1288" on the website, and please note how it includes some basic information about the camp post.

While adding that second code snippet, don't forget to replace the ID "12345" with this actual content template's ID "1288":


$target_ct = 1288;

After that, please place an order for a product that has a related camp and then change that order's status to "completed" from the admin area and you'll receive an email from WooCommerce that the order is now complete.
(it will be sent to the customer's email who placed the order).

In that email's content, you'll see that the related camp's details will be available, through the content template "Test CT to show camp details in the email".

#1908171
Skærmbillede 2021-01-17 kl. 16.18.12.png

Hi Waqar,

Okay so now i put in the code and changed the ID with the content templates ID. But still nothing happens. As you can see on my screenshot i only get the default infos in the products area. I also added some extra fields during the checkout which are the fields you see below the product fields.

Can you help? Thank you so much

#1910401

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Mai,

I've checked the code in the theme's "functions.php" file and it is calling for the content template with ID "224", which is built using the Blocks editor.

As suggested in my previous reply, can you please test the process again using a simpler content template with ID "1288"?

The output of blocks based content templates is complex and you may get unexpected results if you'll try to call it inside the emails.

regards,
Waqar

#1912957

Oh I am sorry - i will try 1288 and get back to you!

#1912979
Skærmbillede 2021-01-21 kl. 09.29.52.png

Hi Waqar,
It is the same result - no extra data is appearing. The data below the product info is from the checkout process and not the camp template.

#1915661

Hi waqar - just commenting so the ticket won't close.

#1917327

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I'm not sure exactly which email are you checking, but here are my test results:

1. I ordered the product "Test entry from Waqar with 25 openings" using a test account and received these two emails, as a customer:

a). Welcome email "Velkommen til FindSportsCamps"
( screenshot: hidden link )

b). Ordered received email "Tak for din ordre"
( screenshot: hidden link )

2. After that, as an admin, I changed the status of my order to completed and which triggered this email to my customer account, confirming that my order has been completed "Mange tak for at handle hos os".
( screenshot: hidden link )

The content shown highlighted in the red box, is coming from the content template "Test CT to show camp details in email" ( ID: 1288 )

#1918225

Hi Waqar,

Ah i see now - so what is happening in this email result:
2. After that, as an admin, I changed the status of my order to completed and which triggered this email to my customer account, confirming that my order has been completed "Mange tak for at handle hos os".
( screenshot: hidden link )

is the results i actually want for this one:
b). Ordered received email "Tak for din ordre"
( screenshot: hidden link )

So the emails that we use are the "new order" mail to the admin and host of the camp and the "thank you for your order" mail that the customer gets when they buy a camp, and it is these two email that i wish for the data to appear in.

I am so sorry for not making that clear. We are not going to mark the orders as "completed" at any time so the customer will basically only recieve the "thank you for your order" email.

Also from what i saw on your screenshot i was wondering about 2 minor things:
1) if instead of having the whole link postet if we can just attach the link to the Camp Title in the email?
2) Is it possible to move the data down below the default woocommerce box with product info?

#1918579

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for clearing this up that you'd like to target the "order received" email and not the "order completed" one.

1. To change this, you can change line 4 from the second code snippet that I shared in the other reply, from:
( ref: https://toolset.com/forums/topic/add-information-to-email-continued/page/2/#post-1885927 )


if ( $email->id == 'customer_completed_order' ) {

To:


if ( ($email->id == 'customer_processing_order') || ($email->id == 'new_order') ) {

Related guide: hidden link

This change will make that code work for the "new order received" emails, sent to the customer and the website's admin.

2. To have the camp title as a link in the email, you can replace the following code from the "Test CT to show camp details in email" content template:


[wpv-post-title] ( [wpv-post-url] )

With the "wpv-post-link" shortcode:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-link )


[wpv-post-link]

3. To move your custom content in the email after the WooCommerce's information table, you can change line # 2 from the same second code snippet, from:
( ref: https://toolset.com/forums/topic/add-information-to-email-continued/page/2/#post-1885927 )


add_action( 'woocommerce_email_before_order_table', 'custom_add_content_specific_email', 20, 4 );

To:


add_action( 'woocommerce_email_after_order_table', 'custom_add_content_specific_email', 20, 4 );

#1921365

Hi Waqar,
So i added your changes but now the data is still not showing up in the New order mail. Both the Admin and the customer get the new order mail and neither of these mails has the data included right now.

#1928101

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Mai,

I've checked your active theme's "functions.php" file and noticed this line in the code snippet in question:


if ( $email->id == 'customer_processing_order' ) {

This way it will only target the "Your order has been received!" email sent to the customer and not the one that is sent to the admins.

To target, the new order received emails sent to the customer and the admins, you should use the line from my last reply:


if ( ($email->id == 'customer_processing_order') || ($email->id == 'new_order') ) {

I couldn't complete the checkout process on your website as it keeps showing me a "406 Security Incident Detected" message. But, I tested the code snippet on my test website and it worked as expected.

regards,
Waqar

#1928719

Hi Waqar, i just made a test with a random camp on the site and i still do not get any data in my mails - not the "new order mail" or the "processing order mail".

Can you help?