Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.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/3/html/77.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_Html_Wordpress_Email_Woocommerce - Fatal编程技术网

Php WooCommerce-创建订单时发送电子邮件

Php WooCommerce-创建订单时发送电子邮件,php,html,wordpress,email,woocommerce,Php,Html,Wordpress,Email,Woocommerce,我试图在下单时向多个电子邮件地址发送电子邮件。我正在使用woocommerce\u thankyouhook。但电子邮件根本不发送 add_action( 'woocommerce_thankyou', function( $order_id ){ $order = new WC_Order( $order_id ); $paymentType = $order->payment_method_title; $firstName = $order->billi

我试图在下单时向多个电子邮件地址发送电子邮件。我正在使用woocommerce\u thankyouhook。但电子邮件根本不发送

add_action( 'woocommerce_thankyou', function( $order_id ){
    $order = new WC_Order( $order_id );
    $paymentType = $order->payment_method_title;
    $firstName = $order->billing_first_name;
    $lastName = $order->billing_last_name;
    $billing_address = $order->billing_address_1;
    $billing_address2 = $order->billing_address_2;
    $billing_postcode = $order->billing_postcode;
    $billing_city = $order->billing_city;
    $billing_country = $order->billing_country;
    $billing_email = $order->billing_email;
    $billing_phone = $order->billing_phone;
    $totalRefunded = $order->get_total_refunded();
    $totalTaxRefunded = $order->get_total_tax_refunded();
    $totalShippingRefunded = $order->get_total_shipping_refunded();
    $total = $order->get_order_currency() . $order->get_total();
    $notes = $order->get_customer_order_notes();
    $company = $order->billing_company;
    $orderItems = $order->get_items();
    $subject = 'Order ' . $order_id . ' was placed';

    $message = '';
    $message .= "Payment Type: $paymentType<br>";
    $message .= "First Name: $firstName<br>";
    $message .= "Last Name: $lastName<br>";
    $message .= "Adress1: $billing_address<br>";
    $message .= "Adress2: $billing_address2<br>";
    $message .= "Post Code: $billing_postcode<br>";
    $message .= "City: $billing_city<br>";
    $message .= "Country: $billing_country<br>";
    $message .= "Email: $billing_email<br>";
    $message .= "Phone: $billing_phone<br>";
    $message .= "Total Refunded: $totalRefunded<br>";
    $message .= "Total Tax Refunded: $totalTaxRefunded<br>";
    $message .= "Company: $company<br>";
    $message .= "Order Notes: $notes->post_excerpt<br>";
    $message .= "Total Shipping Refunded: $totalShippingRefunded<br><br>";
    foreach($orderItems as $product) {
        $message .= $product['name'] . ' x' . $product['qty'] . '<br>'; 
    }
    $message .= "<br>Total: $total";
    $headers  = "Content-type: text/html; charset=windows-1251 \r\n";
    $headers .= 'From: post@test.com' . "\r\n" .
    "Reply-To: $billing_email" . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    mail(get_option('ordemails'), $subject, $message, $headers);
});
add_action('woocommerce_thankyou',函数($order_id){
$order=新WC\U订单($order\U id);
$paymentType=$order->payment\u方法\u标题;
$firstName=$order->billing\u first\u name;
$lastName=$order->billing\u last\u name;
$billing\u address=$order->billing\u address\u 1;
$billing\u address2=$order->billing\u address2;
$billing_postcode=$order->billing_postcode;
$billing\u city=$order->billing\u city;
$billing\u country=$order->billing\u country;
$billing\u email=$order->billing\u email;
$billing\u phone=$order->billing\u phone;
$totalreturned=$order->get_total_returned();
$totaltaxreturned=$order->get_total_tax_returned();
$TotalShippingReturned=$order->get_total_shipping_Returned();
$total=$order->get_order\u currency()。$order->get_total();
$notes=$order->get_customer_order_notes();
$company=$order->billing\u company;
$orderItems=$order->get_items();
$subject='Order'.$Order_id.'wasted';
$message='';
$message.=“付款类型:$paymentType
”; $message.=“名字:$firstName
”; $message.=“姓氏:$lastName
”; $message.=“地址1:$billing_地址
”; $message.=“地址2:$billing_address2
”; $message.=“邮政编码:$billing_邮政编码
”; $message.=“城市:$billing_City
”; $message.=“国家:$billing_Country
”; $message.=“电子邮件:$billing_Email
”; $message.=“电话:$billing_Phone
”; $message.=“退款总额:$totalreturned
”; $message.=“退税总额:$totaltaxreturned
”; $message.=“公司:$Company
”; $message.=“订单注释:$Notes->post_摘录
”; $message.=“已退款的发货总额:$TotalShippingReturned

”; foreach($orderItems作为$product){ $message.=$product['name'].x.$product['qty'].
; } $message.=“
总计:$Total”; $headers=“内容类型:text/html;charset=windows-1251\r\n”; $headers.='来自:post@test.com“。”\r\n”。 “回复:$billing\u电子邮件”。\r\n”。 'X-Mailer:PHP/'.phpversion(); 邮件(获取选项('ordemails'),$subject,$message,$headers); });

get\u选项('ordemails')
是一个字符串,其中包含以逗号分隔的电子邮件地址(test@test.com, test2@test.com)

get\u选项('ordemails')
由您添加。是,它返回字符串'email@test.com,emailtwo@test.com“好的。!我只是怀疑它的
ordermails
ordermails
是否有其他woocommerce和wordpress电子邮件从您的网站发送出去?您尝试过wp_mail()函数吗?