Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ascorbic-acid/8ecceb5edee6d1daba39fdefd442544c to your computer and use it in GitHub Desktop.
Save ascorbic-acid/8ecceb5edee6d1daba39fdefd442544c to your computer and use it in GitHub Desktop.
wp webhooks update woocommerce order status example
// 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