Book Image

WooCommerce Cookbook

By : Patrick Rauland
Book Image

WooCommerce Cookbook

By: Patrick Rauland

Overview of this book

Table of Contents (17 chapters)
WooCommerce Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting a post code for correct taxation with the Local Pickup setting


If you're selling to people in different parts of the country or the world, you normally base the tax on the location of the customer. For that reason, you don't normally have to set your own zip code or city. But if you sell to people outside your city most of the time, but also have the Local Pickup shipping method selected, then you'll need to set your zip code and city.

How to do it…

This is an edge case, so there isn't any way to do this in the admin. You have to do this with some custom code, using the following steps:

  1. Open your theme's functions.php file, located under wp-content/themes/your-theme-name/, or create a custom WooCommerce plugin.

  2. At the bottom of the file, enter the following lines of code to set your city:

    add_filter( 'woocommerce_countries_base_city' , 'woocommerce_cookbook_countries_base_city' ); 
    function 'woocommerce_cookbook_countries_base_city'() { 
        // Replace with your store town/city 
        return...