全球$ woocommerce; 在wordpress my-ac-plugin.php 500错误

I need to add 'global $woocommerce;' in the wordpress my-ac-plugin.php to pull in the users country code for my caching but I'm getting a 500 error.

Does anyone know how I can do this, or any ideas what's wrong?

Here's my code...

if (!defined('WPINC')) {
exit('Do NOT access this file directly.');
}
function my_ac_plugin() 
{
$ac = $GLOBALS['comet_cache_advanced_cache']; 
$ac->addFilter('comet_cache_version_salt', 
'my_ac_version_salt_shaker');
}
function my_ac_version_salt_shaker($version_salt)
{

global $woocommerce;
$customer_country = $woocommerce->customer->get_country();
$version_salt .= $customer_country; 
geoip_close($gi);
return $version_salt;

}
my_ac_plugin(); 

Follow these steps to help in troubleshooting:

  1. Go FTP into your website
  2. Open the file named wp-config.php
  3. Find the line where you see define('WP_DEBUG', false);
  4. Change false to true and save the file

The next time you refresh the page you were getting an error on you should now see more descriptive error messages which will help in troubleshooting.