WC_Shipping_Free_Shipping::sanitize_cost()
Sanitize the cost field.
Method of the class: WC_Shipping_Free_Shipping{}
No Hooks.
Return
String
.
Usage
$WC_Shipping_Free_Shipping = new WC_Shipping_Free_Shipping(); $WC_Shipping_Free_Shipping->sanitize_cost( $value );
- $value(string) (required)
- Unsanitized value.
Changelog
Since 8.3.0 | Introduced. |
WC_Shipping_Free_Shipping::sanitize_cost() WC Shipping Free Shipping::sanitize cost code WC 9.4.2
public function sanitize_cost( $value ) { $value = is_null( $value ) ? '' : $value; $value = wp_kses_post( trim( wp_unslash( $value ) ) ); $value = str_replace( array( get_woocommerce_currency_symbol(), html_entity_decode( get_woocommerce_currency_symbol() ) ), '', $value ); $test_value = str_replace( wc_get_price_decimal_separator(), '.', $value ); $test_value = str_replace( array( get_woocommerce_currency_symbol(), html_entity_decode( get_woocommerce_currency_symbol() ), wc_get_price_thousand_separator() ), '', $test_value ); if ( $test_value && ! is_numeric( $test_value ) ) { throw new Exception( __( 'Please enter a valid number', 'woocommerce' ) ); } return $value; }