Skip to content

Instantly share code, notes, and snippets.

@KoolPal
Forked from felipe-pita/functions.php
Created February 5, 2020 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KoolPal/b5e925f8dec3c52cd83ac24b719d37ec to your computer and use it in GitHub Desktop.
Save KoolPal/b5e925f8dec3c52cd83ac24b719d37ec to your computer and use it in GitHub Desktop.
/**
* Não permitir a troca de status de pedidos cancelados.
* Muda o pedido para apovação manual
*/
add_filter( 'woocommerce_before_order_object_save', 'prevent_cancelled_order_status_change', 10, 2 );
function prevent_cancelled_order_status_change( $order, $data_store ) {
$changes = $order->get_changes();
if (isset($changes['status'])) {
$data = $order->get_data();
$from_status = $data['status'];
$to_status = $changes['status'];
if ($from_status === 'cancelled') {
$order->set_status('aprovacao-manual', 'O pedido estava cancelado e o sistema tentou alterar seu status. Favor verificar manualmente.');
}
}
return $order;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment