• Resolved thesadshow

    (@thesadshow)


    I’m trying to use this plugin to create a third address field where people can enter a buzzer code if they live in an apartment building. However, I’m making the third field exactly the same as the second default field and it’s not working the same as the second field.

    The new third field is showing as its own separate section, rather than being an extension of the address area. This isn’t a deal breaker, but would like a fix if there is one.

    What is a deal breaker however, is that the new third address field, when filled in by the customer, does not show in the normal area on order pages and emails. Instead, it gets shown in a completely different area on pages and emails that looks really out of place. When this field is filled in, I need it to show under the second address line.

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    You need to override the Address display format to include the new field along with billing fields.

    You can refer to any of the below links for more details:

    https://docs.wpovernight.com/woocommerce-print-address-labels/formatting-the-address/

    https://stackoverflow.com/questions/36837619/woocommerce-order-formatted-billing-address-reorder-and-custom-billing-field

    We hope this will help 🙂

    Thank you!

    Thread Starter thesadshow

    (@thesadshow)

    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.

    Plugin Author ThemeHigh

    (@themehigh)

    Thread Starter thesadshow

    (@thesadshow)

    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.

    Plugin Author ThemeHigh

    (@themehigh)

    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!

    Thread Starter thesadshow

    (@thesadshow)

    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?

    Plugin Author ThemeHigh

    (@themehigh)

    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!

    Thread Starter thesadshow

    (@thesadshow)

    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 ‘&’

    Plugin Author ThemeHigh

    (@themehigh)

    Can you please raise a ticket through our website? We hope our technical team will be able to help you.

    Thank you!

    Plugin Author ThemeHigh

    (@themehigh)

    We have confirmed that the above code is working fine.

    Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Third address field’ is closed to new replies.