class-wc-email-customer-processing-order.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * Class WC_Email_Customer_Processing_Order file.
  4. *
  5. * @package WooCommerce\Emails
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit; // Exit if accessed directly.
  9. }
  10. if ( ! class_exists( 'WC_Email_Customer_Processing_Order', false ) ) :
  11. /**
  12. * Customer Processing Order Email.
  13. *
  14. * An email sent to the customer when a new order is paid for.
  15. *
  16. * @class WC_Email_Customer_Processing_Order
  17. * @version 2.0.0
  18. * @package WooCommerce/Classes/Emails
  19. * @extends WC_Email
  20. */
  21. class WC_Email_Customer_Processing_Order extends WC_Email {
  22. /**
  23. * Constructor.
  24. */
  25. public function __construct() {
  26. $this->id = 'customer_processing_order';
  27. $this->customer_email = true;
  28. $this->title = __( 'Processing order', 'woocommerce' );
  29. $this->description = __( 'This is an order notification sent to customers containing order details after payment.', 'woocommerce' );
  30. $this->template_html = 'emails/customer-processing-order.php';
  31. $this->template_plain = 'emails/plain/customer-processing-order.php';
  32. $this->placeholders = array(
  33. '{site_title}' => $this->get_blogname(),
  34. '{order_date}' => '',
  35. '{order_number}' => '',
  36. );
  37. // Triggers for this email.
  38. add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
  39. add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
  40. add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
  41. // Call parent constructor.
  42. parent::__construct();
  43. }
  44. /**
  45. * Get email subject.
  46. *
  47. * @since 3.1.0
  48. * @return string
  49. */
  50. public function get_default_subject() {
  51. return __( 'Your {site_title} order receipt from {order_date}', 'woocommerce' );
  52. }
  53. /**
  54. * Get email heading.
  55. *
  56. * @since 3.1.0
  57. * @return string
  58. */
  59. public function get_default_heading() {
  60. return __( 'Thank you for your order', 'woocommerce' );
  61. }
  62. /**
  63. * Trigger the sending of this email.
  64. *
  65. * @param int $order_id The order ID.
  66. * @param WC_Order|false $order Order object.
  67. */
  68. public function trigger( $order_id, $order = false ) {
  69. $this->setup_locale();
  70. if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
  71. $order = wc_get_order( $order_id );
  72. }
  73. if ( is_a( $order, 'WC_Order' ) ) {
  74. $this->object = $order;
  75. $this->recipient = $this->object->get_billing_email();
  76. $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
  77. $this->placeholders['{order_number}'] = $this->object->get_order_number();
  78. }
  79. if ( $this->is_enabled() && $this->get_recipient() ) {
  80. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
  81. }
  82. $this->restore_locale();
  83. }
  84. /**
  85. * Get content html.
  86. *
  87. * @access public
  88. * @return string
  89. */
  90. public function get_content_html() {
  91. return wc_get_template_html(
  92. $this->template_html, array(
  93. 'order' => $this->object,
  94. 'email_heading' => $this->get_heading(),
  95. 'sent_to_admin' => false,
  96. 'plain_text' => false,
  97. 'email' => $this,
  98. )
  99. );
  100. }
  101. /**
  102. * Get content plain.
  103. *
  104. * @access public
  105. * @return string
  106. */
  107. public function get_content_plain() {
  108. return wc_get_template_html(
  109. $this->template_plain, array(
  110. 'order' => $this->object,
  111. 'email_heading' => $this->get_heading(),
  112. 'sent_to_admin' => false,
  113. 'plain_text' => true,
  114. 'email' => $this,
  115. )
  116. );
  117. }
  118. }
  119. endif;
  120. return new WC_Email_Customer_Processing_Order();