Project

General

Profile

Product Plugins » History » Version 5

Ondra Spilka, 03/01/2012 02:26 PM

1 1 Patrick Kohl
h1. Product Plugins
2
3
h2. for user  
4
5
The product plugin is installed as a standard joomla plugin
6
7
To see it you must publish it in joomla extention after installation.
8
9 2 Patrick Kohl
After you do that, you can find it in the customfields on edit Choice : 
10
*Custom Field Type* : plugin
11 1 Patrick Kohl
12
After choicing the plugin you can setup the defaut value depending on your plugin.
13
14
h2. for developper.
15
16
h3. Language files :
17
18
XML install file must use the name in this form plg_vmcustom_YOURPLUGINNAME
19
20
EG. for textinput french and english
21
    <languages>
22
        <language tag="en-GB">en-GB.plg_vmcustom_textinput.ini</language>
23
        <language tag="fr-FR">fr-FR.plg_vmcustom_textinput.ini</language>
24
    </languages>
25
26
the constructor include directly the language file to simplify using JTEXT
27
28
Try to always use this convention name in the ini files :
29
VMCUSTOM_YOURPLUGINNAME_STRING="my string in english"
30
31
EG. for texinput plugin , string : size
32
VMCUSTOM_TEXTINPUT_INPUT_SIZE="Size of input"
33
34
h3. Write your plugin :
35
36 2 Patrick Kohl
_List of function to write in your plugin_
37
38
*onProductEdit($field,$param,$row, $product_id);*
39
40
	render the plugin with param  to display on product edit customfields TAB
41
	(called by customfields inputTypePlugin)
42
43
*onDisplayProductFE( $field, $param, $product, $idx);*
44
45
	display the plugin on product FE
46
	return $html
47
48
*onViewCartModule( $product,$custom_param,$productCustom, $row);*
49
	display the product plugin on cart module
50
	return $html
51
	
52
*onViewCart($product, $param,$productCustom, $row);*
53
	display the product plugin on cart
54
	return $html
55
	
56
*onViewCartOrder($product, $param,$productCustom, $row)*
57
	handel $param before adding it in the order
58
	return $param;
59
	
60
	
61
*onViewOrderFE($item, $param,$productCustom, $row);*
62
	display the plugin in order for customers
63
	$item is the order item line
64
	Eg. to Get the statut ( $item->order_status == 'S'  )
65
	
66
*onViewOrderBE($item, $param,$productCustom, $row);*
67
	display the plugin in order for vendor
68
	$item is the order item line
69
70
	
71
*modifyPrice( $product, $field,$param,$selected )*
72
	overide the defaut price modifation by plugin
73
	you have to rewrite it in your plugin to do other calculations
74
	
75
	_you must return $field->custom_price at end to include your changes or the price varaint is set to 0;_
76 1 Patrick Kohl
77 5 Ondra Spilka
*plgVmGetProductStockToUpdateByCustom(&$product,$param, $productCustom)*
78
	Gets called after cart item is stored to database. 
79
        Developer can read product and parameters and eventually do own modifications.
80
        $param contains plugin values(if applicable) so developer can read those values
81
        Necessary check have to be performed...here check against field is not possible
82
        so eg. at least such a vaidation have to be done:
83
<pre>
84
		if ( !empty($param['vmcalendar']) && is_array($param['vmcalendar']))
85
		{
86
			$rf = $param['vmcalendar']['reservation_from'];
87
			$rt = $param['vmcalendar']['reservation_to'];
88
                        ....
89
90
</pre>
91
92
93 3 Patrick Kohl
h3. Use of plugin XML parameters :
94
95
*XML Exemple for textinput*
96
<pre>
97
<?xml version="1.0" encoding="UTF-8" ?>
98
<install version="1.5" type="plugin" group="vmcustom" >	
99
    <name>VMCustom - textinput</name>
100
    <creationDate>June 2011</creationDate>
101
    <author>The VirtueMart Development Team</author>
102
    <authorUrl>http://www.virtuemart.net</authorUrl>
103
    <copyright>Copyright (C) 2004-2011 Virtuemart Team. All rights reserved.</copyright>
104
    <license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
105
    <version>1.9.8</version>
106
    <description>text input plugin for product</description>
107
    <languages>
108
        <language tag="en-GB">en-GB.plg_vmcustom_textinput.ini</language>
109
        <language tag="fr-FR">fr-FR.plg_vmcustom_textinput.ini</language>
110
    </languages>
111
    <files>
112
        <filename plugin="textinput">textinput.php</filename>
113
    </files>
114
    <params addpath="/administrator/components/com_virtuemart/elements">
115
        <param type="vmjpluginwarning" />
116
        <param name="custom_name" type="text" size="20"  default="COM_VIRTUEMART_COMMENT" label="VMCUSTOM_NAME_INFO" description="VMCUSTOM_NAME_INFO_DESC" />
117
        <param name="custom_size" type="text"  size="5"  default="10" label="VMCUSTOM_TEXTINPUT_SIZE" description="VMCUSTOM_TEXTINPUT_SIZE_DESC" />
118
        <param name="custom_price_by_letter" type="list"  default="0" label="VMCUSTOM_PRICE_BY_LETTER" description="VMCUSTOM_PRICE_BY_LETTER_DESC" >
119
			<option value="0">No</option>
120
			<option value="1">Yes</option>
121
		</param>		
122
    </params>
123
</install>
124
</pre>
125 1 Patrick Kohl
126 5 Ondra Spilka
*You can see somes differences with joomla standard XML files :*
127 3 Patrick Kohl
128
<pre>
129
<install version="1.5" type="plugin" group="vmcustom" >	
130
</pre>
131 4 Patrick Kohl
132 3 Patrick Kohl
inform joomla the plugin is a "vmcustom" plugin(product customfield plugin)
133
134
135
<pre>
136
    <params addpath="/administrator/components/com_virtuemart/elements">
137
</pre>
138 4 Patrick Kohl
139 3 Patrick Kohl
Overide the joomla system by virtuemart 2 to enchance it.
140
_Always add this or your plugin have chance to not work_
141
142
143 4 Patrick Kohl
<pre>
144 3 Patrick Kohl
        <param type="vmjpluginwarning" />
145
</pre>
146 1 Patrick Kohl
147
inform that the parameters are saved by virtuemart2 for each plugin variant.
148 4 Patrick Kohl
149
h3. transmited parameters by functions
150
151
*$product_id*
152
is the selected product_id
153 1 Patrick Kohl
154
*$product*
155 4 Patrick Kohl
is the selected product
156
157 5 Ondra Spilka
*$param*
158
 are the plugin parameters
159 4 Patrick Kohl
160
*$productCustom ,$field*
161
 are the product customfield attributes
162
163
*$selected,$row or $idx*
164
 is the parameter to find or write the right "index/row"
165
166
167
TODO : add more details for parameters
168
169
_See texinput plugin for eg._