Project

General

Profile

Product Plugins » History » Version 6

Ondra Spilka, 03/01/2012 02:27 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
78 3 Patrick Kohl
h3. Use of plugin XML parameters :
79
80
*XML Exemple for textinput*
81
<pre>
82
<?xml version="1.0" encoding="UTF-8" ?>
83
<install version="1.5" type="plugin" group="vmcustom" >	
84
    <name>VMCustom - textinput</name>
85
    <creationDate>June 2011</creationDate>
86
    <author>The VirtueMart Development Team</author>
87
    <authorUrl>http://www.virtuemart.net</authorUrl>
88
    <copyright>Copyright (C) 2004-2011 Virtuemart Team. All rights reserved.</copyright>
89
    <license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
90
    <version>1.9.8</version>
91
    <description>text input plugin for product</description>
92
    <languages>
93
        <language tag="en-GB">en-GB.plg_vmcustom_textinput.ini</language>
94
        <language tag="fr-FR">fr-FR.plg_vmcustom_textinput.ini</language>
95
    </languages>
96
    <files>
97
        <filename plugin="textinput">textinput.php</filename>
98
    </files>
99
    <params addpath="/administrator/components/com_virtuemart/elements">
100
        <param type="vmjpluginwarning" />
101
        <param name="custom_name" type="text" size="20"  default="COM_VIRTUEMART_COMMENT" label="VMCUSTOM_NAME_INFO" description="VMCUSTOM_NAME_INFO_DESC" />
102
        <param name="custom_size" type="text"  size="5"  default="10" label="VMCUSTOM_TEXTINPUT_SIZE" description="VMCUSTOM_TEXTINPUT_SIZE_DESC" />
103
        <param name="custom_price_by_letter" type="list"  default="0" label="VMCUSTOM_PRICE_BY_LETTER" description="VMCUSTOM_PRICE_BY_LETTER_DESC" >
104
			<option value="0">No</option>
105
			<option value="1">Yes</option>
106
		</param>		
107
    </params>
108
</install>
109
</pre>
110 1 Patrick Kohl
111 5 Ondra Spilka
*You can see somes differences with joomla standard XML files :*
112 3 Patrick Kohl
113
<pre>
114
<install version="1.5" type="plugin" group="vmcustom" >	
115
</pre>
116 4 Patrick Kohl
117 3 Patrick Kohl
inform joomla the plugin is a "vmcustom" plugin(product customfield plugin)
118
119
120
<pre>
121
    <params addpath="/administrator/components/com_virtuemart/elements">
122
</pre>
123 4 Patrick Kohl
124 3 Patrick Kohl
Overide the joomla system by virtuemart 2 to enchance it.
125
_Always add this or your plugin have chance to not work_
126
127
128 4 Patrick Kohl
<pre>
129 3 Patrick Kohl
        <param type="vmjpluginwarning" />
130
</pre>
131 1 Patrick Kohl
132
inform that the parameters are saved by virtuemart2 for each plugin variant.
133 4 Patrick Kohl
134
h3. transmited parameters by functions
135
136
*$product_id*
137
is the selected product_id
138 1 Patrick Kohl
139
*$product*
140 4 Patrick Kohl
is the selected product
141
142 5 Ondra Spilka
*$param*
143
 are the plugin parameters
144 4 Patrick Kohl
145
*$productCustom ,$field*
146
 are the product customfield attributes
147
148
*$selected,$row or $idx*
149
 is the parameter to find or write the right "index/row"
150
151
152
TODO : add more details for parameters
153
154
_See texinput plugin for eg._