Last active
February 3, 2022 02:26
-
-
Save growdev/5051444 to your computer and use it in GitHub Desktop.
Add Buttons to WooCommerce Edit Order screen
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
<?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