• Hello,

    On the WooCommerce general settings page you can enter the store address. Is there an easy way to add this address to the bottom of the emails that are being sent by WooCommerce?

    Are there placeholders that can be added in the ‘Additional content’ box when you edit an email?

    I don’t really want to customize every single email template.

    Thanks
    JP

Viewing 10 replies - 1 through 10 (of 10 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @jpnl,

    Is there an easy way to add this address to the bottom of the emails that are being sent by WooCommerce?

    At the moment there isn’t an “easy way” to add the store address in email templates, meaning there’s no default option for that in WooCommerce settings, and customizing that would require a bit of additional coding. We don’t provide support for customizations but I found the following link that may interest you:

    https://wordpress.stackexchange.com/questions/319346/woocommerce-get-physical-store-address

    If you do require more help with the actual coding, we’d recommend hiring a developer or one of the customization experts listed at https://woocommerce.com/customizations/.

    Cheers.

    What about just going to WooCommerce > Settings > Emails, then scrolling down to the Footer Text box and putting the store address in there?

    If you don’t want to go that route, you could use the hook woocommerce_email_footer($email) in the functions.php of your child theme to programmatically add the store address to all the emails. If you search for “woocommerce email hook” you’ll find a number of tutorials that will get you there.

    It would take a few minutes to code it, but it would be easier than overriding and editing all the email templates.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    @linux4me2 is actually right. You can manually enter the store address in the footer text of the email template.


    Link to image: https://snipboard.io/RhgZL9.jpg

    If you update the store address in the settings this will not be reflected in the email template though and the footer will still show the old address. In that case, you’d need to act programmatically or manually change the address.

    Best.

    Thank you so much guys! I totally missed that Footer text box in the email settings screen. That setting is good enough for what I wanted.

    To Woo support staff, would it still be possible to add a feature requests to make the store address fields available as placeholders? Although you can type the details in the footer box, it’s better to pickup the details that have already been entered elsewhere in the settings.

    Thanks
    JP

    Hello,

    I understand what you are saying.

    In case you would like to post your ideas please visit: Ideas Board, which is where developers go to look for future plugin features and improvements.

    Also, if you would like more customization to your email templates, you can use a plugin like this:
    https://woocommerce.com/products/woocommerce-email-customizer/

    I hope this helps.

    Thanks, will do.

    Hi @jpnl,

    I couldn’t leave this alone. 🙂

    Here is a code snippet you can put in your child theme’s functions.php to add the store address placeholders (or others) to the footer text in WooCommerce > Settings > Emails:

    
    add_action( 'woocommerce_email_footer_text', 'addWCFooterPlaceholders', 10, 1 );
    function addWCFooterPlaceholders($footer_text){
        /*
            This function adds the following placeholders to the WooCommerce
            footer text:
            * {store_address}
            * {store_address_2} 
            * {store_city} 
            * {store_postcode} 
            * {store_country} 
            * {store_state}
        */
        // The main address pieces:
        $store_address     = get_option('woocommerce_store_address');
        $store_address_2   = get_option('woocommerce_store_address_2');
        $store_city        = get_option('woocommerce_store_city');
        $store_postcode    = get_option('woocommerce_store_postcode');
        
        // The country/state
        $store_raw_country = get_option('woocommerce_default_country');
        
        // Split the country/state
        $split_country = explode(":", $store_raw_country);
        
        // Country and state separated:
        $store_country = $split_country[0];
        $store_state   = $split_country[1];
        
        $search = array(
            '{store_address}', 
            '{store_address_2}', 
            '{store_city}', 
            '{store_postcode}', 
            '{store_country}', 
            '{store_state}'
        );
        $replace = array(
            $store_address, 
            $store_address_2, 
            $store_city, 
            $store_postcode, 
            $store_country, 
            $store_state
        );
        
        $footer_text = str_replace($search, $replace, $footer_text);
    
        return $footer_text;
    }
    

    It won’t add the available placeholders to the tooltip for the footer text, so I put them in as a comment in the code snippet.

    Once you’ve added the code snippet to your child theme’s functions.php, all you have to do is add the placeholders you want to use to the footer text box on the WooCommerce Email Settings page. I’ve tested it in WP 5.9.2 and WooCommerce 6.3.1, and it works with no errors.

    Hi there,

    Thanks for providing a workaround via the code snippet, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    @linux4me2 that worked, thank you so much !!!

    JP

    @jpnl you are welcome! I’m glad it worked for you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to add store address to emails?’ is closed to new replies.