Hi guys
i want to make use of plgVmOnUpdateOrderShipment to make sure that i always get a trigger when an order get statuschanged.
I need to make some action based on this and these are set up in the vm shipment plugin configuration:
<vmconfig>
<fields name="params">
<fieldset name="orderstatuses">
<field name="order_status_a" type="textarea" label="order_status_a" description="order_status_a" default=""/>
...etc...
</fieldset>
</fields>
</vmconfig>
However whenever the plgVmOnUpdateOrderShipment method does not have any data on the params i have saved in the setup of the plugin
I've been looking into the code and looks like there are 3 triggers whenever a order status change is happening.
shipment,
payment,
coupon each have a plgVm method that is triggered
Payment seems to be stopping if some condition in the returnvalues is met.
Therefore i choose to make my plugin as a shipment plugin.
The problem is however that the saved plugin-parameters ( /administrator/index.php?option=com_virtuemart&view=shipmentmethod ) are not loaded anywhere and i have no idea how to retrieve the info to be able to take action on them.
Can anyone guide me the correct direction?
Thanks
something like
$plugin2 = JPluginHelper::getPlugin('vmshipment', 'weight_countries');//this is the vmshipping plugin
$paramsgjc2 = new JRegistry($plugin2->params);// the params
okay
so you think i should make the plugin so that the param settings should be done in joomla general, not in the actual plugin-instance within VM?
Don't understand
this gets the params from any plugin from anywhere.. you can use as needed
Quote from: GJC Web Design on August 31, 2018, 14:43:34 PM
something like
$plugin2 = JPluginHelper::getPlugin('vmshipment', 'weight_countries');//this is the vmshipping plugin
$paramsgjc2 = new JRegistry($plugin2->params);// the params
Sorry to add to the confusion. This does not seem to get the params from a <vmconfig> section , it just accesses params declared in a <config> section of a xml file. I may be missing something, but that is what I can experience so far.
Jörgen @ Kreativ Fotografi
this could well be true-- never tested .. but I don't understand what params are required from where to be used where.. :(
The joomla params are "global" the vmconfig params can be specific for example each order row and need more keys to find the right one. Makes it a lot trickier to find the right one when you out of context in a module or component looking for custom field data.
Jörgen @ Kreativ Fotografi
Hi guys.
Thanks for your time.
As Jörgen writes they code above gives me the joomla plugin-parameters which are global
What i would like to do is get a vm plugin instance parameters for each instance of the plugin.
See it like this:
I have a plugin called url-callback that i would like to add depending on which shopper it is.
So order status "E" i want it to call url1 if shopper is X and url2 if shopper is Y.
Normally i would have a $method (in the other triggers) but right here i dont have this.. so i was just wondering how do i determine which one "im currently in"
Hi again.
So i thought i wanted to update you on the current solution on working on.
I actually make a sql directly to the db to get the info i want, then i decode the encoded plugin parameters..
function plgVmOnUpdateOrderShipment($data, $old_order_status) {
$db = JFactory::getDBO();
$shipment_element = strtolower(str_ireplace("plgVmShipment","",get_class($this)));
$sql = 'SELECT * FROM `#__virtuemart_shipmentmethods` WHERE published=1 AND `shipment_element` LIKE "'.$shipment_element.'" order by ordering ASC';
$db->setQuery( $sql );
$shipments = $db->loadObjectList();
$params =array();
foreach($shipments as $shipment_plugin_data){
$params_lines = explode("|",$shipment_plugin_data->shipment_params);
foreach($params_lines as $line){
if(!empty($line)){
$param_data = explode("=",$line,2);
$params[$param_data[0]] = substr($param_data[1],1,-1);
}
}
$order_status_param = isset($params['order_status_'.strtolower($data->order_status)])?$params['order_status_'.strtolower($data->order_status)]:"";
}
}
Hopefully someone out there might be looking for a similar solution.