-
-
Save Dudikowski/f53b4e7ed4251dd90400d1f1ea94c65c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Billing fields woocommerce checkout | |
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); | |
function custom_override_checkout_fields( $fields ) { | |
unset($fields['billing']['billing_company']); | |
unset($fields['billing']['billing_address_2']); | |
unset($fields['billing']['billing_country']); | |
unset($fields['billing']['billing_state']); | |
// Setting placeholder texts | |
$fields['billing']['billing_first_name']['required'] = true; | |
$fields['billing']['billing_first_name']['placeholder'] = "Förnamn"; | |
$fields['billing']['billing_last_name']['required'] = true; | |
$fields['billing']['billing_last_name']['placeholder'] = "Efternamn"; | |
$fields['billing']['billing_address_1']['required'] = true; | |
$fields['billing']['billing_address_1']['placeholder'] = "Adress"; | |
$fields['billing']['billing_city']['required'] = true; | |
$fields['billing']['billing_city']['placeholder'] = "Stad"; | |
$fields['billing']['billing_postcode']['required'] = true; | |
$fields['billing']['billing_postcode']['placeholder'] = "Postnummer"; | |
$fields['billing']['billing_phone']['required'] = true; | |
$fields['billing']['billing_phone']['placeholder'] = "Telefon"; | |
$fields['billing']['billing_email']['placeholder'] = "E-post"; | |
$fields['billing']['billing_email']['required'] = true; | |
// Comments are required | |
$fields['order']['order_comments']['required'] = true; | |
return $fields; | |
} | |
// Hide order comments if no coupon is used | |
add_action( 'woocommerce_before_checkout_form' , 'product_checkout_custom_content' ); | |
function product_checkout_custom_content() { | |
global $woocommerce; | |
$msgs = array('mycouponcode'=>''); | |
$applied_coupon = $woocommerce->cart->applied_coupons; | |
if( ! array_key_exists($applied_coupon[0], $msgs) ) { | |
// Hide order comments | |
unset( $fields['order']['order_comments'] ); | |
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' ); | |
$fields['order']['order_comments']['required'] = false; | |
return $fields; | |
// echo $msgs[$applied_coupon[0]]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment