我正在尝试将列产品列表添加到管理订单页面。
就像图片上的东西:
最佳答案
当前版本的 WooCommerce,没有简单的方法。
这是负责该部分的代码。
<tbody id="order_line_items">
<?php
foreach ( $line_items as $item_id => $item ) {
do_action( 'woocommerce_before_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
include( 'html-order-item.php' );
do_action( 'woocommerce_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
}
do_action( 'woocommerce_admin_order_items_after_line_items', $order->get_id() );
?>
</tbody>
特别是这一行:include('html-order-item.php');
。
如果您查看 html-order-item.php
的内容,您会发现没有任何钩子(Hook)可以让您添加另一个 td
。
我可以建议你在 foreach
循环中使用上面的两个操作之一。使用它来将 td
标记与您的数据一起放置。
然后使用 jQuery 将 td
传输到它应该在的位置。
关于php - WooCommerce - 如何将列添加到管理订单页面中的产品列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49505736/