1. Home
  2. Docs
  3. woocommerce ‘Custom Email’ & ‘문자 알림’
  4. Custom WooCommerce Email 추가하기

Custom WooCommerce Email 추가하기

방법 3단계:

  1. Extending WC_Email class to define the email header, subject, email template for content, etc.
  2. Adding our custom email class to the default WooCommerce email classes using woocommerce_email_classes filter
  3. Creating our own email template to be used to generate email content for our custom email.

예제 – 첫 구매 시 환영 메일을 보내는 방법

※ 테마에 직접 추가가 아닌 wrodpress  upload 폴더에 코드를 추가하는 방법 활용

  1. Create directory crwc-custom-emails inside wp-content > uploads.
  2. Create file crwc-email-functions.php in the root of crwc-custom-emails directory (crwc-custom-emails > crwc-email-functions.php).
  3. Create file class-crwc-welcome-email.php in the root of crwc-custom-emails directory (crwc-custom-emails > class-crwc-welcome-email.php).
  4. Create a sub-directory emails inside crwc-custom-emails directory.
  5. Create a new file crwc-welcome-email.php inside the emails directory (crwc-custom-emails > emails > crwc-welcome-email.php).
  6. You can also choose to create a sub-directory plain inside emails directory and then create crwc-welcome-email.php file inside plain directory (crwc-custom-emails > emails > plain > crwc-welcome-email.php). This will be used in case emails use plain content-type.

■ Building custom email class

Add the following code to class-crwc-welcome-email.php file.

 

Viewing custom email settings

우커머스 > 설정 > 이메일에서 기본 이메일 리스트에 표시 및 설정을 할 수 있도록 추가된 클래스를 디폴트 클래스 묶음에 추가

on WooCommerce Emails screen under WooCommerce > Settings > Emails, we’ll need to add this class to the default email classes in WooCommerce. In order to do that, we’ll make use of the woocommerce_email_classes filter to include custom email class to the default classes.

Add the following code to crwc-email-functions.php file (inside crwc-custom-emails directory).

 

 Creating custom email template

탬플릿 파일 만들고 구성하기.

Add the following code to crwc-welcome-email.php file (inside emailsdirectory).

 

 Start making Custom WooCommerce email work

In order to do so, you can just add the following code to your theme’s functions.php:


!! _crwc_welcome_email_sent 라는 유저메타를 활용하여 최초 1회만 환영 메일을 발송함.