Aggiungere pulsante per annullare ordine da WooCommerce

Aggiungere pulsante per annullare ordine da WooCommerce

Per comodità, aggiungiamo un pulsante per annullare un ordine da WooCommerce

/**
 * Questo snippet aggiungerà un pulsante Annulla ad ogni ordine presente nella lista degli ordini.
 */
add_filter( 'woocommerce_admin_order_actions', 'add_cancel_order_actions_button', PHP_INT_MAX, 2 );
function add_cancel_order_actions_button( $actions, $the_order ) {
	if ( ! $the_order->has_status( array( 'cancelled' ) ) ) { // if order is not cancelled yet...
		$actions['cancel'] = array(
			'url'       => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=cancelled&order_id=' . $the_order->id ), 'woocommerce-mark-order-status' ),
			'name'      => __( 'Cancel', 'woocommerce' ),
			'action'    => "view cancel", // setting "view" for proper button CSS
		);
	}
	return $actions;
}
add_action( 'admin_head', 'add_cancel_order_actions_button_css' );
function add_cancel_order_actions_button_css() {
	echo '<style>.view.cancel::after { content: "\00274C" !important; }</style>';
}

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.

Scroll to Top