Skip to content
Advertisement

WooCommerce hide pay button on my account page for failed/onhold orders

What would you be the correct CSS code to hide the pay button for the failed or hold orders on My Account page.

I tried this and it is not working.

.woocommerce-button.button.pay {
    display: none;
}

Thanks.

Advertisement

Answer

You could use the following:

  • CSS
.woocommerce-MyAccount-content .woocommerce-orders-table__row--status-failed .pay {
    display: none;
}
  • PHP
function filter_woocommerce_my_account_my_orders_actions( $actions, $order ) {
    // Get status
    $order_status = $order->get_status();

    // Status = failed
    if ( $order_status == 'failed' ) {
        // Unset 
        unset( $actions['pay'] );
    }

    return $actions;
}
add_filter( 'woocommerce_my_account_my_orders_actions', 'filter_woocommerce_my_account_my_orders_actions', 10, 2 );
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement