Author Topic: How to run an action whenever the status of an order is updated?  (Read 177 times)

BSemog

  • Beginner
  • *
  • Posts: 2
  • A beginner
How to run an action whenever the status of an order is updated?
« 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?

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2996
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to run an action whenever the status of an order is updated?
« Reply #1 on: September 07, 2020, 12:51:05 pm »
Cron job, plugin... your question ceratinly needs some more explantion.

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 642
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: How to run an action whenever the status of an order is updated?
« Reply #2 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
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

BSemog

  • Beginner
  • *
  • Posts: 2
  • A beginner
Re: How to run an action whenever the status of an order is updated?
« Reply #3 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?

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9777
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to run an action whenever the status of an order is updated?
« Reply #4 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
               }
       }


GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 642
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: How to run an action whenever the status of an order is updated?
« Reply #5 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
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates