WC_Settings_Tax::get_posted_tax_rate()privateWC 1.0

Get a posted tax rate.

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

Хуков нет.

Возвращает

Массив.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_posted_tax_rate( $key, $order, $class );
$key(строка) (обязательный)
Key of tax rate in the post data array.
$order(int) (обязательный)
Position/order of rate.
$class(строка) (обязательный)
Tax class for rate.

Код WC_Settings_Tax::get_posted_tax_rate() WC 8.7.0

private function get_posted_tax_rate( $key, $order, $class ) {
	// phpcs:disable WordPress.Security.NonceVerification.Missing -- this is called from 'save_tax_rates' only, where nonce is already verified.
	$tax_rate      = array();
	$tax_rate_keys = array(
		'tax_rate_country',
		'tax_rate_state',
		'tax_rate',
		'tax_rate_name',
		'tax_rate_priority',
	);

	// phpcs:disable WordPress.Security.NonceVerification.Missing
	foreach ( $tax_rate_keys as $tax_rate_key ) {
		if ( isset( $_POST[ $tax_rate_key ], $_POST[ $tax_rate_key ][ $key ] ) ) {
			$tax_rate[ $tax_rate_key ] = wc_clean( wp_unslash( $_POST[ $tax_rate_key ][ $key ] ) );
		}
	}

	$tax_rate['tax_rate_compound'] = isset( $_POST['tax_rate_compound'][ $key ] ) ? 1 : 0;
	$tax_rate['tax_rate_shipping'] = isset( $_POST['tax_rate_shipping'][ $key ] ) ? 1 : 0;
	$tax_rate['tax_rate_order']    = $order;
	$tax_rate['tax_rate_class']    = $class;
	// phpcs:enable WordPress.Security.NonceVerification.Missing

	return $tax_rate;
	// phpcs:enable WordPress.Security.NonceVerification.Missing
}