Created
May 31, 2019 14:32
-
-
Save felipe-pita/7116132fa9ccb340da1661b5e6396de2 to your computer and use it in GitHub Desktop.
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
/** | |
* 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