wc_format_option_price_num_decimals

Formats decimals when saved in settings.

Description

(string) wc_format_option_price_num_decimals( (string) $value, (array) $option, (string) $raw_value ); 

Returns (string)

Parameters (3)

0. $value (string)
The value.
1. $option (array)
The option.
2. $raw_value (string)
The raw value.

Usage

  1. if ( !function_exists( 'wc_format_option_price_num_decimals' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The value. 
  5. $value = ''; 
  6.  
  7. // The option. 
  8. $option = array(); 
  9.  
  10. // The raw value. 
  11. $raw_value = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wc_format_option_price_num_decimals($value, $option, $raw_value); 
  15.  

Defined (1)

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

/includes/wc-formatting-functions.php  
  1. function wc_format_option_price_num_decimals( $value, $option, $raw_value ) { 
  2. return is_null( $raw_value ) ? 2 : absint( $raw_value );