Geen omschrijving

class-wc-email-customer-on-hold-order.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * Class WC_Email_Customer_On_Hold_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_On_Hold_Order', false ) ) :
  11. /**
  12. * Customer On-hold Order Email.
  13. *
  14. * An email sent to the customer when a new order is on-hold for.
  15. *
  16. * @class WC_Email_Customer_On_Hold_Order
  17. * @version 2.6.0
  18. * @package WooCommerce\Classes\Emails
  19. * @extends WC_Email
  20. */
  21. class WC_Email_Customer_On_Hold_Order extends WC_Email {
  22. /**
  23. * Constructor.
  24. */
  25. public function __construct() {
  26. $this->id = 'customer_on_hold_order';
  27. $this->customer_email = true;
  28. $this->title = __( 'Order on-hold', 'woocommerce' );
  29. $this->description = __( 'This is an order notification sent to customers containing order details after an order is placed on-hold.', 'woocommerce' );
  30. $this->template_html = 'emails/customer-on-hold-order.php';
  31. $this->template_plain = 'emails/plain/customer-on-hold-order.php';
  32. $this->placeholders = array(
  33. '{order_date}' => '',
  34. '{order_number}' => '',
  35. );
  36. // Triggers for this email.
  37. add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
  38. add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
  39. add_action( 'woocommerce_order_status_cancelled_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
  40. // Call parent constructor.
  41. parent::__construct();
  42. }
  43. /**
  44. * Get email subject.
  45. *
  46. * @since 3.1.0
  47. * @return string
  48. */
  49. public function get_default_subject() {
  50. return __( 'Your {site_title} order has been received!', 'woocommerce' );
  51. }
  52. /**
  53. * Get email heading.
  54. *
  55. * @since 3.1.0
  56. * @return string
  57. */
  58. public function get_default_heading() {
  59. return __( 'Thank you for your order', 'woocommerce' );
  60. }
  61. /**
  62. * Trigger the sending of this email.
  63. *
  64. * @param int $order_id The order ID.
  65. * @param WC_Order|false $order Order object.
  66. */
  67. public function trigger( $order_id, $order = false ) {
  68. $this->setup_locale();
  69. if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
  70. $order = wc_get_order( $order_id );
  71. }
  72. if ( is_a( $order, 'WC_Order' ) ) {
  73. $this->object = $order;
  74. $this->recipient = $this->object->get_billing_email();
  75. $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
  76. $this->placeholders['{order_number}'] = $this->object->get_order_number();
  77. }
  78. if ( $this->is_enabled() && $this->get_recipient() ) {
  79. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
  80. }
  81. $this->restore_locale();
  82. }
  83. /**
  84. * Get content html.
  85. *
  86. * @return string
  87. */
  88. public function get_content_html() {
  89. return wc_get_template_html(
  90. $this->template_html,
  91. array(
  92. 'order' => $this->object,
  93. 'email_heading' => $this->get_heading(),
  94. 'additional_content' => $this->get_additional_content(),
  95. 'sent_to_admin' => false,
  96. 'plain_text' => false,
  97. 'email' => $this,
  98. )
  99. );
  100. }
  101. /**
  102. * Get content plain.
  103. *
  104. * @return string
  105. */
  106. public function get_content_plain() {
  107. return wc_get_template_html(
  108. $this->template_plain,
  109. array(
  110. 'order' => $this->object,
  111. 'email_heading' => $this->get_heading(),
  112. 'additional_content' => $this->get_additional_content(),
  113. 'sent_to_admin' => false,
  114. 'plain_text' => true,
  115. 'email' => $this,
  116. )
  117. );
  118. }
  119. /**
  120. * Default content to show below main email content.
  121. *
  122. * @since 3.7.0
  123. * @return string
  124. */
  125. public function get_default_additional_content() {
  126. return __( 'We look forward to fulfilling your order soon.', 'woocommerce' );
  127. }
  128. }
  129. endif;
  130. return new WC_Email_Customer_On_Hold_Order();