Useful PHP Functions – Country catalogs for WooCommerce

The following php functions can be helpful for you if you want to customize your theme to show/hide elements based on the user location used by our plugin. You can use this to add sections to your homepage, header, footer, show/hide popups, or make any code customizations that you want.

wcacr_get_user_country() will return the country code of the user in 2 letters (ie. CA, US, ES) or the state/province of the user.

vcwccr_shop_is_available() will return boolean if the products are restricted globally. For example, if you restrict all products in our settings page to be visible for US, it will return false when someone from CA is viewing the site and true if it’s someone from the US.

vcwccr_is_restricted($product_id) will return boolean if the country of the current user is allowed to view the product.

vcwccr_is_restricted($category_id, ‘category’) will return boolean if the country of the user is allowed to view the category.