Skip to content

Instantly share code, notes, and snippets.

@a1iraxa
Forked from abegit/wc_order_status_changes.php
Created September 14, 2017 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1iraxa/ab1a2deed15ae2f0e223a9f5fa1880c1 to your computer and use it in GitHub Desktop.
Save a1iraxa/ab1a2deed15ae2f0e223a9f5fa1880c1 to your computer and use it in GitHub Desktop.
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
error_log("$order_id set to PROCESSING", 0);
}
function mysite_completed($order_id) {
error_log("$order_id set to COMPLETED", 0);
}
function mysite_refunded($order_id) {
error_log("$order_id set to REFUNDED", 0);
}
function mysite_cancelled($order_id) {
error_log("$order_id set to CANCELLED", 0);
}
add_action( ‘woocommerce_order_status_pending’, ‘mysite_pending’);
add_action( ‘woocommerce_order_status_failed’, ‘mysite_failed’);
add_action( ‘woocommerce_order_status_on-hold’, ‘mysite_hold’);
// Note that it’s woocommerce_order_status_on-hold, not on_hold.
add_action( ‘woocommerce_order_status_processing’, ‘mysite_processing’);
add_action( ‘woocommerce_order_status_completed’, ‘mysite_completed’);
add_action( ‘woocommerce_order_status_refunded’, ‘mysite_refunded’);
add_action( ‘woocommerce_order_status_cancelled’, ‘mysite_cancelled’);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment