PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/theme WP a cương/test_wp/wp-content/plugins/woocommerce/classes/emails/class-wc-email-customer-invoice.php

https://gitlab.com/hop23typhu/list-theme
PHP | 185 lines | 113 code | 21 blank | 51 comment | 13 complexity | 36cf8473e7e1d052fc21c57535918f2f MD5 | raw file
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  3. /**
  4. * Customer Invoice
  5. *
  6. * An email sent to the customer via admin.
  7. *
  8. * @class WC_Email_Customer_Invoice
  9. * @version 2.0.0
  10. * @package WooCommerce/Classes/Emails
  11. * @author WooThemes
  12. * @extends WC_Email
  13. */
  14. class WC_Email_Customer_Invoice extends WC_Email {
  15. var $find;
  16. var $replace;
  17. /**
  18. * Constructor
  19. */
  20. function __construct() {
  21. $this->id = 'customer_invoice';
  22. $this->title = __( 'Customer invoice', 'woocommerce' );
  23. $this->description = __( 'Customer invoice emails can be sent to the user containing order info and payment links.', 'woocommerce' );
  24. $this->template_html = 'emails/customer-invoice.php';
  25. $this->template_plain = 'emails/plain/customer-invoice.php';
  26. $this->subject = __( 'Invoice for order {order_number} from {order_date}', 'woocommerce');
  27. $this->heading = __( 'Invoice for order {order_number}', 'woocommerce');
  28. $this->subject_paid = __( 'Your {blogname} order from {order_date}', 'woocommerce');
  29. $this->heading_paid = __( 'Order {order_number} details', 'woocommerce');
  30. // Call parent constructor
  31. parent::__construct();
  32. }
  33. /**
  34. * trigger function.
  35. *
  36. * @access public
  37. * @return void
  38. */
  39. function trigger( $order ) {
  40. global $woocommerce;
  41. if ( ! is_object( $order ) ) {
  42. $order = new WC_Order( absint( $order ) );
  43. }
  44. if ( $order ) {
  45. $this->object = $order;
  46. $this->recipient = $this->object->billing_email;
  47. $this->find[] = '{order_date}';
  48. $this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
  49. $this->find[] = '{order_number}';
  50. $this->replace[] = $this->object->get_order_number();
  51. }
  52. if ( ! $this->is_enabled() || ! $this->get_recipient() )
  53. return;
  54. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
  55. }
  56. /**
  57. * get_subject function.
  58. *
  59. * @access public
  60. * @return string
  61. */
  62. function get_subject() {
  63. if ( $this->object->status == 'processing' || $this->object->status == 'completed' )
  64. return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $this->subject_paid ), $this->object );
  65. else
  66. return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $this->subject ), $this->object );
  67. }
  68. /**
  69. * get_heading function.
  70. *
  71. * @access public
  72. * @return string
  73. */
  74. function get_heading() {
  75. if ( $this->object->status == 'processing' || $this->object->status == 'completed' )
  76. return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $this->heading_paid ), $this->object );
  77. else
  78. return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $this->heading ), $this->object );
  79. }
  80. /**
  81. * get_content_html function.
  82. *
  83. * @access public
  84. * @return string
  85. */
  86. function get_content_html() {
  87. ob_start();
  88. woocommerce_get_template( $this->template_html, array(
  89. 'order' => $this->object,
  90. 'email_heading' => $this->get_heading()
  91. ) );
  92. return ob_get_clean();
  93. }
  94. /**
  95. * get_content_plain function.
  96. *
  97. * @access public
  98. * @return string
  99. */
  100. function get_content_plain() {
  101. ob_start();
  102. woocommerce_get_template( $this->template_plain, array(
  103. 'order' => $this->object,
  104. 'email_heading' => $this->get_heading()
  105. ) );
  106. return ob_get_clean();
  107. }
  108. /**
  109. * Initialise Settings Form Fields
  110. *
  111. * @access public
  112. * @return void
  113. */
  114. function init_form_fields() {
  115. $this->form_fields = array(
  116. 'enabled' => array(
  117. 'title' => __( 'Enable/Disable', 'woocommerce' ),
  118. 'type' => 'checkbox',
  119. 'label' => __( 'Enable this email notification', 'woocommerce' ),
  120. 'default' => 'yes'
  121. ),
  122. 'subject' => array(
  123. 'title' => __( 'Email subject', 'woocommerce' ),
  124. 'type' => 'text',
  125. 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->subject ),
  126. 'placeholder' => '',
  127. 'default' => ''
  128. ),
  129. 'heading' => array(
  130. 'title' => __( 'Email heading', 'woocommerce' ),
  131. 'type' => 'text',
  132. 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->heading ),
  133. 'placeholder' => '',
  134. 'default' => ''
  135. ),
  136. 'subject_paid' => array(
  137. 'title' => __( 'Email subject (paid)', 'woocommerce' ),
  138. 'type' => 'text',
  139. 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->subject_paid ),
  140. 'placeholder' => '',
  141. 'default' => ''
  142. ),
  143. 'heading_paid' => array(
  144. 'title' => __( 'Email heading (paid)', 'woocommerce' ),
  145. 'type' => 'text',
  146. 'description' => sprintf( __( 'Defaults to <code>%s</code>', 'woocommerce' ), $this->heading_paid ),
  147. 'placeholder' => '',
  148. 'default' => ''
  149. ),
  150. 'email_type' => array(
  151. 'title' => __( 'Email type', 'woocommerce' ),
  152. 'type' => 'select',
  153. 'description' => __( 'Choose which format of email to send.', 'woocommerce' ),
  154. 'default' => 'html',
  155. 'class' => 'email_type',
  156. 'options' => array(
  157. 'plain' => __( 'Plain text', 'woocommerce' ),
  158. 'html' => __( 'HTML', 'woocommerce' ),
  159. 'multipart' => __( 'Multipart', 'woocommerce' ),
  160. )
  161. )
  162. );
  163. }
  164. }