0

在使用以下代码在订单页面详细信息中添加自定义列后,我无法检索测量“体积”的值:

// Add custom column headers
add_action(
  'woocommerce_admin_order_item_headers',
  'my_woocommerce_admin_order_item_headers');

function my_woocommerce_admin_order_item_headers() {

  //column name
  $column_name = 'Total M3';

  // display the column name
  echo '<th>' . $column_name . '</th>';
}

// Add custom column values here
add_action(
  'woocommerce_admin_order_item_values', 
  'my_woocommerce_admin_order_item_values',
  10, 
  3);

function my_woocommerce_admin_order_item_values($_product, $item, $item_id = null) {

  // get the post meta value from the associated product
  $value = get_post_meta($_product->post->ID, '_custom_field_name', 1);

  // display the value
  echo '<td>' . $value . '</td>';
}

我正在使用WooCommerce 测量价格计算器插件来计算测量值。我找不到元值。

4

0 回答 0