解決方案如果有人需要它。
我用woocommerce的「$ item_meta」數組捕獲gform數據。
foreach ($item_meta->meta as $arraydata => $arrayvalue)
{
if ( $arraydata == "_qty" ||
$arraydata == "_tax_class" ||
$arraydata == "_product_id" ||
$arraydata == "_gravity_forms_history" ||
// all values above are general and will be there in default customer email.
// below arraydata is from gravity form
$arraydata == "Total" ||
$arraydata == "Delivery charges")
{}
else
{
$string = preg_replace("/\d+\.\d+/", "", $arrayvalue[0]);
$string = str_replace('($)', '', $string);
// printing Filds : Value
echo $arraydata.": ".$string."<br>";
}
}
這將從gform返回字段的值與他們的值,除了那些在if條件中提到的那些。 preg_replace用於從價值中刪除產品價格,折扣價格和百分比,以及適用的稅金。對於e.g它將改變
Selected Product : Headphones ($25.45), Mouse ($15.00), Keyboard(with backlight) ($45.00)
Total Price : $85.45
Payment Gateway: Credit Card
到
Selected Product : Headphones , Mouse , Keyboard(with backlight)
Payment Gateway: Credit Card
文件中,這一切都發生將發送一封電子郵件,以通過WordPress的預先通知插件特定的電子郵件地址。