Menu icon
RedCrackle
Menu icon
Services
01Design Transformation
About UsCase StudiesBlogContact Us

<

Blog post

Configuring Flat Shipping Rate Based On The Shopper's Shipping Address

Neerav Mehta

Founder & CEO

This is tutorial #16 in the Drupal Commerce tutorial series. Earlier, we added a basic shipping rate of $10 to every order placed on the site. In this article, we will go a step further and determine shipping rates based on the shopper's location.

I am going to charge a flat rate of $15 if the shipping address is for California. All other states will continue having the $10 shipping rate.

The following screenshots will highlight what we seek to achieve through this article.

A shipping flat rate of $15 for all California-based orders:

Shipping Rate

And a shipping flat rate of $10 for all other states:

Shipping Rate

To begin with, click “Store”:

Shipping Rate

Click “Configuration”:

Shipping Rate

Click “Shipping”:

Shipping Rate

You will notice the default flat rate already present there – it’s the one we configured to impose a $10 flat rate. Click “Add a flat rate service”:

Shipping Rate

In the new screen, I want you to create a new flat rate. Give it a custom title and display of your choice. I have given a base rate of $15 as can be seen below. Click “Save flat rate”:

Shipping Rate

The new flat rate has been saved:

Shipping Rate

Click configure component on the right of “Flat Rate For California”:

Shipping Rate

You will now be taken to the Rules page where you can configure how you want the new flat rate to behave. Notice the breadcrumb on the top to realize which page you have reached:

Shipping Rate

You will need to create two conditions. The first condition ensures that only American orders get the offer. The second condition ensures that only California is charged $15 shipping rates.

Click “Add condition”:

Shipping Rate

The page now expands to show multiple fields.

For the field “Select the condition to add”, select Order address component comparison. This ensures that the shipping address is validated :

Shipping Rate

Under “ADDRESS COMPONENT”, select Country. This is to specify that the flat rate is applicable only for orders from the USA:

Shipping Rate

Under “OPERATOR”, select equals:

Shipping Rate

Under “Value”, select US as the country you seek this tax rate for:

Shipping Rate

Let’s add one more condition so that only orders from California are imposed with the $15 shipping rate. Click “Add condition” once again:

Shipping Rate

Select Order address component comparison:

Shipping Rate

Select “Administrative area (State / Province)” from the dropdown. This signifies that you are laying down the condition for a state.

Shipping Rate

Under “OPERATOR”, select equals:

Shipping Rate

Under “VALUE”, I have typed in CA. The system accepts only 2 character for this field:

Shipping Rate

The conditions have now been saved:

Shipping Rate

Okay, now you have set the flat rate to impose a $15 on all orders originating from California. But there’s still more for you to do to make this possible. Remember the original $10 shipping flat rate for all states that was configured in the earlier article? You will have to set 2 conditions for it to ensure that the $10 shipping rate isn’t applied to California anymore.

Let’s go to “Store” -> “Configuration” -> “Shipping”. Click configure component:

Shipping Rate

The first condition should reflect the country just like we did before. Select Order address component comparison:

Shipping Rate

Fill in the other fields like we did earlier:

Shipping Rate

Similarly, fill in details for California (CA):

Shipping Rate

Notice the “Negate” box has been ticked. This ensures that the $10 rate won’t be applied for orders that feature these fields – CA and USA. Here are the saved conditions for the $10 Rate Flat rate:

Shipping Rate

Let’s now add an OR group to club these conditions together. OR ensures that the conditions work together:

Shipping Rate

OR gets added to the table. Let’s drag it to the very top:

Shipping Rate

Let’s now drag the conditions towards the right so that they become a part of the OR group:

Shipping Rate

Click “Save changes”

Let’s now try checking out a product with a California shipping address. Let’s see how the bill reflects the shipping rate for deliveries in California and other states.

I am checking out my cart:

Shipping Rate

I provided a random California-based address:

Shipping Rate

Proceed to the next step. You will notice the $15 shipping rate being applied for my order:

Shipping Rate

Click forward to the final screen and you will see the $15 as part of the final bill. The functionality is working.

Shipping Rate

I’ll now perform a checkout to test whether a flat rate of $10 applies for non-California state orders:

Shipping Rate

I am using a New Mexico address:

Shipping Rate

Proceed further in the checkout process and you will notice a flat rate of $10 being added to the bill. This proves the functionality is correct:

Shipping Rate

In the final screen, you will see $10 added to the bill:

Shipping Rate

We have successfully added a flat shipping rate of $15 to California-based orders while keeping the rate $10 for all other states.

Next: Configuring FedEx For Your Drupal Store

Neerav Mehta

Neerav Mehta

Founder & CEO

Neerav Mehta is the Founder & CEO of Red Crackle. With sterling qualities, Neerav’s technological acumen is firing a generation of progressive companies on the digital path. With an undergraduate degree in Electrical Engineering from India's most prestigious institution IIT Bombay and having spent seven years developing and contributing to the launch of AMD's innovative line of computer products, Neerav founded Red Crackle where he is lauded for his dynamic and innovative genius.

View all posts

>

Read Next

10 Tips For Entrepreneurs In 2015

10 Tips For Entrepreneurs In 2015

Learn more

10 Ways To Increase Productivity At Work

10 Ways To Increase Productivity At Work

Learn more

30 best WordPress widgets for your site

30 best WordPress widgets for your site

Learn more

Let’s get you started!

Contact Us

>

RedCrackle

Explore

About Us

Services

Contact Us

Our address

5346 Gerine Blossom Dr,

San Jose, CA 95123

USA

Socials

Twitter
LinkedIn

© 2023 RedCrackle. All rights reserved.