VirtueMart Forum

VirtueMart 2 + 3 => Plugins: Payment, Shipment and others => Topic started by: UWiX on October 20, 2016, 21:25:32 pm

Title: How to save "extra plugin parameters" when creating userfield plugin.
Post by: UWiX on October 20, 2016, 21:25:32 pm
I am developing a simple userfield plugin which should check some user profile settings. It does not need any table to store records or something like the included virtuemart realex_hpp_api plugin does.

Now I've added one option in the xml of the plugin to show up on the extra plugin parameters field when defining the shopper field details. And it displays as it should but when saving the defined field this parameter isn't stored in the "userfield_params" column in the #__virtuemart_userfields table.

The following codes are added to the plugin:

Code: [Select]
var $varsToPush = array( 'checkUserProfile'=>array(0.0,'bool')   ); // Global variable to use
In the ___construct function added:
Code: [Select]
$this->setConfigParameterable('userfield_params', $this->varsToPush); // As described in the documentation
In the plgVmPrepareUserfieldDataSave function added:
Code: [Select]
$this->storePluginInternalData($params); // Save parameters ($params is taken from the function variable)But that function does not seem te be called at all ;-(

Also tried to add the storePluginInternalData call in the plgVmOnBeforeUserfieldSave function - but that doesn't work either.

What am I missing here? I cannot seem to find the correct way to store the selected parameter value into the correct array or function to save it to the database.
If any of you have an idea or a solution or some clear documentation on it... That would be very nice!  ;D

Title: Re: How to save "extra plugin parameters" when creating userfield plugin.
Post by: Milbo on February 13, 2018, 20:51:42 pm
In the plgVmPrepareUserfieldDataSave function added:
Code: [Select]
$this->storePluginInternalData($params); // Save parameters ($params is taken from the function variable)But that function does not seem te be called at all ;-(

Sad that I did not see this post earlier. The answer is just that the storePluginInternalData is the user data of the plugin. You want to store the configuration of the plugin, right?
Title: Re: How to save "extra plugin parameters" when creating userfield plugin.
Post by: UWiX on February 13, 2018, 21:06:49 pm
Yes, that's right. The plugin parameters which are added as described in my 'problem' description.  And better late than....  ;D Thank you for the reply!
Title: Re: How to save "extra plugin parameters" when creating userfield plugin.
Post by: Milbo on February 14, 2018, 10:23:37 am
You need in the constructor this (as you posted)
Code: [Select]
$this->setConfigParameterable ('customfield_params', $varsToPush);

and this
Code: [Select]
function plgVmDeclarePluginParamsCustomVM3(&$data){
return $this->declarePluginParams('custom', $data);
}

and this
Code: [Select]
function plgVmGetTablePluginParams($psType, $name, $id, &$xParams, &$varsToPush){
return $this->getTablePluginParams($psType, $name, $id, $xParams, $varsToPush);
}


When you have this triggers, you just need the data as array and the stuff is automatically stored as parameter.