Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

woocommerce_before_checkout_form

Fires at the top of the classic checkout page, before the checkout form. It doesn't fire with the Checkout block.

  • Type Action
  • From WooCommerce
  • Since 1.0.0
  • Fired in templates/checkout/form-checkout.php

When it fires

WooCommerce fires this action at the start of the classic checkout template (checkout/form-checkout.php), used by the [woocommerce_checkout] shortcode. WooCommerce hooks its own notices, the returning customer login form and the coupon form here, all at priority 10.

It doesn't run with the Checkout block, which is the default checkout for new stores. It only fires if your checkout page uses the shortcode or the Classic Checkout block.

Parameters

Parameters
$checkoutWC_Checkout The checkout object.

Example: Show a message above the checkout form

PHP
add_action( 'woocommerce_before_checkout_form', function () {
	wc_print_notice(
		__( 'Orders placed after 14:00 on Friday are dispatched on Monday.', 'my-snippets' ),
		'notice'
	);
}, 5 );

Good to know

  • Checkout block: this hook doesn't fire. Add a block with your message to the checkout page in the editor instead.
  • Use a priority below 10 to appear above WooCommerce's own notices and forms, or above 10 to appear below them.
  • The $checkout parameter was added in WooCommerce 2.0.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.