Custom Fields location
-
Hello, thank you for this great plugin! I am hoping you could help me with a challenge I am facing.
I have added the code below to move the custom fields within the billing address details. However, when I test, the fields show both above the billing address as well as within the billing details. Is there a way to only show them within the billing details on both the checkout page and emails? Here are screenshots of the issue:
https://drive.google.com/file/d/1iB7i-t7bxr1K_4Z–HS04v5-7u0aYdhT/view?usp=sharing
https://drive.google.com/file/d/1uO2cBn6Ido3_TXbnQUhqxYcZ5Wz18zF_/view?usp=sharing//Order Billing Fields add_filter( 'woocommerce_order_formatted_billing_address' , 'th56t_woo_custom_order_formatted_billing_address', 10, 2 ); function th56t_woo_custom_order_formatted_billing_address( $address, $WC_Order ) { $address['billing_title'] = get_post_meta( $WC_Order->get_id(), 'billing_title', true ); $address['additional_sector'] = get_post_meta( $WC_Order->get_id(), 'additional_sector', true ); $address['additional_other'] = get_post_meta( $WC_Order->get_id(), 'additional_other', true ); return $address; } add_filter( 'woocommerce_formatted_address_replacements', function( $replacements, $args ){ $replacements['{billing_title}'] = isset($args['billing_title']) ? $args['billing_title'] : ''; $replacements['{additional_sector}'] = isset($args['additional_sector']) ? $args['additional_sector'] : ''; $replacements['{additional_other}'] = isset($args['additional_other']) ? $args['additional_other'] : ''; return $replacements; }, 10, 2 ); add_filter( 'woocommerce_localisation_address_formats' , 'woo_includes_address_formats', 10, 1); function woo_includes_address_formats($address_formats) { $address_formats['default'] = "{company}\n{name}\n{billing_title}\n{address_1}\n{address_2}\n{city}\n{state}\n{postcode}\n{country}\n{additional_sector}{additional_other}"; // default address format // Add your country address format here return $address_formats; }
Also, is there a way I could add labels before each billing fields? I.e. it would say
Company: {company}
Name: {name}
Title: {billing_title}
etc.Thank you in advance!
- The topic ‘Custom Fields location’ is closed to new replies.