The Rawforms customfield plugin allows to use custom html and php snippet to display forms allowing the shopper to personalize his product and allows the store owner to provide customized prices. All of that just by using few lines of simply readable code.
INSTALLATION
- Install the plugin with the Joomla Extension Manager
- Browse Joomla Extensions > Manage, filter by name Rawform or filter by type: vmcustom
- Enable the Rawform plugin
HOW TO USE
- Browse VirtueMart administration, choose the menu Product > Custom Fields
- Create new customfields, select type plugin, at the bottom select Rawform, name it e.g. my raw form
- Enable option Cart Attribute
- Enable option Cart Input
- In Additional Parameters insert internal comment for your identification convenience (optional)
- Select snippet files to use for each view: productdetails, cart, order, data preparation
- Browse containing template files containing form snippets, physical path on server is: Your Joomla Root\plugins\vmcustom\istraxx_rawforms\tmp\
We recommend to either clone the files or create template overwrite (how to overwrite plugins: https://docs.virtuemart.net/tutorials/templating-layouts/101-how-to-overwrite-plugins.html) - Browse VirtueMart administration product details where you like to add the form. In product details browse to the tab customfields and add the Rawform by selecting my raw form, set the customfield price and save the product entry.
HOW TO MODIFY CODE SNIPPETS
product.php - display form in product details, uses html <input>, you can modify according to html standards (http://www.w3schools.com/html/html_form_input_types.asp)
(...)
<input class=""
type="text" value=""
size="10"
name=""
> (...)
prepcart.php - form calculation, if the form is filled by shopper the following snippet will add x=(1.0 x customfield_price)
to the product price:
(...)
if (!empty($selected['comment'])) {
if ($customfield->custom_price_by_letter ==1) {
$charcount = strlen (html_entity_decode ($selected['comment']));
} else {
$charcount = 1.0;
}
$modificatorSum += $charcount * $customfield->customfield_price;
} (...)
To change the price e.g. to be added for each letter, set statement $customfield->custom_price_by_letter = 1;
between first and second line of this snippet.
The cart.php and order.php do work in the same way, please note: neither change the top code block, nor change the Javascript if you do not know what you do!
You can define different snippet files to be used for each rawform custom prototype.
See some samples here:
FAQ
Q: Can I use template overrides to modify rawforms?
A: Yes, same way as you know from Joomla and VM https://docs.virtuemart.net/tutorials/templating-layouts/101-how-to-overwrite-plugins.html
Q: Actually, how do I modify snippet files?
A: Use your file browser extension, alternatively dependant on your host ssh or sftp \plugins\vmcustom\istraxx_rawforms\tmp\ (product.php, prepcart.php, cart.php, order.php)
Q: Can I have more then one custom proto per product?
A: No, currently single raw form is allowed, use single <form> and multiple <input> in rawfield. Contact us for custom solution.
Q: Somehow I broke my snippets, how to restore original files?
A: No problem at all, as always: update of the plugin resets the plugin files.