Custom fields – customizing products with versions and charging different prices for them
Often you will have a product available in more than one version. What about a black or white iPad? Or the download, DVD or Blu-ray version of VirtueMart the Movie. Of course it would be easy to implement a new product for each version, but that is not always what you want. If it makes sense in your version dilemma to have the versions selectable on one product page, then this is the recipe for you. And VirtueMart will handle the stock control for each version separately.
Getting ready
Write down the different versions you will create and make a note of the products you intend to apply them to. Fire up VirtueMart and read on.
How to do it...
We will do this over two stages much like the other custom field recipes:
- First we create the custom field itself
- Then we will add the custom field to a product
Steps for creating the custom field are as follows:
- In the Products menu click on the Custom Fields option. Now choose New from the row of buttons near the top.
- In the Custom Field type: select Plug-ins as shown in the following screenshot:
- Now in the Title field enter
Choose media type
or something similar that fits your goals. And in the Cart Attribute box be sure to select the Yes radio button. - When we selected the Plug-ins type we got an extra drop-down box to play with. In the Select a plug-in field choose Stockable variants. When you do a whole bunch of extra options there is a pop up, as shown in the following screenshot:
- In Option name enter
Type
and on three separate lines enterDownload
,DVD
,Blu-ray
, or whatever your options will be. Click on Save.
Steps for adding the custom field to a product are as follows:
- Now select Products from the Products menu and click on the product you want to add the custom field to. Click on the Custom Fields tab.
- In the drop-down box in the Custom field type section choose your new custom field that we just made. The page will look like the following screenshot:
Now we see the following screenshot:
What is about to happen is that we will be configuring a child product. That is a product related to another product, in this case the VirtueMart the Movie product. VirtueMart will then magically add a child product for each option in our custom field and we will further configure each option/child as well. All from the preceding screenshot by using the following steps:
- Enter the Product SKU for the first version of your product. Then enter a product name. The products used in this chapter are clearly homebrew, here it is,
VirtueMart the Movie - Download
. - Also enter a stock level. You can leave the other fields blank. Just click on the New button. Now look at what has happened. You can see we have the option to add another version as well as to further configure the initial one.
- You can see that here
-1
is typed for Additional charge and Download is selected in the Type dropdown. This means that the first option available to our customers will be the Download option and it will cost 1.0 of our native currency less than the main product, which is its parent, as shown in the following screenshot:The following picture shows the area just following the preceding screenshot where you can create another version in the same way.
- Enter the details for the next version and click on New. Configure the new version, perhaps like the one we have in the following screenshot.
- I selected DVD for the Type dropdown and 0 for the Additional charge. This means the DVD version of the child product is the same price as the parent product. It looks like the following screenshot:
- Just the Blu-ray left. So enter an SKU and a stock level as before, click on New, configure the version, and click on Save.
- I added an extra 5 currency units to my Blu-ray version. This seems fair for such a high quality and high definition product.
- Now click on Save and we will see what has happened.
How it works...
Select the Products link from the Products menu and we will see what has been going on behind the scenes.
You will see that VirtueMart has created three child products for us and that they are children to the VirtueMart the Movie product.
Now if we look at our shop front and go to the details page of the product we can see the product versions dropdown in action. Notice how the price changes when we select the different versions, as shown in the following screenshot:
There's more...
I found this process quite buggy. Not unreasonably so, but enough to make it slightly more challenging than it should have been.
Note
The custom fields section of VM has been completely rewritten for VM2.2, which will soon be available in the VM2.1 series of betas. So there may be changes to the recipe shown here.
On the creating the custom field section, when saving, if there are any fields the page doesn't like, it will clear all the fields. Make sure that all the options discussed are reselected, especially the Cart Attribute set to Yes. Failing to do this will make everything appear to be going according to plan when it isn't.
If things don't seem to work out for you on the 'adding the custom field to the product' part, try saving the page to give the JavaScript a kick-start.
If you get in a mess and find you have loads of child products and don't know what is going on (obviously this didn't happen to me), then delete the custom field (to remove it from the product) then delete the child products (See Chapter 5, Going Live for how to do this if you're, not sure). Now start a fresh.