Woocommerce - 在订单页面显示产品摘录

Woocommerce - Display product excerpt in Orders page

我需要在“订单”页面中显示产品的摘录。我花了几个小时试图找到解决方案,但一无所获。

我已经展示了产品的图片和标题(感谢@helgatheviking 和这个 ),但我无法显示摘录。这是我的代码:

 <div id="order-column" class="my_account_orders">
   <div class="wrap">
     <?php
       foreach ( $customer_orders as $customer_order ) {
       $order = wc_get_order( );
       $order->populate( $customer_order );

       foreach( $order->get_items() as $item_id => $item ) {
           $product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
           $product->get_image();
           $product->get_title();             
       }         
       $item_count = $order->get_item_count();
   ?>
    <div class="orders-wrap">
      <div class="preview">
        <div class="image">
          <div class="image-wrap"><?php echo $product->get_image(); ?></div>
        </div>

    <div class="bottom">
      <div class="details">
        <h3 class="name"><a title="View Order" href="<?php echo $order->get_view_order_url(); ?>"><?php echo $product->get_title(); ?></a></h3>
        <h4 class="subtitle"><?php the_excerpt(); ?></h4>              
      </div>
    </div>

摘录应出现在 subtitle 中。 我已经检查并尝试了这些线程中的建议: Woocommerce - description in products page Adding a product description to the woocommerce cart page

这应该可以做到。 the_excerpt 只能与 the_post() 结合使用,因为它取决于全局 $post 对象。但这几乎重新组合了其中发生的事情。

<h4 class="subtitle"><?php echo apply_filters( 'the_excerpt', $product->post->post_excerpt ); ?></h4>

有点晚了,但总是在这里使用:

get_the_excerpt( $product->get_id() );

kat_indo 中的其他解决方案可以使用,但 WooCommerce 表示您永远不应直接访问产品数据。