Home / Blog / E-commerce
,

Add Bootstrap Class to WooCommerce Checkout Fields

First published 14 Jun 2017. Tested again in November 2026 on WordPress 7.1.4, WooCommerce 11.2.2 and PHP 8.4.

Bootstrap, the most popular HTML, CSS and JS framework for developing responsive, mobile first projects on the web. Being so popular yet not accepted by many of other Open Source development providers like WooCommerce. Well, there is no way we can complain to them for this, as WooCommerce is providing great plugins to make eCommerce development easy in WordPress.

But we do have to find possible solutions to use Bootstrap if we are using it for responsive website development.

To add ‘form-control‘ Bootstrap class in WooCommerce default checkout form, add below filter to functions.php in your theme.

add_filter( 'woocommerce_form_field_args', 'wc_form_field_args', 10, 3 );
function wc_form_field_args( $args, $key, $value ) {
    $args['input_class'][] = 'form-control';
    return $args;
}

This adds Bootstrap’s form-control class alongside WooCommerce’s own classes instead of replacing them. It applies to every field WooCommerce prints with woocommerce_form_field(), so the address fields in My Account get it too, not only checkout.

View or fork this snippet on GitHub Gist.

Want this checked on your own site? See Exivon Tech’s Website & E-commerce Audit.

Dhiren Patel

Principal Full-Stack Engineer · Founder, Exivon Tech

I’ve built and run enterprise web platforms and e-commerce for 13 years, and I built ShieldScope, a free WordPress security scanner.

2 responses to “Add Bootstrap Class to WooCommerce Checkout Fields”

  1. Alex

    https://www.dhirenpatel.me/wc-checkout-bootstrap/
    On the page it says “add below filter to functions.php…” but there no filter shown below or above.

  2. Dhiren Patel

    Hey Alex,

    Sorry, the embedded code was lost due to issue with WP plugin which I have used. I have embedded the code again.
    Hope it helps.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.