根据订单内容更改 woocommerce 客户电子邮件的回复地址

找到以下代码;不确定是否可以调整它以根据订单项目或项目类别更改所有 Woocommerce 客户电子邮件的回复地址或发件人地址。


// Utility function to get the shipping method Id from order object
function wc_get_shipping_method_id( $order ){
    foreach ( $order->get_shipping_methods() as $shipping_method ) {
        return $shipping_method->get_method_id();
    }
}

// Add coditionally a "reply to" based on shipping methods IDs for specific email notifications
add_filter( 'woocommerce_email_headers','add_headers_replay_to_conditionally',10,3 );
function add_headers_replay_to_conditionally( $headers,$email_id,$order ) {
    // Avoiding errors
    if ( ! is_a( $order,'WC_Order' ) || ! isset( $email_id ) )
        return $headers;

    // The defined emails notifications to customer
    $allowed_email_ids = array('customer_on_hold_order','customer_processing_order','customer_completed_order');

    // Only for specific email notifications to the customer
    if( in_array( $email_id,$allowed_email_ids ) ) {
        // Local Pickup Plus shipping method
        if( wc_get_shipping_method_id( $order ) === 'local_pickup_plus' ){
            $headers .= "Reply-to: reply1@webshop.com". "\r\n"; // Email adress 1
        } 
        // Other shipping methods
        else {
            $headers .= "Reply-to: reply2@webshop.com". "\r\n"; // Email adress 2
        }
    }

    return $headers;
} 

在这种情况下 get_product_id 会起作用吗?是否可以使用产品类别代替?这里最好的方法是什么?

function wc_get_product_id( $order ){
    foreach ( $order->get_product_id(); as $product_id ) {
        return $product_id->get_method_id();
    } 
}

        if( wc_get_product_id( $order ) === ‘22928’ ){

yongyuanxingfupingan 回答:根据订单内容更改 woocommerce 客户电子邮件的回复地址

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/4111.html

大家都在问