I have an issue regarding emails sent by Woocommerce.
I have multiple custom fields, set up using the ACF plugin, for Wooocomerce orders. These fields contain additional info that should be visible in the emails sent to the user.
But for some reason I can't get them to save before the email is send and thus the email is empty of those values. Only after I click resend email are the values visible.
I tried prioritizing the action hooks using the Prioritize Hooks plugin but to no avail. Tried multiple things in order to prioritize.
I have the Woocommerce emails set up in the template that I use and get retrieve the custom fields like this:
$fields = get_field('fields', $customer_order->ID);
How can I get this to work properly? Any help is appreciated.
you need to store your data before send the email, so you need to find the correct hook.
If i'm not wrong the before_woocommerce_pay hook is your answer check here for more woocommerce hooks
Related
I am familiar with elementor forms new_record hook that I can work with and add some custom actions.
I am looking for a way to add some custom metadata to the save_to_database action elementor has, which saves the form submission in the DB. I have searched and have not found any specific hook that allows me to add custom metadata.
I would like to have on the new_record hook the submission id that was stored and then I can write my own query as needed.
Does anyone know of a way to get the submission id on this hook?
Thanks
I have posts on my website (custom post type) of which the content is filled from advanced custom fields input. The post also include a date field and an email address field. What I like to do is send automatic notifications to the email address when the date is today. Or even better 3 days before the date of today.
I've read some articles about using Wordpress php mail function but don't know where to start. Any points in the right direction are appreciated.
So you can use the Wordpress wp_mail() function.
https://developer.wordpress.org/reference/functions/wp_mail/
Make sure you are using a SMPT plugin so your email doesn't end up in spam.
https://wordpress.org/plugins/wp-mail-smtp/
That should get you started, not sure how I would set up the job to send the mail, by I would definitely use wp_mail().
This might be off topic question but I would like to ask it anyway to the developers out there.
Is there a plugin or whatever, that can enable automatic single use coupon code delivery to a user on wordpress/page?
Basically WordPress will send an email to the customer and then the user takes an action (clicks button, clicks link from email), and can see a unique, single use, coupon code back to the wordpress site? Each user of course would see a unique coupon code because there would need to have been a list of unique coupon codes selected/uploaded to begin with.
Thanks for your kind answers if there is any. Please.
I am not sure if this is what you are looking for:
YITH WOOCOMMERCE COUPON EMAIL SYSTEM
I am trying to run something similar to this function.
wp_new_user_notification( $new_user_id );
this function above works already but I would like to use the woocommerce function. As that includes a better email template. I know I can tick it on in the woocommerce admin. But I am using my own form script for the user registration. Which doesn't trigger the woocommerce email notification.
I found this function somewhere in the woocommerce code but I have no idea how to use it.
woocommerce_created_customer_notification.
Please help thanks!
Yes you are right woocommerce includes a better email template, but this is not a good practice to use them in php script for registration script.
You can use your custom code for new user registration email and change you email template as you wish.
For second option there are many plugins available for new user email.
like :https://wordpress.org/plugins/welcome-email-editor/
I'm sure this isn't possible but I thought I would ask.
In my functions.php file I have a wp_mail function that sends an email to moderators when posts are made.
This email is sent to number of different address - these addresses might change.
I thought it would easier to set these email addresses in the WP Dashboard something like on custom page and then have functions.php update with the new emails.
Is this possible?
Yes, this is possible.
With out getting into the specific coding details you would need to store the different email addresses in the database.
You could tie in advanced custom fields to the wp_mail function to pull the different address from a list. That way you could skip building a page in the dashboard to display the addresses.
Regardless some custom coding would need to happen in the mail function to grab the data from advanced custom fields.