You just gave me two books to read that were written in Japanese. Problem is, I don’t speak Japanese.
Could you narrow it down for me please? There’s a lot of information in the two links you provided me with and I don’t know what specifically you’re referring to.
I just want to add a third address line/field.
I don’t understand what to do. It looks like I’m supposed to add code into my functions.php file but I don’t know what code I’m supposed to use for my situation specifically, as the code seems tailored to that person’s situation.
It’s weird that the premium version doesn’t allow me to just add an extra address field and have it display in the proper place on the checkout form, emails etc. I would gladly pay for this and it seems like a very basic feature for a plugin whose sole purpose is to edit the checkout form.
WordPress forum is supposed to be for the users who are using the free version of our plugin. Since you are using the premium version of our plugin, please raise a ticket through our website. As per the WordPress forum policy, we can’t answer premium related questions on this forum. We hope our technical team will be able to help you.
Thank you!
I am using the free version. I was just saying that I would pay for the premium version if it fixed this problem I’m having.
It seems odd that a plugin designed to let people edit the checkout form isn’t able to add a third address line/field.
There’s no simple way to tell me how to do this?
Unfortunately, there is no direct option available in the lite version of our plugin to show the custom field along with the default address field. For this, you need to add custom code.
Can you please try adding the below code in your active theme’s functiosn.php file?
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_address3'] = get_post_meta( $WC_Order->get_id(), 'billing_address3', true );
return $address;
}
add_filter( 'woocommerce_formatted_address_replacements', function( $replacements, $args ){
$replacements['{billing_address3}'] = isset($args['billing_address3']) ? $args['billing_address3'] : '';
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['ES'] = "{name}\n{company}\n{address_1}\n{address_2}\n{billing_address3}\n{city}\n{state}\n{postcode}\n{country}"; // Address format for Spain
$address_formats['IN'] = "{name}\n{company}\n{address_1}\n{address_2}\n{billing_address3}\n{city}\n{state}\n{postcode}\n{country}"; // Address format for India
$address_formats['default'] = "{name}\n{company}\n{address_1}\n{address_2}\n{billing_address3}\n{city}\n{state}\n{postcode}\n{country}"; // default address format
// Add your country address format here
return $address_formats;
}
Here billing_address3 is the third address field. You need to rename it based on your field name.
We hope this helps.
Thank you!
Thank you. I added the code to my functions.php file, but when I clicked ‘Update File’ it gave me the following error:
Your PHP code changes were rolled back due to an error on line 181 of file wp-content/themes/astra/functions.php. Please fix and try saving again.
syntax error, unexpected ‘&’
Can you please raise a ticket through our website? We hope our technical team will be able to help you.
Thank you!
We have confirmed that the above code is working fine.
Thank you!