This plugin requires a version of Fabrik later than 30 Nov 2015.
It should be installed alongside the Fabrik j2store
System plugin.
Both plugins need to be published.
J2Store is a Joomla e-commerce component, whose concept is to turn any 'item' into a product. It has a plug-in system so that articles, and in this case Fabrik records, become products which you can add to the j2store cart.
The concept of this plugin is that when you save your form's data the plugin will map your Fabrik form fields to their corresponding j2Store product fields, creating the necessary information to turn your Fabrik data into a j2Store product.
The plugin equally adds 'add to cart' widgets into the front end list and details views.
There are some limitations with this plugin:
We only support product types of 'simple' or 'downloadable'
Additional product images are not yet supported.
Setting Up Your Fabrik List and Form
The first thing to do is to create a Fabrik list with the following
Elements:
- product_name (text)
- product_type (dropdown with values "simple" and "downloadable"
- enabled (yesno)
- visible (yesno)
- sku (field)
- upc (field)
- manufacturer (dropdown with the following advanced -> Eval populate code)
PHP:
$lang = JFactory::getLanguage();
$lang->load('com_j2store', JPATH_SITE . '/administrator', null, false, true);
require_once(JPATH_ADMINISTRATOR.'/components/com_j2store/helpers/select.php');
$opts = J2StoreHelperSelect::getManufacturers();
$return = array();
foreach ($opts as $id => $label)
{
$return[] = JHTML::_('select.option', $id, $label);
}
return $return;
- price (text)
- tax_profile (Database join element joined to #__j2store_taxprofiles)
- thumb_img (file upload Upload directory = "/images")
- main_img (file upload Upload directory = "/images")
- enable_shipping (yesno)
- length (field)
- width (field)
- height (field)
- weight (field)
- length_class (Database join element joined to #__j2store_lengths)
- weight_class (Database join element joined to '__j2store_weights)
- download_limit (field)
- download_expiry (field)
If you want to included files (for when the product type is downloadable) then you should add a repeating group and add the following fields to that group:
product_file_display_name
product_file_save_name
Adding the j2Store Fabrik Form plugin
We now want to add and set up the j2store form plugin. The configuration of this plugin allows us to state how each of our Fabrik form's product data corresponds to the j2store product.
Edit the form you have just created.
Go to the plugin's tab and press 'add'
From the 'do' dropdown select the 'j2store' plugin
Select "both" for "in" and "on"
We will now want to map our Fabrik fields to the plugin settings. Each textarea allows us to insert Fabrik
Placeholders. When the form is submitted these
Placeholders are replaced with your form's data.
To bring up a context menu to help you insert the correct placeholder, start by typing '{' and the any part of the element name you wish to insert. In the example below I've started with '{name' and the placeholder {products___product_name} is shown as a possible placeholder. Clicking on this option will insert it into the textarea.
Some fields should use the raw placeholder. These are those placeholder
Elements which are either database join or fileupload
Elements.
The following screen shots shows a typical set up:
Note - add to cart is generally just plain text.
As "File display name" and "File path" are in a repeat group - their full element name is slightly different to the other fields. However, you can add them in the same way, using the context menu - just start typing "{file_display" and {"file_save" to filter and select the correct placeholder.
When creating your Fabrik records - note that the "File path" value must be the full server path to the file, e.g. /var/www/html/mysite/public_html/myfile.zip
List view