VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: BSemog on September 07, 2020, 12:33:14 PM

Title: How to run an action whenever the status of an order is updated?
Post by: BSemog on September 07, 2020, 12:33:14 PM
Hello. I have a component in _admin and i want to run an action whenever the status of an order is updated. What's the best way to do this?
Title: Re: How to run an action whenever the status of an order is updated?
Post by: Jörgen on September 07, 2020, 12:51:05 PM
Cron job, plugin... your question ceratinly needs some more explantion.

Jörgen
Title: Re: How to run an action whenever the status of an order is updated?
Post by: pinochico on September 07, 2020, 13:09:59 PM
For this we have plugin, which change
- status
- description
- pay or not

But you can develop another solution - as wrote Jörgen
Title: Re: How to run an action whenever the status of an order is updated?
Post by: BSemog on September 07, 2020, 13:23:13 PM
We have a component that is responsible for sending the order details to our platform.
Right now, the user has access to a table with the orders listed where he can click to send us the order details.
What we want, is to have this process done automatically after the order status change (or after a payment happens).
I would love to not use cron jobs or having to create a plugin inside the component, since this will be installed in multiple stores.
Is there anyway of having a hook for example that calls a function inside our component?
Title: Re: How to run an action whenever the status of an order is updated?
Post by: GJC Web Design on September 07, 2020, 20:49:09 PM
Just use the triggers provided in VM

when an order status changes it triggers  plgVmOnUpdateOrderPayment()

have a vmcustom or system plugin with

e.g.

   function plgVmOnUpdateOrderPayment ($data,$old_order_status) {
      $status = $this->params->get('status', 'C'); // plugin param
      if($data->order_status==$status){
                    // start doing things
               }
       }


Title: Re: How to run an action whenever the status of an order is updated?
Post by: pinochico on September 07, 2020, 22:55:16 PM
Dont forget about this (I think maybe can be problem):

- the system plugins is loaded before payments plugin
- after trigger payments plugin (order is pay), then I think not loaded your custom system plugin again