Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.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设置客户提供的注释也返回html标记_Php_Html_Wordpress_Woocommerce - Fatal编程技术网

Php Woocommerce设置客户提供的注释也返回html标记

Php Woocommerce设置客户提供的注释也返回html标记,php,html,wordpress,woocommerce,Php,Html,Wordpress,Woocommerce,我正在对客户提供的备忘和客户订购备忘进行一些更改。这是我的密码 add_action( 'woocommerce_checkout_update_order_meta', 'dvs_add_tm_data_order_note' ); function dvs_add_tm_data_order_note($order_id) { $options = THEMECOMPLETE_EPO_API()->get_option( $order_id ,'all' ); fore

我正在对客户提供的备忘和客户订购备忘进行一些更改。这是我的密码

add_action( 'woocommerce_checkout_update_order_meta', 'dvs_add_tm_data_order_note' );
function dvs_add_tm_data_order_note($order_id) {
    $options = THEMECOMPLETE_EPO_API()->get_option( $order_id ,'all' );
    foreach ($options as $item_id => $epos){
        $item = new WC_Order_Item_Product($item_id);
        $product = $item->get_product();
        $output .= "<br><strong>{$product->get_name()}</strong><br>";
        foreach ($epos as $epo){
            $output .= '<i> -- '. $epo['name'] .' : </i>'. $epo['value'] . "<br>";  
        }
    }
    $order = new WC_Order($order_id);
    $output .= "<br><strong>Customer Details</strong><br>";
    $output .= "Name: {$order->get_billing_first_name()}<br>";
    $output .= "Phone: <a href='tel:92{$order->get_billing_phone()}'>{$order->get_billing_phone()}</a><br>";
    $output .= "Address: {$order->get_billing_address_1()}<br>";
    $output .= "City: {$order->get_billing_city()}<br>";
    $output .= "Total: {$order->get_formatted_order_total()}<br>";
    $output .= "Payment: {$order->get_payment_method_title()}<br>";
    $order->add_order_note( $output );
    $order->set_customer_note( $output );
    $order->save();
}
add_操作('woocommerce_checkout_update_order_meta'、'dvs_add_tm_data_order_note');
功能dvs\U添加\U tm\U数据\U订单\U备注($order\U id){
$options=THEMECOMPLETE_EPO_API()->get_选项($order_id,'all');
foreach($item\u id=>$epos的选项){
$item=新WC\u订单\u item\u产品($item\u id);
$product=$item->get_product();
$output.=“
{$product->get_name()}
”; foreach($epo作为$epo){ $output.=''-'.$epo['name'].:'.$epo['value'].“
”; } } $order=新WC\U订单($order\U id); $output.=“
客户详细信息
”; $output.=“名称:{$order->get_billing_first_Name()}
”; $output.=“电话:
”; $output.=“地址:{$order->get_billing_Address_1()}
”; $output.=“城市:{$order->get_billing_City()}
”; $output.=“总计:{$order->get_-formatted_-order_-Total()}
”; $output.=“付款:{$order->get_Payment_method_title()}
”; $order->添加订单注释($output); $order->set\u customer\u note($output); $order->save(); }
输出工作正常

但它在客户提供的注释中也返回html标记

如何解决这个问题?
关于

由于Woocommerce 3,您无法从
WC\u Order
对象访问更多属性。您需要使用
WC\u Order
方法
get\u customer\u note()

您的问题是将HTML代码编码为HTML实体,必须使用PHP函数将其解码为常规HTML并打印解码字符串


我希望这将帮助您理解您的问题。

您能提供钩子或更好的解释,说明您在哪里回显(打印)此HTML吗?我知道原因,但想用代码更好地解释一下,你必须显示消息。先生,问题是html标记在订单->备注中工作,但在客户->备注中不工作。你是否尝试使用
$order->get_customer_note()?更新您的问题并向我们显示打印代码。
// Get the note
$customer_note = $order->get_customer_note();
// decode entity to regular HTML
$customer_note = html_entity_decode($customer_note);
// Print somwhere
echo $customer_note;