Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
When you go into a store to buy something, you are product-centric. You are looking for a particular thing, and you don't care much about what happens behind the scene, but when you're running the store, you start looking at the bigger picture. The thing that you sell is part of an order, and that order has to be tracked in inventory. Line items are an important part of the order and inventory system. Here is how it works. An order comprises a list of products that the customer has purchased. You see those here as Product 1 and Product 2.
Those each have a price, and for each one of those, the customer can buy a number of them: the quantity. The price gets multiplied by the quantity, and you get the total amount for that product. Products can also have a negative price. For example, if you give a refund, shown here as -$5. Or they could have no price at all if it's a gift, or some other kind of giveaway. All of those items add up to a subtotal, and then you put on additional charges, such as shipping and tax. The things that are at the top of the screen here, before you add the shipping, and tax, and other additional charges, are known as line items.
The things that come after the subtotal are not line items; in this case, shipping, and tax. However, orders don't have to work exactly this way. Here is another example. We have all of our products at the top, and they are line items. But then again, we also have the shipping item as a line item. This would be the case if it was flat rate shipping, for example. We know that no matter what, it's going to cost 6 dollars. In some order systems, the amount of shipping changes depending on the total of the line items, and in that case, shipping itself is not considered a line item, because it's variable.
Tax, however, is not considered a line item in this example, because it is variable; it's a percentage based on the total amount of the line items before. You will also notice that not every line item is necessarily taxable. We have added up the amounts of the order, and that comes to $40; 10% of that is our $4 tax. We didn't charge tax on the shipping. Now let's take a look at how line items work in a Drupal Commerce store. Since we haven't set up any shipping methods yet, our order is going to be very simple. We will start by putting an item in the cart.
Let's just get us some Lip balm, and go and take a look at the cart. When we look at the cart, we see only the line items. We have created a tax rule in a previous video, but we don't see it here until we go to Checkout. Now we see our line items, and then we have our tax after it. Now, line items are unusual in Drupal Commerce in that you can't create them. They are, instead, created by modules that you install, such as the commerce shipping module I will show you later in the course. I'll show you what I mean. If we go up to Store, Configuration, and Taxes, we see that Tax Rate that we added earlier, and in fact, there is a link here to add a tax rate.
However, Drupal Commerce also keeps track of all of the line items, and if we go back up to Configure store here, and then down to Line item types. However, we don't have an add link up here. Instead, these line item types appear as you add modules, or enable modules, in your Drupal Commerce store. As Drupal Commerce matures, I expect we'll see some interesting definitions of what line items are. As always, drupalcommerce.org is where you can find out about these developments.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 74154 Viewers
80 Video lessons · 129550 Viewers
52 Video lessons · 63843 Viewers
59 Video lessons · 49621 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.