Building E-commerce Sites with VirtueMart Cookbook
上QQ阅读APP看书,第一时间看更新

Custom fields – adding customizable product text and charging per letter

Do you want to add custom or customer designed products to your store? What about a greeting in a card to make it personal or a player name on a football shirt? Here is how to do it with custom fields in VirtueMart.

Getting ready

Log in to Joomla! admin and select the VirtueMart component. The example used here is the option to add a custom message on the DVD when giving Joomla! the Movie to a close friend. Not only will they thank you for a life altering movie, but they will also feel like the gift is extra special because of the personal touch.

How to do it...

We will do this in two parts. First creating the custom field and then adding the field to a product.

Creating the custom field:

  1. Select Custom Fields from the Products menu and then click on New. For Custom Field Type select Plugins as shown in the following screenshot:
  2. For Cart Attribute choose Yes as shown in the following screenshot:
  3. In the Description box type Enter your personal message. For Plugin Type choose Customer Text Input from the dropdown. You will now see the following screenshot:
  4. Now in the new fields that have opened up choose Price per letter from the dropdown and in the Title field delete what is in there by default and type Type here.

Adding the custom field to a product:

  1. Click on the Products link in the Products menu and select the product you want to add the chargeable customizable text to.
  2. Click straight on the Product Fields tab. Scroll down and from the dropdown selector choose Type here or whatever you called the custom field as shown in the following screenshot:

    Nearly done. You can alter the maximum size of the message by entering a value in the Size of input field. The only thing you must do is enter a number for the cost per letter. In our example you can see we entered 1.0 which will be 1 of whatever your default currency. If your product is not as prestigious as mine you might like to reduce the cost per letter slightly.

  3. Click on Save and look at the product details page in your shop.

How it works...

Notice that as you type into the message box, the product price automatically increases. And whatever the final price is, when you click on Add to cart, that is what is added. If you ordered the product the message will be part of the invoice and product description, enabling us to make sure we prepare the product correctly before shipping, as shown in the following screenshot: