In this chapter we will look at how to add sales tax to our products. This chapter will cover US-style taxes, where the tax is listed separately and rounded up for each line item. The next chapter will cover European-style VAT taxes. We'll also look at how to make the application of taxes conditional with Rules, since you don't always want the same tax rate applied to all items.
If you need a refresher on using the Rules module, check out the Learning the Rules framework series.
Now that we've reviewed how taxes work with the US-style sales tax, we'll continue on by seeing how to set our store up with a European-style VAT (Value-Added Tax). VAT is added to the unit price of a product, instead of on the line item on the order form. We'll dive into our Tax Type to explain the differences and then add VAT to our store, and also see how to have the site calculate the correct product price for a given VAT to give us a nice, even unit price for our products.
Drupal Commerce Basics
CourseIn this Drupal Commerce series, Ryan Szrama takes you through the process of creating your own Drupal e-commerce site using Drupal Commerce for Drupal 7. The series starts by getting the basics installed with the Commerce Kickstart project, and then works through working with products, taxes, discounts, checkout, and general configuration of our store.
We kick off the Commerce Basics series with a look at the LB Robotics store site that we will be building. Ryan gives a quick tour of the site and discusses the main topics we will be focusing on, like products, taxes, discounts, checkout, and general configuration of our store. Drupal Commerce relies heavily on the Views and Rules modules for many of its features, which allow you a lot of customization. If you need a refresher on these two modules, you can watch these other Drupalize.Me series:
Now that we have our base site installed and ready, we'll begin setting up our store by removing the example products that Commerce Kickstart created for us, and adding our own products to the store. We also discuss the difference between Products and Product displays.
To get started with our new Drupal Commerce store, we are installing Drupal using the Commerce Kickstart installation profile. Commerce Kickstart provides you with Drupal core, along with a number of modules that all Commerce sites will need to get up and running. Using the installation profile makes your life a lot easier since you have everything you need in one package and the Drupal installer will make sure that you don't hit annoying PHP timeouts when trying to enable all those modules at the same time. It also installs a few sample products and handles some basic configuration.
Now that we have created our products we'll dive into the Product display content type so that we can display our products to our users. In this instance we'll start out be re-using the nodes created by Commerce Kickstart, then we create two new displays for our remaining items. We finish up by rearranging the fields on the content type using Drupal 7's manage display configuration.
In our latest sprint -- Sparkleworks -- we sprinkled some magic pony dust (and also wrote a little code) to make more improvements to the Drupalize.Me site. The two main improvements we made for this release have been popular member requests; we've added a listing of your entire video history, and we've added newest and most popular video lists. Today we also have a new video for our Wednesday release day, Tips for writing secure code.
When writing code for the web it is very important that you pay attention to security. Drupal provides many tools to help you out and in this presentation we'll look at what those are and how to make sure you use them properly.
Additional resources
To round out our local development web server videos, we've added a companion video to the recent Installing a web server on Ubuntu. In Ubuntu web server configuration we learn how to configure the various pieces of our local development web server. We'll get clean URLs working by enabling the Apache rewrite module, and increase various settings for MySQL and PHP.
Following on last week's videos about setting up local development web servers on Windows and Mac, we also have one for Ubuntu: Installing a web server on Ubuntu. This video is not explaining how to set up a big, beefy web server where you would host your real website. This video is just like the Mac and Windows ones, in that it helps you get your own personal web server on your desktop or laptop, to use for development and playing around with things.
Ever peer at the laptop next to you while flying cross county and wonder how someone can work on developing their website when there is no Internet at 35,000 feet? They are developing it locally! All personal computers can be turned into personal web servers so that you can develop a website on your machine before pushing the code into a production environment. In this set of videos, Addison Berry walks you through how to:
This video walks through some of the most common and important server configurations for running a local development server on WAMP. This will show you how to enable the Apache rewrite_module through the WampServer graphical user interface, and where the http.conf configuration file is located. It also walks through the process of creating aliased folders so that you can organize your files in your directory structure and still have it available in the localhost via your browser. The video also shows how to change the max_allowed_packet from 1M to 2M via the my.ini file, and how to up the memory limit from 128M to 256M via the php.ini file stored in the bin folder within the Apache version folder.
To learn how to install WampServer, see the Installing Wampserver tutorial.
Additional resources
More information on Development Environments
This video describes a number of the most important configuration files within MAMP that are commonly edited in order to run a web application like Drupal locally. There's a brief tour of the http.conf file, and then walks through the process of upping the max_allowed_packet limit from 1M to 2M within the my.cnf, which was a renamed copy of the my-large.cnf file. It's also a good idea to turn off binary logging on your local development by commenting out log-bin and binlog_format lines within this my.cnf file. Addi then shows you how to raise the PHP memory unit from 32M to 256 by opening the php.ini file and changing the memory_limit value. Finally, she shows you how to use MAMP's version of PHP and MySQL from the commandline by editing your .bash_profile and adding a number of paths to your default PATH. Note: The configuration files may have moved between versions of MAMP. You should check for where the MySQL cnf files are for your specific version of MAMP. A quick Google search can probably get you set in the right direction.
To learn how to install MAMP, see the Installing MAMP Server tutorial.
Additional resources
More information on Development Environments
This video shows you how to download and do the initial setup of MAMP, which is Apache, MySQL and PHP for Macintosh. It shows some basic configuration tweaks to change the port from 8888 to the default of 80 so that you can just visit the localhost in the browser and get your Drupal installation to appear. It also provides a general orientation to MAMP, and some other initial configuration setting changes.
Next up: MAMP Server Configuration
Additional resources
More information on Development Environments
This video walks through the process of downloading and doing the initial configuration of WampServer, which is Apache, MySQL and PHP for Windows. It shows how to turn it on and off, as well as how to get files to show up from the localhost server.
Next up: WampServer Configuration.
Notes:
If after installing WAMP you get a 404 error, make sure the server is actually running. Navigate to wampserver > apache > service > install service... opens prompt, hit enter... wampserver icon turns green.
Additional resources
More information on Development Environments
This screencast covers the following topics:
- Manual import/export of Page manager settings.
- Import/export using Features.
- Some words about the custom rulesets module.
- Some words about the custom content panes module.
- Some words about the stylizer module.
- Some words (but not enough!) about mini panels.
- Some words about Panels everywhere.
- Some words and a quick demonstration of Panels in-place editor.
This screencast covers the following topics:
- Rearranging the node edit form with Panels.
- Some words about how the render arrays in Drupal 7 makes this possible.
The Views Context
FreeThis screencast covers the following topics:
- Creating a Context display type in Views.
- Placing individual View rows in your custom page.
- Displaying other View render elements in your custom page (such as the pager or header).
- Using the View context to load further contextual object.
This screencast covers the following topics:
- Adding new contextual objects with manual selection.
- Adding new contextual objects with relationships.
- Chaining contextual objects, with the example of loading a node term, and then loading the term top level parent (or not).