News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How to save "extra plugin parameters" when creating userfield plugin.

Started by UWiX, October 20, 2016, 21:25:32 PM

Previous topic - Next topic

UWiX

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:

var $varsToPush = array( 'checkUserProfile'=>array(0.0,'bool')   ); // Global variable to use

In the ___construct function added:
$this->setConfigParameterable('userfield_params', $this->varsToPush); // As described in the documentation

In the plgVmPrepareUserfieldDataSave function added:
$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

-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Milbo

Quote from: UWiX on October 20, 2016, 21:25:32 PM
In the plgVmPrepareUserfieldDataSave function added:
$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?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

UWiX

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!
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Milbo

You need in the constructor this (as you posted)

$this->setConfigParameterable ('customfield_params', $varsToPush);


and this

function plgVmDeclarePluginParamsCustomVM3(&$data){
return $this->declarePluginParams('custom', $data);
}


and this

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/