WooCommerce:将成员分配到送货区

WooCommerce : assign member to shipping zone

有没有办法为会员指定配送区域?

我想这样做是因为我将 WooCommerce 用于食​​品配送网站,并且我需要在有人下订单时向最近的餐厅发送电子邮件

我正在考虑在送货区 table 添加一个电子邮件字段,如下所示(抱歉,我的管理面板是法语的)

有什么想法吗?

更新 (2019) - 您应该以不同的方式使用 woocommerce_email_recipient_new_order 根据送货区域添加特定的电子邮件收件人:

add_filter( 'woocommerce_email_recipient_new_order', 'custom_email_recipient_new_order', 10, 2 );
function custom_email_recipient_new_order( $recipient, $order ) {
    // Avoiding backend displayed error in Woocommerce email settings
    if ( ! is_a( $order, 'WC_Order' ) ) 
        return $recipient;

    // Get the shipping country and postcode
    $country_code = $order->get_shipping_country();
    $postcode     = $order->get_shipping_postcode();

    // Get All Zone IDs
    $zone_ids    = array_keys( array('') + WC_Shipping_Zones::get_zones() );

    // Loop through Zone IDs
    foreach ( $zone_ids as $zone_id ) {
        // Get the shipping Zone object
        $shipping_zone = new WC_Shipping_Zone($zone_id);

        // Loop through Zone locations
        foreach ( $shipping_zone->get_zone_locations() as $location ){
            if ( ( $location->type === 'postcode' && $location->code === $postcode ) 
            || ( $location->type === 'country' && $location->code === $country_code ) ) {
                $the_zone_id   = $zone_id;
                $the_zone_name = $shipping_zone->get_zone_name(); // (You can use the the zone name too)
                break;
            } 
        }
        if($found) break;
    }

    if( $the_zone_id == 0 ) {
        $recipient .= ',' . 'james.collins@gmail.com';
    } elseif( $the_zone_id == 2 ) {
        $recipient .= ',' . 'jean.dubreuil@gmail.com';
    } elseif( $the_zone_id == 3 ) {
        $recipient .= ',' . 'joel.chalamousse@gmail.com';
    } else {
        $recipient .= ',' . 'isabelle.frottin@gmail.com';
    }

    return $recipient;
}

代码进入您的活动子主题(或活动主题)的 function.php 文件。它应该有效。