Skip to content

Instantly share code, notes, and snippets.

@Musilda
Created February 17, 2019 17:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Musilda/ac1525a0f6298c685abcf9621f33cb50 to your computer and use it in GitHub Desktop.
Save Musilda/ac1525a0f6298c685abcf9621f33cb50 to your computer and use it in GitHub Desktop.
<?php
// Add your custom order status action button (for orders with "processing" status)
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
// Display the button for all orders that have a 'processing' status
if ( $order->has_status( array( 'processing' ) ) ) {
// Get Order ID (compatibility all WC versions)
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
// Set the action button
$actions['parcial'] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=parcial&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
'name' => __( 'Envio parcial', 'woocommerce' ),
'action' => "view parcial", // keep "view" class for a clean button CSS
);
}
return $actions;
}
// Set Here the WooCommerce icon for your action button
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
echo '<style>.view.parcial::after { font-family: woocommerce; content: "\e005" !important; }</style>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment