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

plgVmOnUpdateOrderShipment - getting vmconfig params for plugin

Started by welrachid, August 31, 2018, 14:08:21 PM

Previous topic - Next topic

welrachid

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
Best regards,
Wel

GJC Web Design

something like

   $plugin2 = JPluginHelper::getPlugin('vmshipment', 'weight_countries');//this is the vmshipping plugin
   $paramsgjc2 = new JRegistry($plugin2->params);// the params
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

welrachid

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?

Best regards,
Wel

GJC Web Design

Don't understand

this gets the params from any plugin from anywhere.. you can use as needed
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

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

GJC Web Design

this could well be true-- never tested .. but I don't understand what params are required from where to be used where..  :(
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

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

welrachid

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"
Best regards,
Wel

welrachid

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.
Best regards,
Wel