1 <?php
  2 
  3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  4 
  5 if ( ! class_exists( 'WC_Email_Customer_Note' ) ) :
  6 
  7 /**
  8  * Customer Note Order Email
  9  *
 10  * Customer note emails are sent when you add a note to an order.
 11  *
 12  * @class       WC_Email_Customer_Note
 13  * @version     2.0.0
 14  * @package     WooCommerce/Classes/Emails
 15  * @author      WooThemes
 16  * @extends     WC_Email
 17  */
 18 class WC_Email_Customer_Note extends WC_Email {
 19 
 20     var $customer_note;
 21 
 22     /**
 23      * Constructor
 24      *
 25      * @access public
 26      * @return void
 27      */
 28     function __construct() {
 29 
 30         $this->id               = 'customer_note';
 31         $this->title            = __( 'Customer note', 'woocommerce' );
 32         $this->description      = __( 'Customer note emails are sent when you add a note to an order.', 'woocommerce' );
 33 
 34         $this->template_html    = 'emails/customer-note.php';
 35         $this->template_plain   = 'emails/plain/customer-note.php';
 36 
 37         $this->subject          = __( 'Note added to your {site_title} order from {order_date}', 'woocommerce');
 38         $this->heading          = __( 'A note has been added to your order', 'woocommerce');
 39 
 40         // Triggers
 41         add_action( 'woocommerce_new_customer_note_notification', array( $this, 'trigger' ) );
 42 
 43         // Call parent constructor
 44         parent::__construct();
 45     }
 46 
 47     /**
 48      * trigger function.
 49      *
 50      * @access public
 51      * @return void
 52      */
 53     function trigger( $args ) {
 54 
 55         if ( $args ) {
 56 
 57             $defaults = array(
 58                 'order_id'      => '',
 59                 'customer_note' => ''
 60             );
 61 
 62             $args = wp_parse_args( $args, $defaults );
 63 
 64             extract( $args );
 65 
 66             $this->object       = new WC_Order( $order_id );
 67             $this->recipient    = $this->object->billing_email;
 68             $this->customer_note = $customer_note;
 69 
 70             $this->find[] = '{order_date}';
 71             $this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
 72 
 73             $this->find[] = '{order_number}';
 74             $this->replace[] = $this->object->get_order_number();
 75         }
 76 
 77         if ( ! $this->is_enabled() || ! $this->get_recipient() )
 78             return;
 79 
 80         $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
 81     }
 82 
 83     /**
 84      * get_content_html function.
 85      *
 86      * @access public
 87      * @return string
 88      */
 89     function get_content_html() {
 90         ob_start();
 91         wc_get_template( $this->template_html, array(
 92             'order'         => $this->object,
 93             'email_heading' => $this->get_heading(),
 94             'customer_note' => $this->customer_note,
 95             'sent_to_admin' => false,
 96             'plain_text'    => false
 97         ) );
 98         return ob_get_clean();
 99     }
100 
101     /**
102      * get_content_plain function.
103      *
104      * @access public
105      * @return string
106      */
107     function get_content_plain() {
108         ob_start();
109         wc_get_template( $this->template_plain, array(
110             'order'         => $this->object,
111             'email_heading' => $this->get_heading(),
112             'customer_note' => $this->customer_note,
113             'sent_to_admin' => false,
114             'plain_text'    => true
115         ) );
116         return ob_get_clean();
117     }
118 }
119 
120 endif;
121 
122 return new WC_Email_Customer_Note();
WooCommerce API documentation generated by ApiGen 2.8.0