NF_Fields_Total

Class NF_Field_Total.

Defined (1)

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

/includes/Fields/Total.php  
  1. class NF_Fields_Total extends NF_Abstracts_Input 
  2. protected $_name = 'total'; 
  3.  
  4. protected $_section = 'pricing'; 
  5.  
  6. protected $_icon = 'money'; 
  7.  
  8. protected $_aliases = array(); 
  9.  
  10. protected $_type = 'total'; 
  11.  
  12. protected $_templates = 'total'; 
  13.  
  14. protected $_test_value = '0.00'; 
  15.  
  16. protected $_settings_exclude = array( 'placeholder', 'default', 'input_limit_set', 'disable_input', 'required' ); 
  17.  
  18. public function __construct() 
  19. parent::__construct(); 
  20.  
  21. $this->_nicename = __( 'Total', 'ninja-forms' ); 
  22.  
  23. public function process( $total, $data ) 
  24. $subtotal = 0; 
  25.  
  26. foreach( $data[ 'fields' ] as $key => $field ) { 
  27.  
  28. if( isset ( $field[ 'type' ] ) && 'shipping' == $field[ 'type' ] ) { 
  29. $subtotal += $field[ 'shipping_cost' ]; 
  30.  
  31. if( isset( $data[ 'product_totals' ] ) ) { 
  32.  
  33. foreach( $data[ 'product_totals' ] as $product_total ) { 
  34.  
  35. $subtotal += $product_total; 
  36.  
  37. $data[ 'new_total' ] = number_format( $subtotal, 2 ); 
  38.  
  39. return $data;