WC_Shipping_Free_Shipping::sanitize_cost()publicWC 8.3.0

Sanitize the cost field.

Метод класса: WC_Shipping_Free_Shipping{}

Хуков нет.

Возвращает

Строку.

Использование

$WC_Shipping_Free_Shipping = new WC_Shipping_Free_Shipping();
$WC_Shipping_Free_Shipping->sanitize_cost( $value );
$value(строка) (обязательный)
Unsanitized value.

Список изменений

С версии 8.3.0 Введена.

Код WC_Shipping_Free_Shipping::sanitize_cost() WC 9.3.3

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;
}