MS_Model_Communication_Before_Payment_Due

Communication model - before payment is due.

Defined (1)

The class is defined in the following location(s).

/app/model/communication/class-ms-model-communication-before-payment-due.php  
  1. class MS_Model_Communication_Before_Payment_Due extends MS_Model_Communication { 
  2.  
  3. /** 
  4. * Communication type. 
  5. * @since 1.0.0 
  6. * @var string The communication type. 
  7. */ 
  8. protected $type = self::COMM_TYPE_BEFORE_PAYMENT_DUE; 
  9.  
  10. /** 
  11. * Populates the field title/description of the Period before/after field 
  12. * in the admin settings. 
  13. * @since 1.0.0 
  14. * @param array $field A HTML definition, passed to lib3()->html->element() 
  15. */ 
  16. public function set_period_name( $field ) { 
  17. $field['title'] = __( 'Notice Period', 'membership2' ); 
  18. $field['desc'] = __( 'Define, how many days in advance the user should be notified.', 'membership2' ); 
  19.  
  20. return $field; 
  21.  
  22. /** 
  23. * Get communication description. 
  24. * @since 1.0.0 
  25. * @return string The description. 
  26. */ 
  27. public function get_description() { 
  28. return __( 
  29. 'Sent a predefined number of days before the payment is due. You must decide how many days beforehand a message is to be sent.', 'membership2' 
  30. ); 
  31.  
  32. /** 
  33. * Communication default communication. 
  34. * @since 1.0.0 
  35. */ 
  36. public function reset_to_default() { 
  37. parent::reset_to_default(); 
  38.  
  39. $this->subject = __( 'Membership payment due soon', 'membership2' ); 
  40. $this->message = self::get_default_message(); 
  41. $this->enabled = false; 
  42. $this->period_enabled = true; 
  43.  
  44. do_action( 
  45. 'ms_model_communication_reset_to_default_after',  
  46. $this->type,  
  47. $this 
  48. ); 
  49.  
  50. /** 
  51. * Get default email message. 
  52. * @since 1.0.0 
  53. * @return string The email message. 
  54. */ 
  55. public static function get_default_message() { 
  56. $subject = sprintf( 
  57. __( 'Hi %1$s, ', 'membership2' ),  
  58. self::COMM_VAR_USERNAME 
  59. ); 
  60. $body_notice = sprintf( 
  61. __( 'This is a reminder that the next payment for your %1$s membership at %2$s will be due on (%3$s).', 'membership2' ),  
  62. self::COMM_VAR_MS_NAME,  
  63. self::COMM_VAR_BLOG_NAME,  
  64. self::COMM_VAR_MS_EXPIRY_DATE 
  65. ); 
  66. $body_invoice = __( 'Here are your latest invoice details:', 'membership2' ); 
  67.  
  68. $html = sprintf( 
  69. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s<br /><br />%4$s',  
  70. $subject,  
  71. $body_notice,  
  72. $body_invoice,  
  73. self::COMM_VAR_MS_INVOICE 
  74. ); 
  75.  
  76. return apply_filters( 
  77. 'ms_model_communication_before_payment_due_get_default_message',  
  78. $html 
  79. );