How to make so that after updating the status of the order for "processing", my code is executed? How can you catch a status change? Is it even possible to do this without editing the plugin?

Ps I searched for the answer in goog, I tried to find the answer in the api documentation ( http://woocommerce.imtqy.com/woocommerce-rest-api-docs/wp-api-v2.html?php#libraries-and-tools ), but in it I found only the possibility of obtaining data on orders.

  • one
    Hmm ... here is stackoverflow.com/questions/46090181/… an example of reading documentation and google if I understand the question correctly, then you need the following add_action('woocommerce_order_status_changed','callback'); hook add_action('woocommerce_order_status_changed','callback'); when status changes - Walfter
  • one
    This is what I found in the documentation woocommerce.imtqy.com/woocommerce-rest-api-docs / ... all the hooks - Walfter
  • @Walfter thanks for answering, now I will see :) - olishevskyalex
  • 2
    @Walfter as they say, the answers - in the answers! The answer is correct, and it can be useful for those who are looking for a solution to this problem. - KAGG Design
  • one
    @KAGGDesign I was not sure what the answer was and only tried to push the author. Since I did not work with woocommerce, and spoke only from the general knowledge of WP, and I think if he solved this problem, the author needed to give an answer to his question - Walfter

1 answer 1

Using WP hooks:

 add_action('woocommerce_order_status_changed','callback', 10, 3); // 10 ΠΏΡ€ΠΈΠΎΡ€ΠΈΡ‚Π΅Ρ‚ Ρ…ΡƒΠΊΠ° 3 количСство ΠΎΡ‚Π΄Π°Π²Π°Π΅ΠΌΡ‹Ρ… ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ² function callback($order_id,$old_status,$new_status) { if ($new_status == 'processing') { // ΠΊΠ°ΠΊΠΎΠΉ Ρ‚ΠΎ ΠΊΠΎΠ΄ } } 

Sample in English stack

The second example in English is from the question author.

Hooks in WooCommerce plugin (documentation)