Created
March 14, 2023 05:51
-
-
Save moxet/fe2f301355802814ee857e2588b4d4cb to your computer and use it in GitHub Desktop.
This file contains 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: Auto Pricing | |
* Plugin URI: https://www.softemblems.com | |
* Description: Display auto convert currency for woocommerce products based on user location. | |
* Version: 0.1 | |
* Text Domain: auto-pricing | |
* Author: Moxet Khan | |
* Author URI: https://www.moxetkhan.com | |
*/ | |
function auto_pricing($atts) { | |
$product = wc_get_product(get_the_ID()); | |
$thePrice = $product->get_price(); | |
$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) ); | |
echo "Estimate Price for ".$geoPlugin_array["geoplugin_countryName"]. " is <b>".$geoPlugin_array["geoplugin_currencyCode"]." ".round($geoPlugin_array["geoplugin_currencyConverter"]*$thePrice)."</b>"; | |
} | |
add_shortcode('auto-pricing', 'auto_pricing'); | |
add_action( 'woocommerce_single_product_summary', 'custom_text', 15 ); | |
function custom_text() { | |
$product = wc_get_product(get_the_ID()); | |
$thePrice = $product->get_price(); | |
$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) ); | |
echo "Estimate Price for ".$geoPlugin_array["geoplugin_countryName"]. " is <b>".$geoPlugin_array["geoplugin_currencyCode"]." ".round($geoPlugin_array["geoplugin_currencyConverter"]*$thePrice)."</b><br/><br/>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment