One of the many useful features provided by OpenCart is "Options". In this tutorial, you'll learn how to use Options to set up different variations of the same product without actually creating different products. More specifically, you'll learn to set up configurable products in the front-end, so that the user can choose between the different variations available on the product page itself. We'll go through a detailed explanation of Options in the admin section, and we'll end up by setting up a demo of a configurable product.
Basic Understanding of Options
Have you ever run into the need for setting up multiple products with minor variations in product attributes? "Options" in OpenCart is exactly designed for that! It can help you set up different versions of the same product, as well as price variations.
Let's take a couple of real-world examples to understand this. Assume that you would like to provide different colors for the "T-Shirt" product in your store. And you also want to charge a few extra bucks for the most popular colors. You can accomplish this using the
Select option type in OpenCart. After you've set up the different colors on the admin side, the user is presented with a choice of different colors on the product details page. And yes, the user will be charged based on the color selection!
A more advanced example would be a "Graphic Tee" in which you would like to allow the user to upload an image which will be printed on the T‑shirt! In that case, you could use the
File option type. Sometimes, you'll need to take some input from the user, like "Your Name", which will be printed on a key chain. And for that, the
Text option type comes to the rescue!
So overall, Options involves some form of user input while purchasing the product. And if required, you can introduce price variations based on the user selection.
Different Types of Options
Now let's see the different types of options available in OpenCart.
Text and TextArea
This type of option is used to take some input text from the user. You could choose either
Text, which will provide a text box, or
TextArea, which provides a text area to the user for typing the required details.
As the name suggests, you can use the
File type of option in the case in which a user needs to upload a file for the product.
Date and Time
As you've probably guessed, this will ask the user to enter the date and time. There are three further different types available. The
Date & Time type allows the user to enter the date and time together.
Date allows the user to select only the date. In the same way,
Time allows the user to select only the time. This option type is useful when you would like to ask the user to choose a delivery date.
In this type of option, the user is presented with different items to choose from. There are four different types available for the user selection:
Selecttype provides a drop-down box to the user with different options.
Radiotype provides different radio buttons for each option.
Checkboxtype provides different checkboxes for each option. You could use this option when you want to provide multiple selections for the same option.
Imageis somewhat similar to the Radio option type, but a user is presented with different images to choose from, instead of just text.
So that's it as far as different option types are concerned. Enough theory, let's dive into the action!
Set Up a Configurable Product
In this section, we'll set up a configurable product from the admin side. First of all, create a sample product named
Graphic T-Shirt from the back-end of the admin side. You just need to enter the basic product information and choose the category. The details you enter into the product are not important, as we'll only concentrate on the Option tab available in the product edit interface. I'll get back to this at the end of this section.
We assume that our T-shirt product is configurable in a way that one can choose color, enter some slogan text, and upload the image which will be printed on the T‑shirt. Let's see how to accomplish this using the Options.
Add a "Color" Option
Head over to the back-end of OpenCart. Go to Catalog > Options. It'll list out the existing options in the store. Click on the Insert button to create a new Color option.
As shown in the above screenshot, fill in the values. We've entered Color in the Option Name field. It'll be displayed as a title. The next field is Type, for which we've chosen Select, since we want to provide a drop-down for the color. Sort Order is just used to display the different options in a certain order. For now, we'll enter 1 in that field.
Now that we've added basic information, you need to add option values. Obviously, in this case they'll be different colors. Click on the Add Option Value button to add values for the Color option. In the screenshot, it shows we've entered Red in the Option Value Name and again the Sort Order is 1. Let's ignore the Image field for the sake of simplicity now. In the same way add two more colors, Blue and Green.
Add a "Slogan Text" Option
Now let's go ahead and set up the "Slogan Text" option. Again, click on the Insert button on the Catalog > Options page.
As you can see, we've entered
Slogan Text in the Option Name field. And the Type is set to Text. Sort Order is set to 2.
Add a "T-shirt Image" Option
The last one is "T-Shirt Image", so let's go ahead and add that. Click on the Insert button on the Catalog > Options page.
As you can see, we've entered
T-Shirt Image in the Option Name field. And the Type is set to File. Sort Order is set to 3.
We've done with setting up "Options" stuff. Now, we need to associate our options with the product so that it can be displayed in the front-end. I assume that you've created the sample product named "Graphic T-Shirt" as I mentioned earlier. If you haven't done so yet, just do that before you proceed to the next section!
Assign Options to the Product
Let's edit the "Graphic T-Shirt" product right away to add the options. Go to the Option tab in the product editing interface. On the left-hand side, you'll see the text box, which is auto-complete. If you type "Color", it will show you the "Color" option we added earlier.
Clicking on the Color option in the auto-complete text box will add a new row for color as shown in the screenshot. In that section, you can add different option values which you would like to display for the color option in the front-end. Click on Add Option Value to add different color options.
As you can see, I've added three options:
Red. The other important thing is the Price fields. For each option, you could vary the prices using the +/- sign by the entered amount. Finally, you must specify the Quantity for each type of option, otherwise it won't get displayed in the front-end. So now we've finished with the "Color" option.
Now let's assign the "Slogan Text" in a similar way. We don't need any configuration for this field, as it'll be a simple text box.
Finally, lets assign the "T-Shirt Image". We don't need any configuration for this field either, because it'll be a simple file upload field.
After assigning all three options to the product, save it. And believe me, you're done!
Test Ride Front-End
Let's straight away visit the product detail page in the front-end to see the outcome!
Looks great, doesn't it? So you've just set up a configurable T-shirt product which allows the user to choose the color, enter the text for the slogan, and upload an image. You've probably noticed that with each different color it charges extra money, as per our configuration in the back-end!
So now you should feel comfortable with Options and creating configurable products in OpenCart. So that's it for today! I would love to hear your feedback.
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post