Documentation
GeoBlock
Shortcode

Shortcode

GeoBlock provides a shortcode that lets you display the restriction message anywhere on your site - inside page builder layouts, custom templates, or theme files.

[geoblock_product_message]

Renders the restriction message if the current visitor is restricted from the product. Outputs nothing if the visitor is not restricted or if no product can be determined.

Attributes

AttributeTypeDefaultDescription
idintegerCurrent productThe product ID to check. Omit to use the product currently in the loop or the current page's product.
classstring(empty)One or more additional CSS classes to add to the wrapper <div>. Multiple classes can be separated by spaces.

Examples

Basic usage on a product page or in the loop:

[geoblock_product_message]

Specify a product by ID:

[geoblock_product_message id="123"]

Add a custom CSS class:

[geoblock_product_message class="my-notice highlighted"]

Combined:

[geoblock_product_message id="456" class="geo-alert"]

Output

The shortcode renders a <div> with classes woocommerce-info geoblock-restriction-notice geoblock-shortcode-notice (plus any extra classes you provide):

<div class="woocommerce-info geoblock-restriction-notice geoblock-shortcode-notice" role="alert">
    Sorry, this product is not available in your country.
</div>

The message text depends on the active Restriction Mode:

ModeShortcode output
Catalog Only"This product is not available for purchase in your country."
MessageThe custom message entered in GeoBlock Settings → Restriction Message
HideEmpty - the product page is 404'd before the shortcode could render
💡

The shortcode is particularly useful with page builders (Elementor, Beaver Builder, Divi) where you want to place the restriction notice at a custom position in the product template.