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.
Related
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 );
Lots of our users forgot e-mail adress details and passwords for our website and they are asking me to help them log in.
When I change their password/e-mail adress they receive an e-mail message like this:
Blockquote
From: WordPress <wordpress#example.com>
To: username#example.com
Subject: [WordPress] Password Changed
Hi username,
This notice confirms that your password was changed on WordPress.
If you did not change your password, please contact the Site Administrator at admin#example.com
This email has been sent to username#example.com
Regards,
All at WordPress
http://example.com/
I'd like to customize the message which is sent, but this template doesn't appear in the /wp-admin/Emails tab, like the message which is sent when users change their password themselves.
Could you help me, please?
The correct way to do it, following Wordpress guidelines is by using add_filer for the password_change_email hook.
Do not change wp-includes files as recommended above, as it will be overrun by future WP releases.
you can add the filter in your functions.php file of your theme, or in a plugin.
here's how it should look like roughly:
function my_theme_password_change_email($pass_change_email, $user, $userdata){
//do your changes here
}
add_filter( "password_change_email", "my_theme_password_change_email",10,3 )
See this - add to your functions file
<?php // << remove this
// https://developer.wordpress.org/reference/functions/wp_update_user/
add_filter('password_change_email', 'wpse207879_change_password_mail_message', 10, 3 );
function wpse207879_change_password_mail_message( $pass_change_mail, $user, $userdata) {
/* placeholders are:
'###USERNAME###'
'###ADMIN_EMAIL###'
'###EMAIL###'
'###SITENAME###'
'###SITEURL###'
*/
$new_message_txt = __( '
Hi ###USERNAME###,
This notice confirms that your password on ###SITENAME### was recently changed.
If you did not change your password, please contact us ASAP via our website contact page: ###SITEURL###.
This email has been sent to ###EMAIL###.
Regards,
All at ###SITENAME###
###SITEURL###'
);
$pass_change_mail[ 'message' ] = $new_message_txt;
return $pass_change_mail;
}
The file where these emails are handled are in the root of your wordpress installation. The exact file is wp-login.php. I hope this helps.
Just edit below file from root directory located in /wp-includes/user.php line no. 2009 or search for 'Hi ###USERNAME###, and you will find the message body as below that you can customize it as you would like.
$pass_change_text = __(
'Hi ###USERNAME###,
This notice confirms that your password was changed on ###SITENAME###.
If you did not change your password, please contact the Site Administrator at ###ADMIN_EMAIL###
This email has been sent to ###EMAIL###
Regards,
All at ###SITENAME###
###SITEURL###'
);
I have a website where a customer can enable a front end 'profile' page. These customers have the role of 'customer' as defined by wooCommerce. However, this user role does not provide enough privilege to enable an author page for that user. How do I add the capability of an author archive?
In an ideal world I'd like to continue to use author.php as the template instead of creating some sort of work around author template.
Adding the following code to function.php file will add wp-admin toolbar for all users including customers.
This plugin will help you to add code from dashboard: https://wordpress.org/plugins/code-snippets/
/* Allow customers to access wp-admin */
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
add_filter( 'woocommerce_disable_admin_bar', '__return_false' );
Alrighty! Figured it out. Thanks, everyone for the answers, however, this is for a front-end author page, not backend access.
// remove wooCommerce redirect from authors.php template
remove_action('template_redirect', 'wc_disable_author_archives_for_customers', 10 );
Turns out WooCommerce disables author archives for customers. In my case, a customer is also a member and therefore I need to author.php template accessible.
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';}
I am setting up an ecommerce site using Wordpress and WooCommerce. We are using the wordpress member accounts to track customer information, and we need a way for logged in members only to be able to choose to purchase their cart "on credit", meaning no payment is required to place the order. Basically what I have done is hi-jacked the "Check" option (since we don't need it anywhere else) and renamed it "Credit" since it allows for the functionality we need.
However, I need a way for the "Credit" (check) option to only display if the user is logged in. Is there any way I can just "unhook" this option if the user isn't logged in? This seems like something that would be easy to do, but I couldn't find anything about it. Any help is appreciated.
The original answer to this question (from BWDesign) no longer works due to changes in WooCommerce (at least from WooCommerce 2.1.7 onwards, possibly before). This does the trick now (tested on 2.1.7 and 2.1.8), add it to e.g. your functions.php file:
add_filter( "woocommerce_available_payment_gateways", "rp_filter_gateways", 9999 );
function rp_filter_gateways($args) {
if(!is_user_logged_in() && isset($args['cheque'])) {
unset($args['cheque']);
}
return $args;
}
I just found the solution. In the class-wc-cheque.php file, the check or "cheque" (crazy brits) option is hooked using add_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );. So the solution was simply to add this code to my functions.php file:
if(!is_user_logged_in()){
remove_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );
}
Hope this helps!