Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats

DataStore::get_taxes()public staticWC 1.0

Get taxes associated with a store.

{} Это метод класса: DataStore{}

Хуков нет.

Возвращает

Массив. An array of all taxes.

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

$result = DataStore::get_taxes( $args );
$args(массив) (обязательный)
Array of args to filter the query by. Supports include.

Код DataStore::get_taxes() WC 6.6.1

public static function get_taxes( $args ) {
	global $wpdb;
	$query = "
		SELECT 
			tax_rate_id, 
			tax_rate_country, 
			tax_rate_state, 
			tax_rate_name, 
			tax_rate_priority 
		FROM {$wpdb->prefix}woocommerce_tax_rates
	";
	if ( ! empty( $args['include'] ) ) {
		/* phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared */
		$tax_placeholders = implode( ',', array_fill( 0, count( $args['include'] ), '%d' ) );
		$query           .= $wpdb->prepare( " WHERE tax_rate_id IN ({$tax_placeholders})", $args['include'] );
		/* phpcs:enable */
	}
	return $wpdb->get_results( $query, ARRAY_A ); // WPCS: cache ok, DB call ok, unprepared SQL ok.
}