Do you want to micromanage the shipping rates on your ecommerce website? Table rates shipping method allows you to apply shipping rates to a cart based on:
- Cart price and the shipping destination;
- Weight of items in the cart and the shipping destination;
- The number of items in the cart and the shipping destination.
For example, it may cost you less to ship an item to San Fransisco and more to ship the same item to Washington. You can pass on this difference in shipping costs to your customer with table rate shipping.
This tutorial is a part of our series on configuring shipping settings in Magento 2.
In this tutorial, you’ll learn how to setup table rates shipping in Magento 2. Table rates are created in a CSV file and then uploaded from Magento admin panel.
Setting up table rate shipping in Magento 2 is a two-step process:
Configuring the Default Settings
Step 1: Go to Stores => Configuration (under Settings)
Step 2: Expand Sales tab from the left sidebar and click on Shipping Methods. Expand the Table Rates section.
Step 3: Uncheck the Use System Value box and fill in the following details:
- Enabled: Set this to “Yes” to enable table rate shipping.
- Title: This is the shipping method title which appears during checkout. Set your desired title here. By default, Magento sets this field to “Best Way.”
- Method Name: This is the shipping method name which appears next to the calculated rate in the cart.
- Condition: You can set this to one of the three following options –
- Weight v. Destination: Choose this method when you want to vary shipping rates based on the weight of items in the cart and where they are to be shipped. For example, setting rates to ship an item (in weight range 500 grams to 2 kg) to New York versus shipping the same item to Kansas.
- Price v. Destination: Choose this method when you want to vary shipping rates based on the price of the items in the cart.
- # of items v. Destination: Choose this method when you want to vary shipping rates based on the number of products in a cart.
- Include Virtual Products in Price Calculation: Set whether you want to apply the table rates shipping method to virtual products or not. By default, this setting is set to “No” as you don’t need to ship virtual products. Also, Weight v. Destination condition doesn’t apply to virtual products as they don’t have any weight.
- Calculate Handling Fee: If you want to charge a handling fee, you can select one of the two options:
- Fixed: Keep handling fee as a constant amount.
- Percent: Calculate handling fee as a percentage of the shipping cost.
- Handling Fee: Enter the amount which you want to use to calculate handling fee. This amount will be used according to the option you’ve selected in the previous section.
- Displayed Error Message: Type in the error message you want to be displayed when the table rates shipping method is not applicable to the order.
- Ship to Applicable Countries: Set whether you want to ship to all countries you’ve allowed in your shipping settings or a subset of it. Select one of the following options:
- All Allowed Countries
- Specific Countries
- Ship to Specific Countries: If you select to ship to specific countries, this option becomes available to you. Select the countries you want to ship to.
- Show Method if Not Applicable: Set whether you want to display the table rates shipping method even when it is not applicable for an order.
- Sort Order: Set the position of table rates shipping in the shipping methods list. Set this field to ‘0’ to keep table rates shipping as the first shipping method option.
Step 4: Once you’ve filled in the required details, click on Save Config button in the top right corner to save your shipping method configuration.
You’ll be prompted to refresh invalidated cache types via a system pop-up message.
Follow these steps to flush the cache in Magento 2.
Preparing and Uploading the Table Rates CSV
Now that you’ve set up default settings for the table rates shipping method, you need to create a CSV with all the shipping rates.
Follow Step 1 and Step 2 from the previous section to go to Table Rates shipping settings.
Step 3: On the top left corner of the page, you’ll see the Store View settings.
Select the website for which you want to apply table rates shipping. In our example, we’ll use Main Website to set up the shipping method.
When you select a website, two new fields become available – Export and Import. We’ll use these fields to export and import our table rates CSV.
Step 4: If you’re creating table rates CSV for the first time, you’ll need a template. Click on Export CSV button to download the current CSV – tablerates.csv.
We’ve set the condition to Price v. Destination, the tablerates.csv we’ve downloaded looks like:
Notice how shipping rates for Alaska, Hawaii and rest of the regions of US are different. The shipping price depends on the order subtotal. When the order subtotal is between $0-50, $50-100 and above $100, the shipping price changes.
‘*’ means all the Zip/Postal codes in that region.
Step 5: Fill in the tablerates.csv according to your preference and save.
Step 6: Click on the Choose file button near Import setting and select the tablerates.csv you’ve created to upload.
Step 7: Click on Save Config button in the top right corner of the page to upload the table rates CSV.
You’ll be prompted to refresh invalidated cache types.
Follow these steps to flush the cache.
The new rates are now applicable on your storefront.
Go through the payment process with different addresses and verify that the shipping rates are being calculated correctly with the table rates shipping method.
This brings us to the end of our tutorial on how to set up table rates shipping method in Magento 2.