Skip to content

Instantly share code, notes, and snippets.

@becomevocal
Created June 20, 2019 22:37
Show Gist options
  • Save becomevocal/601f21c20c0e432a342bfe0f12e8a79e to your computer and use it in GitHub Desktop.
Save becomevocal/601f21c20c0e432a342bfe0f12e8a79e to your computer and use it in GitHub Desktop.
BC4WP: GeoIP Channel Activation
add_filter( 'bigcommerce/channels/enable-multi-channel', '__return_true' );
if (function_exists('geoip_detect2_get_info_from_current_ip')) {
$userInfo = geoip_detect2_get_info_from_current_ip();
if ($userInfo->country->isoCode == 'FR') {
add_filter( 'bigcommerce/channel/current', function( $channel ) {
// logic to set the channel
return get_term( 41, \BigCommerce\Taxonomies\Channel\Channel::NAME );
}, 10, 1 );
add_filter( 'pre_option_' . 'bigcommerce_currency_code', function() {
return 'EUR';
}, 10, 0 );
add_filter( 'pre_option_bigcommerce_currency_symbol', function() {
return '€';
}, 10, 0 );
// also, pre_option_bigcommerce_currency_symbol_position, pre_option_bigcommerce_integer_units, pre_option_bigcommerce_decimal_units
}
} else {
echo '<!-- Warning: The plugin GeoIP Detection is not active. -->';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment