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

<

Blog post

Adding fields and metadata to product

Neerav Mehta

Founder & CEO

This is tutorial #3 in the Drupal Commerce tutorial series. In the previous article, we showed you how to add multiple SKUs for a product, one for each product variation. If you haven't read it, please go and read it now, or get the free eBook on Drupal Commerce 101 from the right sidebar (below the content if you are viewing in mobile).

We used the Inline Entity Form module to add products and product displays to your online store. The screenshot below shows how our product page looked at the end of the previous article:

Adding fields and metadata to product

The purpose of this article is to add fields generally associated with products in an online store. We will add a Description and Image for the flashlight products. These fields can be added by accessing “Store” -> “Products” -> “PRODUCT TYPES”. We will explore the steps in detail in this article. We will also be adding comments and ratings for the products. This is a screenshot of what we are seeking to achieve:

Adding fields and metadata to product

To get started, you will have to download and unzip the following modules in sites/all/modules folder:

Let’s enable these modules. Click “Modules” in the menu and search for “Fivestar” and “Voting API”. Enable them:

Adding fields and metadata to product

Let's now configure the product type to add new fields.

Click “Store” on the top-level menu. Then click “Products”:

Adding fields and metadata to product

Click "PRODUCT TYPES" on the top-right corner:

Adding fields and metadata to product

In the new page, you have the option to edit the existing product type or create a new one. In the earlier article, we used the basic product type provided by Drupal. We will continue using the default product type here. Click “manage fields”:

Adding fields and metadata to product

In the new page, you will be able to view the existing fields. They are “Product SKU”, “Title”, “Price” and “Status”:

Adding fields and metadata to product

Let us add “Description” and “Image” fields for each product. Type in “Description” under Add new field. Choose “Long text” under FIELD TYPE. "Text area (multiple rows)" will be automatically selected under WIDGET. Click "Save".

Adding fields and metadata to product

You will get the following screen. Click “Save field settings”.

Adding fields and metadata to product

You can add the Image field by using “Add new field” or “Add existing field”. I am going to use the existing field:

Adding fields and metadata to product

Click "Save" at the bottom of the screen. Rearrange the order of the fields to reflect the priority in which you want these fields to appear. Click and drag the ‘plus’ sign to the left of each field to arrange according to your priority. To demonstrate, I have taken the newly created fields above the Status field.

Adding fields and metadata to product

These newly added fields will now be an integral part of the product display content type added by you. Let’s add these fields to the display. Go to the homepage and click "Edit" for the product added by you:

Adding fields and metadata to product

Click "Edit" for 3-LED Flashlight:

Adding fields and metadata to product

Add a description and image for 3-LED Flashlight. Click "Update product" as shown in the screenshot below:

Adding fields and metadata to product

Add similar descriptions and images for other products in your inventory. In my case, the products are 6-LED Flashlight and 9-LED Flashlight. Further below, click the "Comment settings" tab on the left. Ensure that "Open" is selected so that users can add their comments describing their experiences while buying the product. Click "Save" at the bottom of the screen:

Adding fields and metadata to product

I am going to configure the comments to ensure anonymous users can add their feedback as well. On the top-level menu, click "People":

Adding fields and metadata to product

On the top-right, click "PERMISSIONS":

Adding fields and metadata to product

Search for "Comment". Tick all the boxes that come under it for "ANONYMOUS USER":

Adding fields and metadata to product

Search for "Fivestar". Tick the box that comes under it for "ANONYMOUS USER" and “AUTHENTICATED USER”:

Adding fields and metadata to product

Let’s now configure the content type associated with displaying the Flashlight products. In my case, the content type is “Inline Form Flashlight Display”. Click "Structure" on the top-level menu:

Adding fields and metadata to product

Click "manage fields" next to "Inline Form Flashlight Display":

Adding fields and metadata to product

On the top-right, click “COMMENT FIELDS”:

Adding fields and metadata to product

Create a new field with the "FIELD TYPE" value as "Fivestar Rating". Provide a name for your rating field. I have used "Rate this product". For the "WIDGET" dropdown, choose the value "Stars (rated while editing):

Adding fields and metadata to product

Save your settings and you will be taken to a new screen as shown in the screen below:

Adding fields and metadata to product

Fill in the fields. I have ticked the box against “Required field”. This means that it is mandatory to give a rating.

In the “Number of stars” dropdown, I have used the default value.

The most important field on this page is the “Voting target” dropdown. It ensures that the rating field is displayed within the comment section.

Choose “Parent Node” as a value for this field.

Save your settings. In the main page, drag the rating field above “Subject”:

Adding fields and metadata to product

Let’s now visit a product on the site. This is how it looks:

Adding fields and metadata to product

You will notice that the new fields have been added. Also notice the rating and comment box at the bottom. I am going to type in a comment and provide a rating. First, I will log off as admin:

Adding fields and metadata to product

Here I am typing in a comment and choosing a rating as an anonymous user:

Adding fields and metadata to product

Click “Save” and this is how the product page will look:

Adding fields and metadata to product

You have now configured your product’s display page to showcase more fields.

Next article: Managing inventory

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.