Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Understanding rules

From: Create Your First Online Store with Drupal Commerce

Video: Understanding rules

Part of Drupal Commerce Kickstart is a Drupal Module called Rules, which is available separately at drupal.org/project/rules. A lot of Drupal Commerce's functioning depends on the Rules module. For example, it comes with a rule that sends the customer an e-mail message when checkout is completed. You'll see rules a lot as we go through the course. I want to just take a moment now to show you how the module works in general. Now, unless you're experienced with Drupal administration, you'll mostly only deal with rules as you configure your store.

Understanding rules

Part of Drupal Commerce Kickstart is a Drupal Module called Rules, which is available separately at drupal.org/project/rules. A lot of Drupal Commerce's functioning depends on the Rules module. For example, it comes with a rule that sends the customer an e-mail message when checkout is completed. You'll see rules a lot as we go through the course. I want to just take a moment now to show you how the module works in general. Now, unless you're experienced with Drupal administration, you'll mostly only deal with rules as you configure your store.

They show up in several places. One of them is related to something we already started playing with; taxes, and we can see that by going up to Store, Configuration, and Taxes. Here's our Flat 8% tax we created earlier. Let's click edit, and take a closer look at it. This is fairly simple. You get to define the rate, and what type of tax it is, as we described. But if we go back a screen, and then click configure component, we see some of the inner workings, which are a little more complicated. This is where you can add conditions.

Let's take a common one. Let's say that our store is in Ohio, and U.S. tax laws say that we only have to collect state sales taxes for sales that are shipped to addresses within that state. So we only want to apply the sales tax when an order is being sent to an address that's inside Ohio. If we look here, we see that there's a Condition section. This is where we're going to add the condition to check to see if it's in Ohio. Most rules also have a section up here; Events, and we'll get to that a little bit later. And as I said earlier in the course, actions defines exactly what happens when the conditions are met.

For now, we'll just click Add condition, and the condition we are going to add will be an address component comparison. This Data selector area is quite complicated; there is a few different ways that you can do this. You can type things in, you can choose them from a list, and if you click and open this Data Selectors, it shows you all of the different options. If you want more information about how all of this works, I would suggest that you take a look at the Rules documentation, which again, you can get to at drupal.org/project/rules. But going down, let's take a look at what our values are. We are going to take the billing information, it will be the state or province, and the value has to equal Ohio, and then save.

Now if we look again, we can see it describes exactly what we're going for. Now, let's take a look and see if it worked. I'll close out this overlay, and we already have an item in the shopping cart which I added previously. Take a look at the cart. Okay, there it is, $8, and let's check out. Now at this point, we're going to add our address in the billing Information. So Tom Geller, Address 1, let's just say, 1 Main Street, Oberlin, Ohio, 44074. Now, if I did this correctly, I should be charged tax.

Let's continue and see, and indeed I am. There is our 8% sales tax. Let's go back and change that address to something in New York, in which case it shouldn't actually charge us the tax. So I'll go back and let's say 1 Spencer Street, Mount Kisco, New York, 10549, and continue. Indeed, it worked; we're not charged tax. Now I want to go back a little, and show you some of the complexities of rules.

We won't be able to go into the details, because there really are a lot of them, but I am hoping that a little more exposure will help you debug rules that don't do exactly what you expect. To show you that, I'll go up to Store, Configuration, and Product pricing rules, and let's take a look at our sales tax calculation here. Now you see that little extra bit at the top, the Events section, which I mentioned earlier. Here you can change when an event occurs; when a rule is triggered, so to speak.

Let's take a look at that. One example that's sort of outside of the whole world of taxes is this After adding a product to the cart. You could, for example, ask the person, would you like this to be gift-wrapped? Pop up a window, or something like that, each time that they add a product to the cart. Similarly, you could change how and when Drupal Commerce calculates shipping charges, and anything else that happens on the site. To see all the rules at once, click Configuration, and then go down and click Rules, and there's your introduction to rules.

If you want to dive deeper, check out the project's homepage at drupal.org/project/rules. To really understand them, scroll down, and click Read documentation. That leads to this URL: drupal.org/node/298476. It happens that Rules has a very active development community, and this project page also has links to a FAQ -- a Frequently Asked Questions page -- and even to a discussion group. Chances are, you won't need this kind of help when you first set up your store, but it is good to have, and it's a great example of the strength of the open-source Drupal community.

Show transcript

This video is part of

Image for Create Your First Online Store with Drupal Commerce
Create Your First Online Store with Drupal Commerce

35 video lessons · 10861 viewers

Tom Geller
Author

 
Expand all | Collapse all
  1. 16m 44s
    1. Welcome
      54s
    2. Previewing the finished project
      4m 10s
    3. Surveying the store-building process
      4m 29s
    4. Using the exercise files
      7m 11s
  2. 12m 12s
    1. Installing Drupal Commerce using Commerce Kickstart
      6m 5s
    2. Configuring your store's basic information
      6m 7s
  3. 31m 29s
    1. Accepting PayPal payments
      5m 9s
    2. Setting up individual products
      3m 17s
    3. Displaying products
      6m 30s
    4. Categorizing products
      5m 31s
    5. Adding simple taxes
      4m 39s
    6. Seeing your site from the customer's viewpoint
      3m 26s
    7. Processing orders
      2m 57s
  4. 17m 39s
    1. Understanding products and other entities
      3m 3s
    2. Understanding line items
      3m 16s
    3. Understanding rules
      5m 10s
    4. Integrating your store into a Drupal site
      6m 10s
  5. 29m 46s
    1. Adding product variations
      7m 2s
    2. Managing product variations
      3m 50s
    3. Importing simple products
      10m 11s
    4. Importing complicated products
      8m 43s
  6. 29m 52s
    1. Shipping products
      4m 50s
    2. Managing inventory
      4m 30s
    3. Managing orders
      5m 39s
    4. Managing customer profiles
      4m 55s
    5. Using Views to gain better oversight
      5m 0s
    6. Accepting other payment methods
      4m 58s
  7. 24m 52s
    1. Changing your store's look
      6m 24s
    2. Streamlining the checkout process
      5m 19s
    3. Launching your store
      13m 9s
  8. 29m 25s
    1. Offering product discounts
      8m 56s
    2. Gaining insight from Google Analytics
      5m 45s
    3. Making your site more visible to search engines (SEO)
      5m 52s
    4. Encouraging customer buzz
      8m 52s
  9. 56s
    1. Goodbye
      56s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Create Your First Online Store with Drupal Commerce .

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.