Skip Navigation

[Closed] Getting content template data in WooCommerce email

This support ticket is created 3 years, 6 months 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/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Waqar 3 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1819907

Hi Waqar,

on our page there is a possibility to buy a ticket for a sportscamp. We have a custom template to show all the info about the camp. Is it possible to take the data from the content template and pull it into the confirmation email that the customer gets, so they can see what they bought? Right now they only see the camp name and the price. Not the specific info with age, level, etc.

#1823743

Hi Waqar,

Do you need anything from me?

#1826785

Waqar
Supporter

Languages: English (English )

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

Hi,

I apologize for the delay in getting back on this as I had a busy queue after the weekend.

Just wanted to let you know that I'll be running some tests based on your requirement and will be able to share my findings with you, in next few hours.

Thank you for your patience.

regards,
Waqar

#1828465

Waqar
Supporter

Languages: English (English )

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

Hi,

Thank you for waiting.

I've performed some tests and research and I was able to include the content from a Toolset content template into the WooCommerce's "order completed" email, using the "woocommerce_email_before_order_table" hook from WooCommerce.
( ref: hidden link )

Example:


add_action( 'woocommerce_email_before_order_table', 'custom_add_content_specific_email', 20, 4 );
  
function custom_add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
	if ( $email->id == 'customer_completed_order' ) {
		$target_post = 123;
		$target_ct = 456;
		echo render_view_template( $target_ct, $target_post );
	}
}

Note: You'll replace "123" with the post ID of the target "sportscamp" post and "456" with the ID of the target content template to use.

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

Also, you'll find the information about the Toolset's "render_view_template" function here:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

I couldn't find any WooCommerce hook to send a duplicate email to another user, so it would best to consult their official support team or community forums, for that part.

regards,
Waqar

#1828565

Hi Waqar,

That sounds good. Just to be sure: When I put in an ID for the specific sportscamp - will that only include this single camp then? Because I need the data to appear on the mail no matter what camp the customer buys. Do you know what I mean?

#1832775

Waqar
Supporter

Languages: English (English )

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

Hi,

Thanks for writing back.

Yes, in my example code snippet, I just used a fixed sports camp post ID, to give you an idea. To use the sports camp post ID dynamically, it would depend on what connection/relationship you have with the purchased/ordered product and the sports camp post.

Can you please share some information about that and if admin access would help in getting clearer picture, you're welcome to share that too.

Note: Your next reply will be private and though no changes will be made on your website, please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1843039

Waqar
Supporter

Languages: English (English )

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

Thank you for sharing the admin access.

I understand that the first form to add a new camp is on the page "Welcome host" ( /welcome-host/ ).

And the second form to add a new product is on page "Welcome host – product info" ( /welcome-host-product-info/ ).

Since a post-relationship exists between these two post types, I'll assume, that you'd also like to link the posts created as a result of these forms in this post-relationship's association.

Using some extra custom code, it may be possible to create a "Product" post, programmatically, when the first form for the camp is submitted, but, before I could suggest the next steps, I'll need to clearly understand the role/need of the fields used in the second form for the product.

The "Price" needs to be saved with the product post, but the title of the camp post can be the same as the product post.

Is there any special reason for the fields like "Antal ledige pladser på campen", "Indtast dit registreringsnummer", and "Indtast dit kontonummer" to be saved with the product post and not the camp post?

The topic ‘[Closed] Getting content template data in WooCommerce email’ is closed to new replies.