News:

Looking for documentation? Take a look on our wiki

Main Menu

Parameters in plugins

Started by evad1089, August 10, 2012, 02:42:20 AM

Previous topic - Next topic

evad1089

I was wondering how to get a state/province select in the plugin.

In the standard shipping the country select is created by:

<param name="countries" type="vmcountries"  scope="com_virtuemart" default="" label="VMSHIPMENT_WEIGHT_COUNTRIES_COUNTRIES" description="VMSHIPMENT_WEIGHT_COUNTRIES_COUNTRIES_DESC"/>

but I cannot find how to get a state select. I searched the source and database and could not even find an instance of "vmcountries" (except for in other xml files).

-- Dave

GJC Web Design

#1
You need to extend the JElement class with a custom plugin (I did this for a categories select in a shipping plugin)
Use models/state.php as an example and install it in the plugins/vmshipment

Might be simpler to use -> http://www.gjcwebdesign.com/virtuemart-2-joomla-25-postcode-zip-code-shipping-plugin-released.html

This can match state/province names and you only need one method...
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

evad1089

Hmmmm.

I had figured there was a built in method considering that the shipping/billing information had state lists. It is sad to know that is not the case.

GJC Web Design

There is a method but it's not available in the JElement class - that's why you need to basically copy it and extend to JElement.
It can then be accessed by the shipping methods..
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

evad1089

Oh, I see.

That makes a lot more sense now.

Am I able to make a stand alone plugin to create this functionality, or do I have to wrap it into my main plugin? I figure this is a pretty useful extension that could be used in lots of different plugins. I am not familiar with how to add a VirtueMart element the correct way.

I noticed this comment in the head of the 'JElementVmCountries' file that I believe controls the vmcountries type element.

* Those plugins cannot be configured througth the Plugin Manager anyway.

I assume this element was installed by a plugin through the Virtuemart all in one component. Correct? How are these controlled if not through the plugin manager?

Regards,
Dave

evad1089

I used this post to get a simple parameter extension for states: http://forum.virtuemart.net/index.php?topic=94998.0

I gave up trying to add a stand along vmstates plugin. (Didn't really try that hard though). Didn't seem worth the hassle once I figured out that if in the parameters section of the install xml file I add something like


<params addpath="/administrator/components/com_virtuemart/elements" />
<params addpath="/plugins/(my plugin type)/(my plugin name)/elements" />
<params>
... my params ...
</params


it will include all my custom parameters for my plugin. I just tossed the vmstates.php file in a folder named elements in my plugin and we were good to go!