Skip to content

Instantly share code, notes, and snippets.

@kartick14
Created October 11, 2018 12:22
Show Gist options
  • Save kartick14/f0f932295a174215fa1412c1c74b7ab6 to your computer and use it in GitHub Desktop.
Save kartick14/f0f932295a174215fa1412c1c74b7ab6 to your computer and use it in GitHub Desktop.
woocommerce checkout page call action when place order is trigger
add_action('woocommerce_after_checkout_validation', 'rei_after_checkout_validation');
function rei_after_checkout_validation( $posted ) {
// do all your logics here...
// adding wc_add_notice with a second parameter of "error" will stop the form...
// wc_add_notice( __( "OMG! You're not human!", 'woocommerce' ), 'error' );
if (empty($_POST['captcha'])) {
wc_add_notice( __( "Captcha is empty!", 'woocommerce' ), 'error' );
}
}
Structure $posted array =>
Array
(
[terms] => 0
[createaccount] => 0
[payment_method] => cheque
[shipping_method] =>
[ship_to_different_address] =>
[billing_first_name] =>
[billing_last_name] =>
[billing_company] =>
[billing_email] => [email protected]
[billing_phone] =>
[billing_country] => PH
[billing_address_1] =>
[billing_address_2] =>
[billing_city] =>
[billing_state] =>
[billing_postcode] =>
[order_comments] =>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment