MS_Helper_Billing

The Membership 2 MS Helper Billing class.

Defined (1)

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

/app/helper/class-ms-helper-billing.php  
  1. class MS_Helper_Billing extends MS_Helper { 
  2.  
  3. const BILLING_MSG_ADDED = 1; 
  4. const BILLING_MSG_DELETED = 2; 
  5. const BILLING_MSG_UPDATED = 3; 
  6. const BILLING_MSG_NOT_ADDED = -1; 
  7. const BILLING_MSG_NOT_DELETED = -2; 
  8. const BILLING_MSG_NOT_UPDATED = -3; 
  9. const BILLING_MSG_NOT_A_MEMBER = -5; 
  10.  
  11. public static function get_admin_message( $msg = 0 ) { 
  12. $messages = apply_filters( 
  13. 'ms_helper_billing_get_admin_messages',  
  14. array( 
  15. self::BILLING_MSG_ADDED => __( 'Added new invoice.', 'membership2' ),  
  16. self::BILLING_MSG_DELETED => __( 'Removed invoice(s).', 'membership2' ),  
  17. self::BILLING_MSG_UPDATED => __( 'Invoice details updated.', 'membership2' ),  
  18. self::BILLING_MSG_NOT_ADDED => __( 'Could not add invoice.', 'membership2' ),  
  19. self::BILLING_MSG_NOT_DELETED => __( 'Could not remove invoice(s).', 'membership2' ),  
  20. self::BILLING_MSG_NOT_UPDATED => __( 'Could not update invoice.', 'membership2' ),  
  21. self::BILLING_MSG_NOT_A_MEMBER => __( 'Did not add the invoice: User is not a member of selected Membership.', 'membership2' ),  
  22. ); 
  23.  
  24. if ( array_key_exists( $msg, $messages ) ) { 
  25. return $messages[ $msg ]; 
  26. return null; 
  27.  
  28. public static function print_admin_message() { 
  29. $msg = ! empty( $_GET['msg'] ) ? (int) $_GET['msg'] : 0; 
  30. $class = ( $msg > 0 ) ? 'updated' : 'error'; 
  31. $contents = self::get_admin_message( $msg ); 
  32.  
  33. if ( $contents ) { 
  34. lib3()->ui->admin_message( $contents, $class ); 
  35.  
  36. /** 
  37. * Formats a number to display a valid price. 
  38. * @since 1.0.0 
  39. * @param numeric $price 
  40. * @return numeric 
  41. */ 
  42. static public function format_price( $price ) { 
  43. $formatted = number_format( (float) $price, 2, '.', '' ); 
  44.  
  45. return apply_filters( 
  46. 'ms_format_price',  
  47. $formatted,  
  48. $price 
  49. ); 
  50.