Teste esse exemplo abaixo:
{ add_action( 'woocommerce_check_cart_items', 'bbloomer_prevent_failed_orders' );
function bbloomer_prevent_failed_orders() {
global $woocommerce; $failed = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
$order_id = $_product->get_order_id();
$order = wc_get_order( $order_id );
if( $order->has_status( 'failed' ) ) {
$failed = 1;
}
}
if ( $failed == 1 ) { wc_add_notice( __( 'Sorry, your order cannot be processed as one of the items in your cart has already failed.', 'woocommerce' ), 'error' ); } }
Estou criando um plugin e vou precisar de algo semelhante, vlw!