Skip to content

Instantly share code, notes, and snippets.

@growdev
Last active February 3, 2022 02:26
Show Gist options
  • Save growdev/5051444 to your computer and use it in GitHub Desktop.
Save growdev/5051444 to your computer and use it in GitHub Desktop.
Add Buttons to WooCommerce Edit Order screen
<?php
add_action('woocommerce_order_actions', array( $this, 'my_order_actions' ));
add_action('woocommerce_process_shop_order_meta', array( $this, 'my_process_order_meta'), 20, 2 );
function my_order_actions( $post_id ) {
?>
<li class="wide"><input type="submit" class="button tips" name="my_button" value="<?php _e('Do Something', 'woocommerce'); ?>" data-tip="<?php _e('Put tip here.', 'woocommerce'); ?>" /></li>
<?php
}
function my_process_order_meta( $post_id, $post) {
global $woocommerce, $woocommerce_errors;
$order = new WC_Order( $post_id );
if ( isset( $_POST['my_button'] ) && $_POST['my_button'] ) {
// Do something...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment