woocommerce_before_checkout_form
Fires before the form on the checkout page.
Usage
add_action( 'woocommerce_before_checkout_form', 'wp_kama_woocommerce_before_checkout_form_action' );
/**
* Function for `woocommerce_before_checkout_form` action-hook.
*
* @param $checkout
*
* @return void
*/
function wp_kama_woocommerce_before_checkout_form_action( $checkout ){
// action...
}
- $checkout
- An instance of WC_Checkout.
Examples
#1 Using the hook in WooCommerce 3.7.0
By default, the hook is declared in the form-checkout.php template, and the functionality listed below runs on it.
Output the login form
//../woocommerce/includes/wc-template-hooks.php:211 add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
Remove the action
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
Output the coupon form
// ../woocommerce/includes/wc-template-hooks.php:212 add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
Remove the action
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
Output all notices
// ../woocommerce/includes/wc-template-hooks.php:302 add_action( 'woocommerce_before_checkout_form', 'woocommerce_output_all_notices', 10 );
Remove the action
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_output_all_notices' );
Where the hook is called
woocommerce_before_checkout_form
woocommerce/templates/checkout/form-checkout.php 22
do_action( 'woocommerce_before_checkout_form', $checkout );
Where the hook is used in WooCommerce
woocommerce/includes/wc-template-hooks.php 221
add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
woocommerce/includes/wc-template-hooks.php 222
add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
woocommerce/includes/wc-template-hooks.php 325
add_action( 'woocommerce_before_checkout_form', 'woocommerce_output_all_notices', 10 );