Tag: PHP

  • Resources on WordPress Override WooCommerce templates with a plugin

    Override WooCommerce templates with a plugin

    WooCommerce Templates WooCommerce has templates for everything including emails and provides developers an easy way override them. This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php. This is very useful when you build a custom or a child theme and you want to modify the way WooCommerce looks according to your needs. But in…

  • Get the visitor’s country by their IP

    Basically the code is something like this:   function check_contry(){ $ip = $_SERVER[“REMOTE_ADDR”]; if (filter_var(@$_SERVER[‘HTTP_X_FORWARDED_FOR’], FILTER_VALIDATE_IP))} $ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } if (filter_var(@$_SERVER[‘HTTP_CLIENT_IP’], FILTER_VALIDATE_IP)){ $ip = $_SERVER[‘HTTP_CLIENT_IP’]; } $ipdata = @json_decode(file_get_contents(“http://www.geoplugin.net/json.gp?ip=” . $ip)); return $ipdata->geoplugin_countryCode; } So we are using the GeoPlugin API to retrieve the Country code. You can also get the full country name,…