- View Offline
- Surveying the store-building process
- Installing Drupal Commerce using Commerce Kickstart
- Accepting PayPal payments
- Processing orders
- Understanding rules and line items
- Listing and importing products
- Managing inventory, orders, and customer profiles
- Streamlining the checkout process
- Launching a store
- Offering product discounts
- Analyzing site traffic with Google Analytics
Skill Level Intermediate
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.
Sign up for a Premium Membership to download courses for Internet-free viewing.
Watch offline with your iOS, Android, or desktop app.Start Your Free Trial
After signing up, download the course here or from the iOS/Android App.