Basic PHP, guidance needed for Woocommerce customer email - wordpress

I know this is basic PHP, but I am just starting off. I'm editing the Woocommerce email template for customer confirmation emails /woocommerce/emails/customer-processing-order.php
I need to add a link which pulls the customer email and products ordered into the URL. This is where I am up to:
<div style="text-align:center">
Click here
</div>
This is not working for me, but I appreciate my basic PHP knowledge is poor so I've probably made a pretty fundamental mistake here. How can I reference customers email and products ordered into a URL string? Thanks.

First of all, it is a wrong practice to update the email templates located at /woocommerce/emails/ directory directly.
If you need to make customization for woocommerce email templates, you need to copy, the file
from /woocommerce/emails/customer-processing-order.php to
content/themes/yourtheme/woocommerce/emails/customer-processing-order.php .
Refer https://docs.woocommerce.com/document/template-structure/ for details.
For the rest, I as stated by #Jignesh , just pass order id , in the url and then in the template, you may get order details using
$order = wc_get_order( $order_id );

Related

Link description of Wordpress site on discord

I encountered a problem while sending a link to my new Wordpress site to a friend. While the link on every other platform shows exactly the same description, as it should. Discord, on the other hand, puts author above description so that when the link is sent it sais:
[mydomain.com]
admin
[description]
It is not that much of a problem but I think that it should not take a place, especially when I often link lot of things on discord.
Adding this block of code to your wordpress functions.php (use child theme if necessary)
This is the shortest method of removing the data that discord pulls in though it will remove the data from being view from every site that wants to embed a link.
/* Disable oEmbeds author name & author url ~ Stops Showing in embeds */
add_filter( 'oembed_response_data', 'disable_embeds_filter_oembed_response_data_' );
function disable_embeds_filter_oembed_response_data_( $data ) {
unset($data['author_url']);
unset($data['author_name']);
return $data;
}
Note this was taken from another post on stackOverflow and isnt my own code : there is also a more compliacted solution on this thread as well. original post
This can also have so negative effects on SEO due to not sharing the data, and we all know google loves data.
An alternative solution is to set the author of the post to the site name rather than the admin user.
Side note you really should change your username from admin to something less generic so a potentual hacker has to work out the username as well as the password.

Wordpress Woocommerce plugin mail triggering

Mail not sending when status changed from processing to on-hold and processing to failed.
Kindly tell me how to achieve this. Thanks in advance
Even that kind of questions (directly asking the need without any research or any part of code) are not welcomed here, I want to help you about that by giving the basic idea.
In the file "wp-content/plugins/woocommerce/includes/class-wc-emails.php", search for the "public static function init_transactional_emails()" and check "$email_actions" array there.
$email_actions = apply_filters(
'woocommerce_email_actions', array(
'woocommerce_low_stock',
'woocommerce_no_stock',
'woocommerce_product_on_backorder',
'woocommerce_order_status_pending_to_processing',
'woocommerce_order_status_pending_to_completed',
'woocommerce_order_status_processing_to_cancelled',
'woocommerce_order_status_pending_to_failed',
'woocommerce_order_status_pending_to_on-hold',
'woocommerce_order_status_failed_to_processing',
'woocommerce_order_status_failed_to_completed',
'woocommerce_order_status_failed_to_on-hold',
'woocommerce_order_status_on-hold_to_processing',
'woocommerce_order_status_on-hold_to_cancelled',
'woocommerce_order_status_on-hold_to_failed',
'woocommerce_order_status_completed',
'woocommerce_order_fully_refunded',
'woocommerce_order_partially_refunded',
'woocommerce_new_customer_note',
'woocommerce_created_customer',
)
);
Since after every update of Woocommerce plugin any changes you made on those files will be gone, you need to add your email trigger for status changes you mentioned by either using a hook or overriding the files using your child theme.
About your request, for "from processing to on-hold" you need to add:
'woocommerce_order_status_processing_to_on-hold',
About overriding a file (or function) from includes folder of Woocommerce you may check this post: Override woocommerce files from includes folder
I hope this will help you to solve it. Have a good day.

woocommerce edit order before send to clients email

Im using wordpress with woocommerce.
I cant find solution how to NOT send automatically email after purchase order, but admin can edit and add extra shiping cost individualy and then send email.
Thank you everyone for help.
I figure it out! This code put in functions.php file
function my_change_status_function ($order_id) {$order = new WC_Order($order_id); return 'on-hold';}

Notify email when someone's posted a review in WooCommerce

I noticed that Woocommerce's reviews are managed through Wordpress Comments. But why is it that Wordpress isn't notifying my email when someone posted a review to a product. I have set the "Email me whenever anyone posted a comment".
Is this function available in Woocommerce or i'm missing something?
Please advise, thanks everyone!
Regards, Ven
By default Wordpress sends a notification to the author of the product/post (the person who created the product in your instance). The suggested site owner (settings > general) is not the recipient of these notifications. This is where the trouble might start. This author information is in Woocommerce hidden and is hard to figure out who that is in your user database. It might be that the original author of the product doesn't exist anymore, and especially if the original author has been deleted from the database and you didn't move the contents of that user to a new user.
The default comment notifications are produced in this Wordpress file: wp-includes/pluggable.php
Below is a trick to override the recipient for the comment/review notification, put this code in your child-theme's functions.php and change the part example#example.com to your desired email recipient and you will receive a notification every time someone adds a comment/review to your site.
function new_comment_moderation_recipients( $emails, $comment_id ) {
return array( 'example#example.com' );
}
add_filter( 'comment_moderation_recipients', 'new_comment_moderation_recipients', 24, 2 );
add_filter( 'comment_notification_recipients', 'new_comment_moderation_recipients', 24, 2 );
I tested it and it works.
On the Wordpress Dashboard navigate to Settings > General and the Email address listed here is where you will get notifications.

Author Post Specific Banners with Admin Control and Expiry system

I have try to get answer from Wordpress Answer but instead of getting answer I earn Thmbleweed badge. :( anyways so I am trying here and hopping solution.
My new website going to have multiple author. All I need to do with that some specific system where Admin can add banner to the specific author's post.
Fore example xxx banner will only display on xyz author's post and not on any other author post. Which will have auto expiry system, it will automatically invisible when it reach to defined date by admin. All these systems will be under admin control only.
I am not php guy but can play with wordpress codes a bit. So I need really great help to work this out. I also won't mind to give full credit on my website credit display for this system.
Create a table with fields:id, authorid, banner_content, expiry_date.
To fill in the table with specific details of authorid,
banner_content, expiry_date create a simple form or directly enter in
the database.
After your table is created and is filled with details
HERE IS THE COMPLETE CODE TO DISPLAY THE BANNER
<?php
$getid = $posts[0]->post_author; //No need to change this
$sql= "SELECT * FROM bannertable wbanner WHERE author_id = $getid AND expiry_date>CURDATE();"; //change the table name 'bannertable' and field names 'author_id' and 'expiry_date' to your own
$banner_con=$wpdb->get_results($sql);
echo "<div class='banner'>";
foreach ( $banner_con as $content )
{
echo $content->banner; //change field name 'banner'.
}
echo "</div>
?>
Make sure to enter the above code inside the loop of your theme.

Resources