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.
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
$checkoutWC_Checkout |
The checkout object. |
|---|
Example: Show a message above the checkout form
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.