Skip to content

Instantly share code, notes, and snippets.

@gareth-gillman
Created February 5, 2019 16:28
Show Gist options
  • Save gareth-gillman/0cffe27dc43ab43001b31e391ff14530 to your computer and use it in GitHub Desktop.
Save gareth-gillman/0cffe27dc43ab43001b31e391ff14530 to your computer and use it in GitHub Desktop.
Woo Checkout Spam
function wcs_checkout_field( $checkout ) {
woocommerce_form_field(
'wcs_buyer_gift',
array(
'type' => 'text',
'class' => array('wcs-field form-row-wide'),
),
$checkout->get_value( 'wcs_buyer_gift' )
);
}
add_action( 'woocommerce_after_order_notes', 'wcs_checkout_field' );
function wcs_checkout_field_process() {
if ( !empty( $_POST['wcs_buyer_gift'] ) ) {
wc_add_notice( __( 'Unable to submit order, please contact our support.' ), 'error' );
}
}
add_action('woocommerce_checkout_process', 'wcs_checkout_field_process');
function wcs_header_css() {
echo '<style>.wcs-field {display:none;}</style>';
}
add_filter('wp_head', 'wcs_header_css', 9999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment