Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WooCommerce电子邮件通知-根据订单计费位置更改页脚内容_Php_Wordpress_Email_Woocommerce - Fatal编程技术网

Php WooCommerce电子邮件通知-根据订单计费位置更改页脚内容

Php WooCommerce电子邮件通知-根据订单计费位置更改页脚内容,php,wordpress,email,woocommerce,Php,Wordpress,Email,Woocommerce,我正在尝试根据当前订单的计费位置更改WooCommerce通知电子邮件中的电子邮件页脚内容。原因是,如果订单来自新西兰、澳大利亚或欧洲,我需要显示不同的分销商业务详细信息 我有一个存储用户当前区域的cookie。这是使用此服务设置的: functions.php文件代码: add_action( 'init', 'location_setcookies' ); function gng_setcookies() { if(isset($_COOKIE['country_set'])) {

我正在尝试根据当前订单的计费位置更改WooCommerce通知电子邮件中的电子邮件页脚内容。原因是,如果订单来自新西兰、澳大利亚或欧洲,我需要显示不同的分销商业务详细信息

我有一个存储用户当前区域的cookie。这是使用此服务设置的:

functions.php文件代码:

add_action( 'init', 'location_setcookies' );
function gng_setcookies() {

if(isset($_COOKIE['country_set'])) {
    $country_set = $_COOKIE['country_set'];

    if($country_set == true) {

        $cur_country = $_COOKIE['cur_country'];
        $cur_region = $_COOKIE['cur_region'];

    }

} else {

    $country = file_get_contents("http://ipinfo.io/{$_SERVER['REMOTE_ADDR']}/country");
    $cur_country = trim($country);

    setcookie( 'country_set', 'false', time() + 3600, COOKIEPATH, COOKIE_DOMAIN );

    if($cur_country == "NZ") {
        setcookie( 'cur_country', $cur_country, time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
        setcookie( 'cur_region', 'NZ', time() + 3600, COOKIEPATH, COOKIE_DOMAIN ); 
        $cur_region = "NZ";
    } elseif ($cur_country == "AU") {
        setcookie( 'cur_country', $cur_country, time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
        setcookie( 'cur_region', 'AU', time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
        $cur_region = "AU";
    } elseif ($cur_country == "AT" || "BE" || "BG" || "CY" || "CZ" || "DK" || "EE" || "FI" || "FR" || "DE" || "GR" || "HU" || "IE" || "IT" || "LV" || "LT" || "LU" || "MT" || "NL" || "PL" || "PT" || "RO" || "SK" || "SI" || "ES" || "SE" || "GB") {
        setcookie( 'cur_country', $cur_country, time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
        setcookie( 'cur_region', 'EU', time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
        $cur_region = "EU";
    } else {
        setcookie( 'cur_country', 'NZ', time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
        setcookie( 'cur_region', 'NULL', time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
        $cur_region = "NULL";
    }

}

 }

add_filter( 'cur_region_val', 'return_cur_region_val' );
function return_cur_region_val( $arg = '' ) {

if(isset($_COOKIE['country_set'])) {

    $cur_region = $_COOKIE['cur_region'];

    return $cur_region;

} else {

    $country = file_get_contents("http://ipinfo.io/{$_SERVER['REMOTE_ADDR']}/country");
    $cur_country = trim($country);

    if($cur_country == "NZ") {
        return "NZ";
    } elseif ($cur_country == "AU") {
        return "AU";
    } elseif ($cur_country == "AT" || "BE" || "BG" || "CY" || "CZ" || "DK" || "EE" || "FI" || "FR" || "DE" || "GR" || "HU" || "IE" || "IT" || "LV" || "LT" || "LU" || "MT" || "NL" || "PL" || "PT" || "RO" || "SK" || "SI" || "ES" || "SE" || "GB") {

        return "EU";
    } else {
        return  "NULL";
    }

} 

}
我已经尝试使用cookie值来确定应该显示哪些电子邮件页脚内容,但它没有按预期工作

email-footer.php代码:

$cur_region = apply_filters( 'cur_region_val', '' );

if($cur_region == 'NZ') {

    echo '<p>New Zealand Business Details</p>';

} elseif($cur_region == 'AU') {

    echo '<p>Australian Business Details</p>';

} elseif($cur_region == 'EU') {

    echo '<p>Europe Business Details</p>';

}
$cur_region=apply_过滤器('cur_region_val','');
如果($cur_region=='NZ'){
echo“新西兰业务详情”

; }elseif($cur_region=='AU'){ echo“澳大利亚商业详情”

; }elseif($cur_region=='EU'){ echo“欧洲业务详情”

; }
谁能给我指一下正确的方向吗。我假设我需要使用WooCommernce钩子或以某种方式使用order对象来检索当前订单的计费位置

编辑:我打算使用订单发货位置,但我认为最好使用订单计费位置或我的cookie值

谢谢