1

in woocommerce email template

is it possible to detect email recipient

example

if email recipient is admin or email [email protected]
or if recipient is customer

tried

 if is_admin
 if is shop manager

nothing worked

i did not find anything on the internet

maybe i am not searching correctly

thank you

4
  • It depends on what you want to do. The function is_admin() does only check whether you are in the WordPress admin area, it does not check permissions. But if you edit the email template files you already know it. All PHP files prefixes with "admin-" are sent to the admin, all prefixed with "customer-" to the customer. Where do you execute your code?
    – Hannes
    Commented Sep 27, 2017 at 15:20
  • i have added the customer to receive "cc"... but i want to hide some information from the customer so i thought it would be possible to make if admin show x if customer show y
    – Lolak
    Commented Sep 28, 2017 at 17:04
  • if you add the customer in CC the you send one email to both of them. It can't be changed anymore. But I don't understand why you do that. WooCommerce separates emails for customers from emails for admins. If you use WP HTML Mail for WooCommerce for example you can easily edit all mails.
    – Hannes
    Commented Sep 28, 2017 at 17:15
  • i use a quoting plugin.. when a customer request quote i receive an email but he does not.. so i added customer to cc.. but then he receive also a link to the admin panel and this will confuse him.. so there is no way to make this happen ? i thought maybe i can duplicate this template ? make 1 for admin 1 for customer ? complicated to do ?
    – Lolak
    Commented Sep 28, 2017 at 17:18

1 Answer 1

0

The template you need to override sits on this path

woocommerce/templates/emails/admin-new-order.php

This template can be overridden by copying it to

yourtheme/woocommerce/emails/admin-new-order.php.

You can put your code there and this code will be executed for all the recipients that have been configured through the backend by going to

Woocommerce > Settings > Emails > New order > Recipient(s)

Hope this helps.

1
  • it is different email template... i have added the customer to receive "cc"... but i want to hide some information from the customer
    – Lolak
    Commented Sep 28, 2017 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.