/theme WP a cương/test_wp/wp-content/plugins/woocommerce/classes/emails/class-wc-email-customer-invoice.php
PHP | 185 lines | 113 code | 21 blank | 51 comment | 13 complexity | 36cf8473e7e1d052fc21c57535918f2f MD5 | raw file
- <?php
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
- /**
- * Customer Invoice
- *
- * An email sent to the customer via admin.
- *
- * @class WC_Email_Customer_Invoice
- * @version 2.0.0
- * @package WooCommerce/Classes/Emails
- * @author WooThemes
- * @extends WC_Email
- */
- class WC_Email_Customer_Invoice extends WC_Email {
- var $find;
- var $replace;
- /**
- * Constructor
- */
- function __construct() {
- $this->id = 'customer_invoice';
- $this->title = __( 'Customer invoice', 'woocommerce' );
- $this->description = __( 'Customer invoice emails can be sent to the user containing order info and payment links.', 'woocommerce' );
- $this->template_html = 'emails/customer-invoice.php';
- $this->template_plain = 'emails/plain/customer-invoice.php';
- $this->subject = __( 'Invoice for order {order_number} from {order_date}', 'woocommerce');
- $this->heading = __( 'Invoice for order {order_number}', 'woocommerce');
- $this->subject_paid = __( 'Your {blogname} order from {order_date}', 'woocommerce');
- $this->heading_paid = __( 'Order {order_number} details', 'woocommerce');
- // Call parent constructor
- parent::__construct();
- }
- /**
- * trigger function.
- *
- * @access public
- * @return void
- */
- function trigger( $order ) {
- global $woocommerce;
- if ( ! is_object( $order ) ) {
- $order = new WC_Order( absint( $order ) );
- }
- if ( $order ) {
- $this->object = $order;
- $this->recipient = $this->object->billing_email;
- $this->find[] = '{order_date}';
- $this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
- $this->find[] = '{order_number}';
- $this->replace[] = $this->object->get_order_number();
- }
- if ( ! $this->is_enabled() || ! $this->get_recipient() )
- return;
- $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
- }
- /**
- * get_subject function.
- *
- * @access public
- * @return string
- */
- function get_subject() {
- if ( $this->object->status == 'processing' || $this->object->status == 'completed' )
- return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $this->subject_paid ), $this->object );
- else
- return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $this->subject ), $this->object );
- }
- /**
- * get_heading function.
- *
- * @access public
- * @return string
- */
- function get_heading() {
- if ( $this->object->status == 'processing' || $this->object->status == 'completed' )
- return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $this->heading_paid ), $this->object );
- else
- return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $this->heading ), $this->object );
- }
- /**
- * get_content_html function.
- *
- * @access public
- * @return string
- */
- function get_content_html() {
- ob_start();
- woocommerce_get_template( $this->template_html, array(
- 'order' => $this->object,
- 'email_heading' => $this->get_heading()
- ) );
- return ob_get_clean();
- }
- /**
- * get_content_plain function.
- *
- * @access public
- * @return string
- */
- function get_content_plain() {
- ob_start();
- woocommerce_get_template( $this->template_plain, array(
- 'order' => $this->object,
- 'email_heading' => $this->get_heading()
- ) );
- return ob_get_clean();
- }
- /**
- * Initialise Settings Form Fields
- *
- * @access public
- * @return void
- */
- function init_form_fields() {
- $this->form_fields = array(
- 'enabled' => array(
- 'title' => __( 'Enable/Disable', 'woocommerce' ),
- 'type' => 'checkbox',
- 'label' => __( 'Enable this email notification', 'woocommerce' ),
- 'default' => 'yes'
- ),
- 'subject' => array(
- 'title' => __( 'Email subject', 'woocommerce' ),
- 'type' => 'text',
- 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->subject ),
- 'placeholder' => '',
- 'default' => ''
- ),
- 'heading' => array(
- 'title' => __( 'Email heading', 'woocommerce' ),
- 'type' => 'text',
- 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->heading ),
- 'placeholder' => '',
- 'default' => ''
- ),
- 'subject_paid' => array(
- 'title' => __( 'Email subject (paid)', 'woocommerce' ),
- 'type' => 'text',
- 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->subject_paid ),
- 'placeholder' => '',
- 'default' => ''
- ),
- 'heading_paid' => array(
- 'title' => __( 'Email heading (paid)', 'woocommerce' ),
- 'type' => 'text',
- 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->heading_paid ),
- 'placeholder' => '',
- 'default' => ''
- ),
- 'email_type' => array(
- 'title' => __( 'Email type', 'woocommerce' ),
- 'type' => 'select',
- 'description' => __( 'Choose which format of email to send.', 'woocommerce' ),
- 'default' => 'html',
- 'class' => 'email_type',
- 'options' => array(
- 'plain' => __( 'Plain text', 'woocommerce' ),
- 'html' => __( 'HTML', 'woocommerce' ),
- 'multipart' => __( 'Multipart', 'woocommerce' ),
- )
- )
- );
- }
- }