WC_Shipping_Local_Pickup::sanitize_cost()publicWC 8.3.0

Sanitize the cost field.

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

Хуков нет.

Возвращает

Строку.

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

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

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

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

Код WC_Shipping_Local_Pickup::sanitize_cost() 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;
}