← Blog

Updates,

Saleor 3.8 & 3.9: flat rates, tax exemption API, and GraphiQL

Avatar
Karol Kielecki

This article summarizes the 3.8 and 3.9 releases of Saleor. We introduced flat rates along with a tax exemption API, GraphiQL V2, and more.


Saleor 3.8: GraphiQL 2 and tax exemption API

GraphiQL 2

We have switched to the long-awaited GraphiQL 2 which adds many enhancements compared to the previous playground. Notable improvements are:

  • improved user interface
  • query history
  • merge fragments into query
  • sharable playgrounds - see the video below:

playgif small.gif

Tax exemption API

We’ve added a new permission to manage this API - MANAGE TAXES.

You can use the following mutation to disable taxes from a specific checkout - you can also set a tax exemption for orders. You need to provide a checkout ID, or order ID, and set the flag to false.

GRAPHQL
1mutation {
2 taxExemptionManage(id: "checkout-id", taxExemption: false) {
3 taxableObject {
4 __typename
5 ... on Checkout {
6 token
7 }
8 }
9 }
10}

Check our documentation to learn more about tax exemption API.

Filtering by slugs

You can now filter through a slug in the following objects:

  • Attribute
  • Category
  • Collection
  • Menu
  • Page
  • Product
  • ProductType
  • Warehouse

New product filters

You can use the following new product filters:

  • isAvailable
  • publishedFrom
  • availableFrom
  • isVisibleInListings

Datagrid

Now you can manage product data with a spreadsheet interface directly in the dashboard, bulk updates, copy-paste from external sources, and more 🚀

datagrid4.gif

All summarized pull requests that have been merged are available in the following Saleor 3.8 Changelog.


Saleor 3.9: new tax calculation API

Introduction to tax improvements

With v3.9, we introduced the complete rework of the tax calculation engine. The new tax API allows defining tax rates per country and tax class. What’s more, you can also customize taxes per channel. The following concept introduces tax configuration (a channel configuration) and tax classes (tax for specific countries). We’ve also decided to drop the Vatlayer plugin because our new engine covers a major part of its logic.

Tax configuration

The tax configuration object defines different configuration options for a channel, such as tax calculation method, whether to charge taxes in this channel or whether prices are entered, including tax. The tax configuration object is created automatically for each sales channel. In the API, it is represented by the TaxConfiguration object. See the API reference for descriptions of all properties.

Below are some common examples of getting and managing the tax configuration.

Fetching tax configurations

To fetch a list of tax configurations with their properties, use the following query:

GRAPHQL
1query TaxConfigurations {
2 taxConfigurations(first: 10) {
3 edges {
4 node {
5 id
6 channel {
7 slug
8 }
9 chargeTaxes
10 displayGrossPrices
11 pricesEnteredWithTax
12 taxCalculationStrategy
13 }
14 }
15 }
16}

To query a specific tax configuration by ID, use the query below (in this case, we’re only asking for the taxCalculationStrategy field):

GRAPHQL
1query TaxConfiguration {
2 taxConfiguration(id: "VGF4Q29uZmlndXJhdGlvbjox") {
3 taxCalculationStrategy
4 }
5}

Updating the tax configuration

The taxConfigurationUpdate mutation allows you to update a specific tax configuration. The example below shows how to set the tax calculation strategy to dynamic taxes (in API represented as the TAX_APP option):

GRAPHQL
1mutation {
2 taxConfigurationUpdate(id: "VGF4Q29uZmlndXJhdGlvbjox", input: { taxCalculationStrategy: TAX_APP }) {
3 errors {
4 field
5 message
6 }
7 taxConfiguration {
8 taxCalculationStrategy
9 }
10 }
11}

Overriding tax configuration per country

You can override channel-specific tax configurations for different countries. Let’s consider the following example: there is a single sales channel that uses flat rates for EU countries, but for the US, it uses the Avalara integration. To represent such a scenario in Saleor, we need to set the flat rates as the channel’s default tax calculation strategy and override the configuration for the US to use dynamic taxes:

GRAPHQL
1mutation {
2 taxConfigurationUpdate(
3 id: "VGF4Q29uZmlndXJhdGlvbjox"
4 input: {
5 taxCalculationStrategy: FLAT_RATES
6 updateCountriesConfiguration: [
7 { countryCode: US, taxCalculationStrategy: TAX_APP, displayGrossPrices: false, chargeTaxes: true }
8 ]
9 }
10 ) {
11 errors {
12 field
13 message
14 }
15 taxConfiguration {
16 taxCalculationStrategy
17 countries {
18 country {
19 code
20 }
21 chargeTaxes
22 taxCalculationStrategy
23 displayGrossPrices
24 }
25 }
26 }
27}

Flat tax rates

Flat rates are the default tax calculation strategy that is enabled for any new sales channel. With this method, you can configure static tax rates and associate them with products, product types, or shipping methods. Tax rates can be defined either as default country rates or can be overridden for specific products with tax classes. During checkout, Saleor uses either default country rates or overridden values from tax classes.

Enabling flat rates for a channel

To enable flat rates, use the following mutation:

GRAPHQL
1mutation {
2 taxConfigurationUpdate(id: "VGF4Q29uZmlndXJhdGlvbjox", input: { taxCalculationStrategy: FLAT_RATES }) {
3 errors {
4 field
5 message
6 }
7 taxConfiguration {
8 taxCalculationStrategy
9 }
10 }
11}

Creating a default national tax rate

The default national tax rate is used for products and shipping methods when there is no other tax class assigned to them. In the following mutation, we used the Polish default tax rate (23%):

GRAPHQL
1mutation {
2 taxCountryConfigurationUpdate(countryCode: PL, updateTaxClassRates: [{ rate: 23 }]) {
3 taxCountryConfiguration {
4 country {
5 code
6 }
7 taxClassCountryRates {
8 rate
9 }
10 }
11 errors {
12 field
13 message
14 }
15 }
16}

Assigning a specific tax rate to a product

To create a tax rate that would be used only for specific products, you must create a tax class and assign it to the product. The example below shows a tax class “Healthcare products” with an 8% tax rate for Poland:

GRAPHQL
1mutation {
2 taxClassCreate(input: { name: "Healthcare products", createCountryRates: [{ countryCode: PL, rate: 8 }] }) {
3 errors {
4 field
5 message
6 }
7 taxClass {
8 id
9 countries {
10 rate
11 }
12 }
13 }
14}

To assign a tax class to a product, use the following mutation:

GRAPHQL
1mutation {
2 productUpdate(id: "UHJvZHVjdDox", input: { taxClass: "VGF4Q2xhc3M6Mg==" }) {
3 errors {
4 field
5 message
6 }
7 product {
8 taxClass {
9 name
10 }
11 }
12 }
13}

Setting flat tax rates via dashboard

You can also see how to manage flat rates via your dashboard in the video below. As you have probably already noticed, we have introduced a new, fresh look to the Saleor Dashboard.

Saleor simple taxes

A flat tax rate is not the only change delivered. Please check the Saleor 3.9 changelog to read more about all improvements.


In this blog post, we highlighted some of the key changes and improvements in Saleor 3.8 and 3.9. Follow our Twitter and sign up for our newsletter to stay up to date with the latest info about Saleor!

Cheers!

– The Saleor Team

Get more useful guides, tech insights, and free learning materials by subscribing to our list.
All human-written!

By registering you agree to our Privacy Policy.
The form is protected by reCAPTCHA - Privacy Policy and Terms of Service.