Woocommerce - 在订单页面中显示产品摘录页面
我需要在订单页面中显示产品摘要。我花了几个小时试图找到一个解决方案,但没有。Woocommerce - 在订单页面中显示产品摘录页面
我已经显示出图像&标题的产品(感谢@helgatheviking &这个thread),但我不能让摘录显示。这是我的代码:
<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-> id);'应该这样做。 – helgatheviking
对不起没有。它不需要任何参数,即“get_the_content()”和“get_the_title()”。检查https://codex.wordpress.org/Function_Reference/get_the_excerpt –
总是值得考虑看看WooCommerce本身如何为[显示数据](https://github.com/woothemes/woocommerce/blob/master/templates/single-product/short-description.php#L22 )。而对于字幕,请看看[我写的插件](https://wordpress.org/plugins/kia-subtitle/) – helgatheviking