Documentation
GeoBlock Pro
Developer Reference

WindCodex GeoBlock Pro Developer Reference


Constants

ConstantValueDescription
GEOBLOCK_PRO_VERSIONe.g. '1.0.0'Current Pro plugin version
GEOBLOCK_PRO_PLUGIN_FILEabsolute pathMain plugin file
GEOBLOCK_PRO_PLUGIN_DIRabsolute pathPlugin directory (with trailing slash)
GEOBLOCK_PRO_PLUGIN_URLURLPlugin directory URL (with trailing slash)
GEOBLOCK_PRO_PLUGIN_BASErelative pathwindcodex-geoblock-pro/windcodex-geoblock-pro.php
GEOBLOCK_PRO_LICENSE_OPTION'wcgb_license_key'Option name for the license key
GEOBLOCK_PRO_LICENSE_STATUS_OPTION'wcgb_license_status'Option name for the license status

Filters

geoblock_resolve_product_id

The same filter as in the free plugin. It lets you map a product ID to another one before GeoBlock reads its rules - the WPML integration uses it to point translated products at the original product.

add_filter( 'geoblock_resolve_product_id', function ( int $product_id ): int {
    return $product_id;
} );

GeoBlock Pro also hooks the standard WooCommerce filters woocommerce_product_is_visible, woocommerce_is_purchasable and woocommerce_available_payment_gateways at priority 10. Hook in at a later priority to override its decisions.


Options

geoblock_settings

Shared with the free plugin, plus Pro keys:

array(
    'restriction_mode'    => 'hide',        // 'hide' | 'catalog_only' | 'message'
    'message_position'    => 'after_title', // 'before_title' | 'after_title' | 'after_price' | 'after_cart'
    'force_geolocation'   => 'no',
    'redirect_enabled'    => 'no',
    'redirect_url'        => '',
    'custom_message'      => 'Sorry, ...',
    'catalog_purchasable' => 'no',
    'debug_mode'          => 'no',
    'analytics_enabled'   => 'no',          // Pro
    'bulk_rules'          => array(),       // Pro - see below
    'payment_rules'       => array(),       // Pro - see below
)

Bulk rule:

array(
    'enabled'    => 'yes',
    'type'       => 'categories',           // 'categories' | 'tags' | 'attributes' | 'global'
    'mode'       => 'exclude',              // 'include' | 'exclude'
    'countries'  => array( 'US', 'CA' ),
    'categories' => array( 15, 22 ),        // term_taxonomy IDs (or 'tags' / 'attributes'; 'global' => 'yes')
)

Payment rule:

array(
    'enabled'     => 'yes',
    'restrict_by' => 'billing',             // 'billing' | 'shipping'
    'methods'     => array( 'cod' ),        // WooCommerce gateway IDs, e.g. 'cod', 'bacs', 'ppcp-gateway'
    'mode'        => 'exclude',             // 'include' | 'exclude'
    'countries'   => array( 'IN' ),
)

Rules without countries are discarded when saved.

Other options

OptionDescription
geoblock_pro_versionVersion saved on the last activation
wcgb_license_keyLicense key (stored as entered)
wcgb_license_statusactive or inactive

Post Meta Keys

Meta KeyStored onFormat
_geoblock_rulesProduct`array( 'mode' => 'include'
_geoblock_variation_rulesEach variationSame format as _geoblock_rules

An empty country list deletes the meta key rather than storing an empty rule.


Analytics Table

Events are written to {prefix}geoblock_analytics when Analytics Logging is on. See Analytics for the columns.

Analytics queries are cached in the WordPress object cache (group-based keys) for 5 minutes. New events clear the cache automatically.


PHP API

The restriction engine can be used from your own code once GeoBlock Pro has loaded:

$restrictions = new GeoBlock_Pro_Restrictions( new GeoBlock_Pro_Geolocation() );
 
// Restricted for the current visitor? (product or variation ID, or WC_Product)
$restrictions->is_restricted( $product_id );
 
// Restricted for a specific country?
$restrictions->is_restricted_for_country( $product_id, 'DE' );
 
// Is a payment method restricted for a country? Returns the matching rule context or null.
$restrictions->test_payment_method_for_country( 'DE', 'cod', 'billing' );