wc_string_to_bool

Converts a string (e.g.

Description

wc_string_to_bool( (string) $string ); 

yes or no) to a bool.

Parameters (1)

0. $string (string)
The string.

Usage

  1. if ( !function_exists( 'wc_string_to_bool' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The string. 
  5. $string = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_string_to_bool($string); 
  9.  

Defined (1)

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

/includes/wc-formatting-functions.php  
  1. function wc_string_to_bool( $string ) { 
  2. return is_bool( $string ) ? $string : ( 'yes' === $string || 1 === $string || 'true' === $string || '1' === $string );