Skip to content

Instantly share code, notes, and snippets.

@diogenesjup
Created December 20, 2023 15:17
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 diogenesjup/152ef5e51f6e1e02f4ee2f2c1fa78318 to your computer and use it in GitHub Desktop.
Save diogenesjup/152ef5e51f6e1e02f4ee2f2c1fa78318 to your computer and use it in GitHub Desktop.
Mudar status para processando automáticamente na confirmação do pagamento
<?php
add_action( 'woocommerce_payment_complete', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
// Verifique se o pedido é para produtos digitais
if ( $order->has_downloadable_item() && $order->has_status( 'completed' ) ) {
$order->update_status( 'processing' ); // Alterar o status para 'Processando'
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment