Project

General

Profile

Product Plugins » History » Version 3

Patrick Kohl, 10/08/2011 11:06 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 3 Patrick Kohl
h3. Use of plugin XML parameters :
78
79
*XML Exemple for textinput*
80
<pre>
81
<?xml version="1.0" encoding="UTF-8" ?>
82
<install version="1.5" type="plugin" group="vmcustom" >	
83
    <name>VMCustom - textinput</name>
84
    <creationDate>June 2011</creationDate>
85
    <author>The VirtueMart Development Team</author>
86
    <authorUrl>http://www.virtuemart.net</authorUrl>
87
    <copyright>Copyright (C) 2004-2011 Virtuemart Team. All rights reserved.</copyright>
88
    <license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
89
    <version>1.9.8</version>
90
    <description>text input plugin for product</description>
91
    <languages>
92
        <language tag="en-GB">en-GB.plg_vmcustom_textinput.ini</language>
93
        <language tag="fr-FR">fr-FR.plg_vmcustom_textinput.ini</language>
94
    </languages>
95
    <files>
96
        <filename plugin="textinput">textinput.php</filename>
97
    </files>
98
    <params addpath="/administrator/components/com_virtuemart/elements">
99
        <param type="vmjpluginwarning" />
100
        <param name="custom_name" type="text" size="20"  default="COM_VIRTUEMART_COMMENT" label="VMCUSTOM_NAME_INFO" description="VMCUSTOM_NAME_INFO_DESC" />
101
        <param name="custom_size" type="text"  size="5"  default="10" label="VMCUSTOM_TEXTINPUT_SIZE" description="VMCUSTOM_TEXTINPUT_SIZE_DESC" />
102
        <param name="custom_price_by_letter" type="list"  default="0" label="VMCUSTOM_PRICE_BY_LETTER" description="VMCUSTOM_PRICE_BY_LETTER_DESC" >
103
			<option value="0">No</option>
104
			<option value="1">Yes</option>
105
		</param>		
106
    </params>
107
</install>
108
</pre>
109
110
*YOu can see somes differences with joomla standard XML files :*
111
112
<pre>
113
<install version="1.5" type="plugin" group="vmcustom" >	
114
</pre>
115
inform joomla the plugin is a "vmcustom" plugin(product customfield plugin)
116
117
118
<pre>
119
    <params addpath="/administrator/components/com_virtuemart/elements">
120
</pre>
121
Overide the joomla system by virtuemart 2 to enchance it.
122
_Always add this or your plugin have chance to not work_
123
124
125
<pre>
126
        <param type="vmjpluginwarning" />
127
</pre>
128
inform that the parameters are saved by virtuemart2 for each plugin variant.
129
130
h3. transmited parameters by functions
131 1 Patrick Kohl
132
TODO