Plugin system » History » Version 23
Valérie Isaksen, 06/12/2011 09:11 AM
1 | 10 | Oscar van Eijk | {{>toc}} |
---|---|---|---|
2 | |||
3 | 1 | Oscar van Eijk | h1. Plugin system |
4 | |||
5 | 5 | Oscar van Eijk | Since VirtueMart v2, the Joomla! plugin system is used form payment and shipper plugins. |
6 | 1 | Oscar van Eijk | |
7 | h2. Installing plugins |
||
8 | |||
9 | During development the the VM2 branch, the plugins are not available as Joomla install packages, so for test environments, they must be installed manually. |
||
10 | |||
11 | h3. Payment plugins |
||
12 | |||
13 | At the time of writing, only 2 of the former payment plugins have been converted to the new plugin system. Others should follow soon, all help is appreciated!! |
||
14 | |||
15 | Use the SQL query below to add the plugins to your database (assuming the table prefix is "jos_"): |
||
16 | |||
17 | 12 | Christopher Roussel | J1.5: |
18 | 1 | Oscar van Eijk | <pre> |
19 | 4 | Devendra Kumar Shukla | INSERT INTO `jos_plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering` |
20 | 1 | Oscar van Eijk | , `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) |
21 | VALUES |
||
22 | (NULL, 'VMPayment - Authorize', 'authorize', 'vmpayment', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '') |
||
23 | 12 | Christopher Roussel | ,(NULL, 'VMPayment - Cash on delivery', 'cashondel', 'vmpayment', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00',''); |
24 | 1 | Oscar van Eijk | </pre> |
25 | 12 | Christopher Roussel | J1.6: |
26 | <pre> |
||
27 | INSERT INTO `jos_extensions` (`extension_id`, `type`, `name`, `element`, `folder`, `access`, `ordering` |
||
28 | , `enabled`, `protected`, `client_id`, `checked_out`, `checked_out_time`, `params`) |
||
29 | VALUES |
||
30 | (NULL, 'plugin', 'plg_vmpayment_authorize', 'authorize', 'vmpayment', 1, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '') |
||
31 | ,(NULL, 'plugin', 'plg_vmpayment_cashondel', 'cashondel', 'vmpayment', 1, 0, 1, 0, 0, 0, '0000-00-00 00:00:00',''); |
||
32 | </pre> |
||
33 | 1 | Oscar van Eijk | |
34 | 13 | Max Milbers | Next, when you did not use the svn checkout, copy the plugin files (authorize.php, authorize.xml, cashondel.php and cashondel.xml), located in the folder /plugins/vmpayment, to the Joomla plugin directory. If that doesn't exist, it must be created first. |
35 | 1 | Oscar van Eijk | |
36 | 19 | Valérie Isaksen | Now, in the store maintenance, you can add payment methods based on one of these plugins, then click Apply button to display the appropriate parameters in the configuration tab. Note at this moment it is required to select a vendor! |
37 | 1 | Oscar van Eijk | |
38 | h3. Shipper plugins |
||
39 | 3 | Oscar van Eijk | |
40 | 1 | Oscar van Eijk | This is very similar to the payment plugins. Only 1 plugin has been created (again: all help is appreciated!); 'standard', which provides a basic shipping option for postal services. |
41 | *Note:* Installing the sample data does _NOT_ provide shipping rates anymore! |
||
42 | |||
43 | Use the SQL query below to add the plugins to your database (assuming the table prefix is "jos_"): |
||
44 | |||
45 | 12 | Christopher Roussel | J1.5: |
46 | 1 | Oscar van Eijk | <pre> |
47 | INSERT INTO `jos_plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering` |
||
48 | , `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) |
||
49 | VALUES |
||
50 | 17 | Valérie Isaksen | (NULL, 'By weight, ZIP and countries', 'weight_countries', 'vmshipper', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '') |
51 | 16 | Valérie Isaksen | ,(NULL, 'By products and countries', 'products_countries', 'vmshipper', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '') |
52 | 14 | Valérie Isaksen | ; |
53 | 1 | Oscar van Eijk | </pre> |
54 | |||
55 | 12 | Christopher Roussel | J1.6: |
56 | <pre> |
||
57 | INSERT INTO `jos_extensions` (`extension_id`, `type`, `name`, `element`, `folder`, `access`, `ordering` |
||
58 | 1 | Oscar van Eijk | , `enabled`, `protected`, `client_id`, `checked_out`, `checked_out_time`, `params`) |
59 | VALUES |
||
60 | 16 | Valérie Isaksen | (NULL, 'plugin', 'plg_vmshipper_weight_countries', 'weight_countries', 'vmshipper', 1, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '') |
61 | ,(NULL, 'plugin', 'plg_vmshipper_products_countries', 'products_countries', 'vmshipper', 1, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '') |
||
62 | 14 | Valérie Isaksen | ; |
63 | 12 | Christopher Roussel | </pre> |
64 | 19 | Valérie Isaksen | Next, when you did not use the svn checkout, copy the plugin files (weight_countries.php, weight_countries.xml, products_countries.php and products_countries.XML), located in the folder /plugins/vmshipper, to the Joomla plugin directory. If that doesn't exist, it must be created first. |
65 | 1 | Oscar van Eijk | |
66 | 19 | Valérie Isaksen | Now use the 'Shipping methods' menu item in the backend to add 1 or more shipping methods. Give a shipping method name, select the shipping method,and click Apply button to display the appropriate parameters in the configuration tab. All you need to do here is give the shipper a name and select a vendor (this is optional; when no vendor is selected, this carrier is valid for all vendors). |
67 | Make sure a there's always a valid shipping rate: the plugin must be able to find a matching rate based on the shipto address! |
||
68 | 1 | Oscar van Eijk | |
69 | 5 | Oscar van Eijk | h2. Plugin Development |
70 | 1 | Oscar van Eijk | |
71 | 5 | Oscar van Eijk | All plugins for VirtueMart should be developed confirming the Joomla! plugin development methods. Refer to http://docs.joomla.org/Tutorial:Plugins for developers documentation for Joomla! plugins. |
72 | |||
73 | h3. Payment Plugins |
||
74 | |||
75 | 7 | Oscar van Eijk | Payment plugins are used both in the front-end and the backend. They must be created as classes deriving from the base class *vmPaymentPlugin*: |
76 | 9 | Oscar van Eijk | <pre><code class="php"> |
77 | 7 | Oscar van Eijk | class plgVmPayment<myPlugin> extends vmPaymentPlugin { |
78 | function plgVmPayment<myPlugin>(&$subject, $config) { |
||
79 | $this->_pelement = basename(__FILE__, '.php'); // Required! |
||
80 | $this->_createTable(); // Required, see below |
||
81 | parent::__construct($subject, $config); |
||
82 | } |
||
83 | } |
||
84 | 9 | Oscar van Eijk | </code></pre> |
85 | 7 | Oscar van Eijk | |
86 | Below is the list with events and a description on what moment they are fired. |
||
87 | 6 | Oscar van Eijk | * *plgVmOnSelectPayment()* - This event is fired during the checkout process. It allows the shopper to select one of the available payment methods. |
88 | 5 | Oscar van Eijk | It should display a radio button (name: paym_id) to select the payment method. Other information (like credit card info) might be selected as well, depending on the plugin. |
89 | +Return:+ |
||
90 | It must return the HTML code for displaying the form (radio button and optional extra selections). |
||
91 | +Parameters:+ |
||
92 | # (VirtueMartCart object) The cart object |
||
93 | # (integer, default 0) ID of an already selected payment method ID, if any |
||
94 | |||
95 | 6 | Oscar van Eijk | * *plgVmOnPaymentSelectCheck()* - This event is fired after the payment method has been selected. It can be used to store |
96 | 5 | Oscar van Eijk | additional payment info in the cart. |
97 | +Return:+ |
||
98 | Plugins that were not selected must return null, otherwise True of False must be returned indicating Success or Failure. |
||
99 | +Parameters:+ |
||
100 | # (VirtueMartCart object) The cart object |
||
101 | |||
102 | 10 | Oscar van Eijk | |
103 | |||
104 | 6 | Oscar van Eijk | * *plgVmOnCheckoutCheckPaymentData()* - This event is fired during the checkout process. It can be used to validate the payment data as entered by the user. |
105 | 5 | Oscar van Eijk | +Return:+ |
106 | Plugins that were not selected must return null, otherwise True of False must be returned indicating Success or Failure. |
||
107 | +Parameters:+ |
||
108 | None |
||
109 | |||
110 | 6 | Oscar van Eijk | * *plgVmOnConfirmedOrderStorePaymentData()* - This event is fired after the payment has been processed; it stores the payment method-specific data. |
111 | 5 | Oscar van Eijk | All plugins _must_ reimplement this method. |
112 | +Return:+ |
||
113 | If the plugin is NOT actually executed (not the selected payment method), this method must return NULL |
||
114 | If this plugin IS executed, it MUST return the order status code that the order should get. This triggers the stock updates if required |
||
115 | +Parameters:+ |
||
116 | # (integer) The ordernumber being processed |
||
117 | # (object) Data from the cart |
||
118 | # (array) Price information for this order |
||
119 | |||
120 | 6 | Oscar van Eijk | * *plgVmOnShowOrderPaymentBE()* - This method is fired when showing the order details in the backend. It displays the the payment method-specific data. |
121 | 5 | Oscar van Eijk | All plugins _must_ reimplement this method. |
122 | +Return:+ |
||
123 | Null when for payment methods that were not selected, text (HTML) otherwise |
||
124 | +Parameters:+ |
||
125 | # (integer) The order ID |
||
126 | # (integer) Payment method used for this order |
||
127 | |||
128 | 6 | Oscar van Eijk | * *plgVmOnCancelPayment()* - This event is fired each time the status of an order is changed to Cancelled. It can be used to refund payments, void authorization etc. |
129 | 5 | Oscar van Eijk | When reimplementing this methis, the body _must_ start with this code: |
130 | 9 | Oscar van Eijk | <pre><code class="php">$_paymethodID = $this->getPaymentMethodForOrder($_orderID); |
131 | 5 | Oscar van Eijk | if (!$this->selectedThisMethod($this->_pelement, $_paymethodID)) { |
132 | return; |
||
133 | 9 | Oscar van Eijk | }</code></pre> |
134 | 5 | Oscar van Eijk | +Parameters:+ |
135 | (integer The order ID |
||
136 | (char) Previous order status |
||
137 | (char) New order status |
||
138 | |||
139 | 6 | Oscar van Eijk | * *plgVmOnShipOrderPayment()* - This event is fired when the status of an order is changed to Shipped. It can be used to confirm or capture payments |
140 | 5 | Oscar van Eijk | When reimplementing this methis, the body _must_ start with this code: |
141 | 9 | Oscar van Eijk | <pre><code class="php">$_paymethodID = $this->getPaymentMethodForOrder($_orderID); |
142 | 5 | Oscar van Eijk | if (!$this->selectedThisMethod($this->_pelement, $_paymethodID)) { |
143 | return; |
||
144 | 9 | Oscar van Eijk | }</code></pre> |
145 | 5 | Oscar van Eijk | +Return:+ |
146 | True on success, False on failure, Null if this plugin was not activated |
||
147 | +Parameters:+ |
||
148 | 1 | Oscar van Eijk | # (integer) Order ID |
149 | 7 | Oscar van Eijk | |
150 | Other helper functions inherited from the base class: |
||
151 | |||
152 | 9 | Oscar van Eijk | * *_ createTable()* - This method is used to create and maintain the plugin specific database table(s). |
153 | 7 | Oscar van Eijk | It _must_ be reimplemented by all plugins. |
154 | 1 | Oscar van Eijk | +Example:+ |
155 | 8 | Oscar van Eijk | <pre><code class="php"> |
156 | 7 | Oscar van Eijk | $_scheme = DbScheme::get_instance(); |
157 | $_scheme->create_scheme('#__vm_order_payment_'.$this->_pelement); |
||
158 | $_schemeCols = array( |
||
159 | 'id' => array ( |
||
160 | 'type' => 'int' |
||
161 | ,'length' => 11 |
||
162 | ,'auto_inc' => true |
||
163 | ,'null' => false |
||
164 | ) |
||
165 | ,'order_id' => array ( |
||
166 | 'type' => 'int' |
||
167 | ,'length' => 11 |
||
168 | ,'null' => false |
||
169 | ) |
||
170 | ,'payment_method_id' => array ( |
||
171 | 'type' => 'text' |
||
172 | ,'null' => false |
||
173 | ) |
||
174 | ); |
||
175 | $_schemeIdx = array( |
||
176 | 'idx_order_payment' => array( |
||
177 | 'columns' => array ('order_id') |
||
178 | ,'primary' => false |
||
179 | ,'unique' => false |
||
180 | ,'type' => null |
||
181 | ) |
||
182 | ); |
||
183 | $_scheme->define_scheme($_schemeCols); |
||
184 | $_scheme->define_index($_schemeIdx); |
||
185 | if (!$_scheme->scheme()) { |
||
186 | JError::raiseWarning(500, $_scheme->get_db_error()); |
||
187 | } |
||
188 | $_scheme->reset(); |
||
189 | 8 | Oscar van Eijk | </code></pre> |
190 | 7 | Oscar van Eijk | |
191 | 8 | Oscar van Eijk | * *getPaymentMethodForOrder()* - Get the order payment ID for a given order number |
192 | 7 | Oscar van Eijk | +Return:+ |
193 | The payment method ID, or -1 when not found |
||
194 | +Parameters:+ |
||
195 | # (integer) The order ID |
||
196 | |||
197 | 8 | Oscar van Eijk | * *getThisMethodName()* - Get the name of the payment method. |
198 | 7 | Oscar van Eijk | This method can _not_ be reimplemented |
199 | +Return:+ |
||
200 | Paymenent method name |
||
201 | +Parameters:+ |
||
202 | # (integer) The payment method ID |
||
203 | |||
204 | 8 | Oscar van Eijk | * *selectedThisMethod()* - This method checks if the selected payment method matches the current plugin |
205 | 7 | Oscar van Eijk | +Return:+ |
206 | True if the calling plugin has the given payment ID, False otherwise. |
||
207 | +Parameters:+ |
||
208 | # (string) Element name, taken from the plugin filename |
||
209 | # (integer) The payment method ID |
||
210 | |||
211 | 8 | Oscar van Eijk | * *writePaymentData()* - This method writes all payment plugin specific data to the plugin's table |
212 | 7 | Oscar van Eijk | +Return:+ |
213 | True if the calling plugin has the given payment ID, False otherwise. |
||
214 | +Parameters:+ |
||
215 | # (array) Indexed array in the format 'column_name' => 'value' |
||
216 | # (string) Table name |
||
217 | 10 | Oscar van Eijk | |
218 | h3. Shipper Plugins |
||
219 | |||
220 | Shipper plugins are used both in the front-end and the backend. They must be created as classes deriving from the base class *vmShipperPlugin*: |
||
221 | <pre><code class="php"> |
||
222 | class plgVmShipper<myPlugin> extends vmShipperPlugin { |
||
223 | function plgVmPayment<myPlugin>(&$subject, $config) { |
||
224 | $this->_pelement = basename(__FILE__, '.php'); // Required! |
||
225 | $this->_createTable(); // Required, see below |
||
226 | parent::__construct($subject, $config); |
||
227 | } |
||
228 | } |
||
229 | </code></pre> |
||
230 | |||
231 | Here's a short overview of the events: |
||
232 | * When a shopper selects a shipper, *plgOnSelectShipper()* is fired. It displays the shipper and can be used for collecting extra - shipper specific - info. |
||
233 | * After selecting, *plgVmShipperSelected()* can be used to store extra shipper info in the cart. The selected shipper ID will be stored in the cart by the checkout process before this method is fired. |
||
234 | * *plgOnConfirmShipper()* is fired when the order is confirmed and stored to the database. It is called before the rest of the order or stored, when reimplemented, it _must_ include a call to parent::plgOnConfirmShipper() (or execute the same steps to put all data in the cart) |
||
235 | |||
236 | When a stored order is displayed in the backend, the following events are used: |
||
237 | * *plgVmOnShowOrderShipperBE()* displays specific data about (a) shipment(s) (NOTE: this plugin is _OUTSIDE_ any form!) |
||
238 | * *plgVmOnShowOrderLineShipperBE()*) can be used to show information about a single orderline, e.g. display a package code at line level when more packages are shipped. |
||
239 | * *plgVmOnEditOrderLineShipperBE() can be used add a package code for an order line when more packages are shipped. |
||
240 | * *plgVmOnUpdateOrderShipperBE()* is fired inside a form. It can be used to add shipper data, like package code. |
||
241 | * *plgVmOnSaveOrderShipperBE()* is fired from the backend after the order has been saved. If one of the show methods above have to option to add or edit info, this method must be used to save the data. |
||
242 | * *plgVmOnUpdateOrderLine()* is fired from the backend after an order line has been saved. This method must be reimplemented if plgVmOnEditOrderLineShipperBE() is used. |
||
243 | 22 | Valérie Isaksen | * *plgVmOnShipperSelectedCalculatePrice()* is fired before the order is saved, and used to calculate the cart prices. |
244 | * *plgVmOnConfirmedOrderStoreShipperData()* This event is fired after the order has been stored; it gets the shipping method specific data. |
||
245 | 10 | Oscar van Eijk | |
246 | The frontend 1 show method: |
||
247 | * plgVmOnShowOrderShipperFE() collects and displays specific data about (a) shipment(s) |
||
248 | |||
249 | Below is the list with events and a description on what moment they are fired. |
||
250 | |||
251 | * *plgVmOnSelectShipper()* - This event is fired during the checkout process. It allows the shopper to select one of the available shippers. |
||
252 | It should display a radio button (name: shipper_id) to select the shipper. In the description, the shipping cost can also be displayed, based on the total order weight and the shipto country (this wil be calculated again during order confirmation) |
||
253 | +Return:+ |
||
254 | HTML code to display the form |
||
255 | +Parameters:+ |
||
256 | # (VirtueMartCart object) Cart object |
||
257 | # (integer, default 0) ID of the currently shipper selected |
||
258 | |||
259 | * *plgVmOnShipperSelected()* - This event is fired after the shipping method has been selected. It can be used to store additional shipper info in the cart. |
||
260 | +Return:+ |
||
261 | True on succes, false on failures, null when this plugin was not selected. |
||
262 | 1 | Oscar van Eijk | On errors, JError::raiseWarning (or JError::raiseError) must be used to set a message. |
263 | +Parameters:+ |
||
264 | # (VirtueMartCart object) Cart object |
||
265 | # (integer, default 0) ID of the shipper selected |
||
266 | 16 | Valérie Isaksen | |
267 | 21 | Valérie Isaksen | * *plgVmOnShipperSelectedCalculatePrice()* - This event is fired before the order is saved, and used to calculate the cart prices. |
268 | 16 | Valérie Isaksen | +Return:+ |
269 | True on succes, false on failures, null when this plugin was not selected. |
||
270 | On errors, JError::raiseWarning (or JError::raiseError) must be used to set a message. |
||
271 | +Parameters:+ |
||
272 | # (VirtueMartCart object) Cart object |
||
273 | # (integer, default 0) ID of the shipper selected |
||
274 | # (array, default 0) Shipping array containing: shipping_name, shipping_value, shipping_rate_vat_id, shipping_currency_id |
||
275 | |||
276 | |||
277 | 10 | Oscar van Eijk | |
278 | 20 | Valérie Isaksen | * *plgVmOnConfirmShipper()* - This event is fired after the payment has been processed; it selects the actual shipping rate and/or order weight, and optionally writes extra info to the database (in which case this method must be reimplemented). |
279 | 10 | Oscar van Eijk | Reimplementation is not required, but when done, the following check MUST be made: |
280 | <pre><code class="php"> |
||
281 | if (!$this->selectedThisShipper($this->_selement, $_cart->shipper_id)) { |
||
282 | return null; |
||
283 | }</code></pre> |
||
284 | +Return:+ |
||
285 | The shipping rate ID |
||
286 | Do _not_ return parent::plgVmOnConfirmShipper($_cart); it is valid but will produce extra overhead! |
||
287 | +Parameters:+ |
||
288 | 1 | Oscar van Eijk | # (VirtueMartCart object) Cart object |
289 | 21 | Valérie Isaksen | |
290 | 20 | Valérie Isaksen | |
291 | * *plgVmOnConfirmedOrderStoreShipperData()* This event is fired after the order has been stored; it gets the shipping method specific data. |
||
292 | +Return:+mixed Null when this method was not selected, otherwise true |
||
293 | #(integer) The order_id being processed |
||
294 | #(object) the cart |
||
295 | #array Price information for this order |
||
296 | |||
297 | |||
298 | 10 | Oscar van Eijk | |
299 | * *plgVmOnShowOrderShipperBE()* - This method is fired when showing the order details in the backend. It displays the shipper-specific data. |
||
300 | NOTE, this plugin should NOT be used to display form fields, since it's called outside a form! Use *plgVmOnUpdateOrderBE()( instead! |
||
301 | +Return:+ |
||
302 | Null for shippers that aren't active, text (HTML) otherwise |
||
303 | +Parameters:+ |
||
304 | # (integer) The order ID |
||
305 | # (integer) Vendor ID |
||
306 | # (object) Object with 2 properties 'carrier' and 'name' |
||
307 | |||
308 | * *plgVmOnEditOrderLineShipperBE()* - This method is fired when editing the order line details in the backend. It can be used to add line specific package codes |
||
309 | +Return:+ |
||
310 | Null for shippers that aren't active, text (HTML) otherwise |
||
311 | +Parameters:+ |
||
312 | # (integer) The order ID |
||
313 | # (integer) The order Line ID |
||
314 | |||
315 | * *plgVmOnUpdateOrderShipper()* - Save updated order data to the shipper specific table |
||
316 | +Return:+ |
||
317 | True on success, false on failures (the rest of the save-process will be skipped!), or null when this shipper is not actived. |
||
318 | +Parameters:+ |
||
319 | # (array) Form data |
||
320 | |||
321 | * *plgVmOnUpdateOrderLineShipper()* - Save updated orderline data to the shipper specific table |
||
322 | +Return:+ |
||
323 | True on success, false on failures (the rest of the save-process will be skipped!), or null when this shipper is not actived. |
||
324 | +Parameters:+ |
||
325 | # (array) Form data |
||
326 | |||
327 | * *plgVmOnShowOrderShipperFE()* - This method is fired when showing the order details in the frontend. It displays the shipper-specific data. |
||
328 | +Return:+ |
||
329 | Null for shippers that aren't active, text (HTML) otherwise |
||
330 | +Parameters:+ |
||
331 | # (integer) The order ID |
||
332 | |||
333 | * *plgVmOnShowOrderLineShipperFE()* - This method is fired when showing the order details in the frontend, for every orderline. It can be used to display line specific package codes, e.g. with a link to external tracking and tracing systems |
||
334 | +Return:+ |
||
335 | Null for shippers that aren't active, text (HTML) otherwise |
||
336 | +Parameters:+ |
||
337 | # (integer) The order ID |
||
338 | # (integer) The order LineID |
||
339 | |||
340 | Other helper functions inherited from the base class: |
||
341 | |||
342 | * *_ createTable()* - This method is used to create and maintain the plugin specific database table(s). |
||
343 | It _must_ be reimplemented by all plugins. |
||
344 | +Example:+ |
||
345 | <pre><code class="php">$_scheme = DbScheme::get_instance(); |
||
346 | $_scheme->create_scheme('#__vm_order_shipper_'.$this->_selement); |
||
347 | $_schemeCols = array( |
||
348 | 'id' => array ( |
||
349 | 'type' => 'int' |
||
350 | ,'length' => 11 |
||
351 | ,'auto_inc' => true |
||
352 | ,'null' => false |
||
353 | ) |
||
354 | ,'order_id' => array ( |
||
355 | 'type' => 'int' |
||
356 | ,'length' => 11 |
||
357 | ,'null' => false |
||
358 | ) |
||
359 | ,'shipper_id' => array ( |
||
360 | 'type' => 'text' |
||
361 | ,'null' => false |
||
362 | ) |
||
363 | ); |
||
364 | $_schemeIdx = array( |
||
365 | 'idx_order_payment' => array( |
||
366 | 'columns' => array ('order_id') |
||
367 | ,'primary' => false |
||
368 | ,'unique' => false |
||
369 | ,'type' => null |
||
370 | ) |
||
371 | ); |
||
372 | $_scheme->define_scheme($_schemeCols); |
||
373 | $_scheme->define_index($_schemeIdx); |
||
374 | if (!$_scheme->scheme()) { |
||
375 | JError::raiseWarning(500, $_scheme->get_db_error()); |
||
376 | } |
||
377 | $_scheme->reset(); |
||
378 | </code></pre> |
||
379 | |||
380 | * *getThisShipperName()* - Get the name of the shipper |
||
381 | +Return:+ |
||
382 | Shipper name |
||
383 | +Parameters:+ |
||
384 | # (integer) The Shipper ID |
||
385 | final protected function ($_sid) |
||
386 | |||
387 | * *writeShipperData()* - This method writes all shipper plugin specific data to the plugin's table |
||
388 | +Parameters:+ |
||
389 | # (array) Indexed array in the format 'column_name' => 'value' |
||
390 | # (string) Table name |
||
391 | |||
392 | * *getShippingRateIDForOrder()* - Get the shipping rate ID for a given order number |
||
393 | +Return:+ |
||
394 | The shipping rate ID, or -1 when not found |
||
395 | +Parameters:+ |
||
396 | # (integer) The order ID |
||
397 | |||
398 | * *getShippingRate()* - Get the total price for a shipping rate |
||
399 | +Return:+ |
||
400 | Price in display format |
||
401 | +Parameters:+ |
||
402 | # (integer) Shipping rate ID |
||
403 | |||
404 | * *getShipperIDForOrder()* - Get the shipper ID for a given order number |
||
405 | +Return:+ |
||
406 | The shipper ID, or -1 when not found |
||
407 | +Parameters:+ |
||
408 | # (integer) The order ID |
||
409 | |||
410 | * *selectShippingRate()* - Select the shipping rate ID, based on the selected shipper in combination with the shipto address (country and zipcode) and the total order weight. |
||
411 | +Return:+ |
||
412 | Shipping rate ID, -1 when no match is found. Only 1 selected ID will be returned; if more ID's match, the cheapest will be selected. |
||
413 | +Parameters:+ |
||
414 | # (VirtueMartCart object) Cart object |
||
415 | # (integer, default 0) Shipper ID, by default taken from the cart |
||
416 | |||
417 | * *selectedThisShipper()* - This method checks if the selected shipper matches the current plugin |
||
418 | +Return:+ |
||
419 | True if the calling plugin has the given payment ID |
||
420 | +Parameters:+ |
||
421 | # (string) Element name, taken from the plugin filename |
||
422 | # (integer) The shipper ID |
||
423 | |||
424 | * *getOrderWeight()* - Get the total weight for the order, based on which the proper shipping rate can be selected. |
||
425 | +Return:+ |
||
426 | Total weight for the order |
||
427 | +Parameters:+ |
||
428 | # (VirtueMartCart object) Cart object |
||
429 | |||
430 | 18 | Valérie Isaksen | * *getShippers()* - Fill an array with all shippers found with this plugin for the current vendor |
431 | 10 | Oscar van Eijk | +Return:+ |
432 | 23 | Valérie Isaksen | True when shipper(s) was (were) found for this vendor, false otherwise |
433 | 10 | Oscar van Eijk | +Parameters:+ |
434 | # (integer) The vendor ID taken from the cart. |
||
435 | |||
436 | * *validateVendor()* - Check if this shipper has carriers for the current vendor. |
||
437 | +Return:+ |
||
438 | True when a shipper_id was found for this vendor, false otherwise |
||
439 | +Parameters:+ |
||
440 | # (integer) The vendor ID taken from the cart. |