Created
March 23, 2021 07:35
-
-
Save ascorbic-acid/8ecceb5edee6d1daba39fdefd442544c to your computer and use it in GitHub Desktop.
wp webhooks update woocommerce order status example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put this code in your theme functions.php | |
add_filter( 'wpwhpro/run/actions/custom_action/return_args', 'wpwh_fire_my_custom_logic', 10, 3 ); | |
function wpwh_fire_my_custom_logic( $return_args, $identifier, $response_body ){ | |
//If the identifier doesn't match, do nothing | |
if( $identifier == 'update_status' ){ | |
$order_id = WPWHPRO()->helpers->validate_request_value( $response_body['content'], 'order_id' ); | |
$new_status = WPWHPRO()->helpers->validate_request_value( $response_body['content'], 'new_status' ); | |
$order = new WC_Order($order_id); | |
$order->update_status($new_status); | |
return 'done'; | |
} | |
return "no identifier"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment