1
The function below issues tax notes automatically using This plugin (Electronic Invoice Woocommerce) when the order status is completed.
function issue_automatic_invoice( $order_id, $from, $to, $order ) {
// Validate
$option = apply_filters( 'nfe_issue_automatic', get_option('wc_settings_woocommercenfe_emissao_automatica') );
if ( !$option ){
return;
}
// Process
if (
$to == 'processing' && ($option == 1 || $option == 'yes') ||
$to == 'completed' && $option == 2
){
$nfes = get_post_meta( $order_id, 'nfe', true );
if ( !empty($nfes) && is_array($nfes) ) {
foreach ( $nfes as $nfe ) {
if ( $nfe['status'] == 'aprovado' ) {
return;
}
}
}
$nf = new WooCommerceNFeIssue;
$response = $nf->send( array( $order_id ) );
}
do_action( 'nfe_issued_automatic', $order_id, $to, $response );
}
How would it be possible to add a if
not to issue if the originator of the request is admin
?
I want the function to be performed only on customers' orders and not on mine.