Created
June 18, 2019 23:56
-
-
Save karen-white/9b5c804aa60b08a430225dce20e1fec3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: BC4WP: GeoIP Region Activation | |
* Plugin URI: http://www.bigcommerce.com/wordpress | |
* Description: Proof of concept for region activation by GeoIP | |
* Version: 0.5 | |
* Author: BigCommerce | |
* Author URI: http://www.bigcommerce.com | |
*/ | |
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