2015-10-25 163 views
0

自定义字段需要添加到订单备注时的订单。我可以更新本公司及订单详细信息页面管理,航运下的字段的详细信息称为Woocommerce更新order_comments下订单后

“客户提供的说明”被称为在“order_comments”关于使用

update_post_meta($order_id, '_billing_company', $_companyName); 

追加到末尾的数字结帐页面。

在订单详情页面上,它被称为“摘录”以及“post_excerpt”。 如果我使用update_post_meta($order_id, 'post_excerpt', $_urn); 该字段未更新。我也尝试过摘录和order_comments,我无法更新此字段。

任何想法?

+0

update_post_meta($ order_id,'post_excerpt',$ _urn);确实创建了一个自定义字段,但我需要更新order_comment –

回答

1

将“客户提供的备注”存储为post_excerpt,并在order post_type上备份WC_Order。要更新它,您可以使用标准的WordPress Codex或wc_update_order()函数(它实际上是WordPress Codex的前端,但可能是正确的方法)。

// specify the order_id so WooCommerce knows which to update 
$order_data = array(
    'order_id' => $order_id, 
    'customer_note' => 'The customer note.' 
); 
// update the customer_note on the order 
wc_update_order($order_data); 
+0

感谢您的意见,非常感谢。这不幸更新订单注释,我需要客户提供商注意更新,位于运输详细信息 –

+0

@RobertWilde对不起,我误解了你的问题。更改了答案以显示如何更新正确的值。 – doublesharp

+0

非常感谢。我不知道为什么这么难找到 –