admin 管理员组文章数量: 1184232
How can I output the contents of my account > orders on a different page in php?
I managed to output the table when there are orders, but when there are no orders, it shows blank.
How can I show the orders content when blank in a different php page?
Thanks!
How can I output the contents of my account > orders on a different page in php?
I managed to output the table when there are orders, but when there are no orders, it shows blank.
How can I show the orders content when blank in a different php page?
Thanks!
Share Improve this question asked Jan 21, 2019 at 13:38 KarenSKarenS 112 bronze badges 2- What do you have so far? – RiddleMeThis Commented Jan 21, 2019 at 13:52
- This shows my full order table but not the empty message . /* Show Orders inside My Account Page */ function shortcode_my_orders_two( $atts ) { extract( shortcode_atts( array( 'order_count' => -1 ), $atts ) ); ob_start(); wc_get_template( 'myaccount/orders.php', array( 'current_user' => get_user_by( 'id', get_current_user_id() ), 'order_count' => $order_count ) ); return ob_get_clean(); } add_shortcode('my_orders_two', 'shortcode_my_orders_two'); – KarenS Commented Jan 23, 2019 at 14:24
1 Answer
Reset to default 0If you look at the template file for orders it starts like this
do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
<?php if ( $has_orders ) : ?>
If there are no orders it's never going to loop through that content, which is good because it would be broken if it did. If you really need the orders table to show up even if it's empty then you'll want to recreate the table from the template file somewhere else and pull that in. If you're including this template on your other page it shouldn't be showing up as blank with no orders though, there should be a no orders message.
本文标签: How can I put the contents of My Account gt Order into a separate page WooCommerce
版权声明:本文标题:How can I put the contents of My Account > Order into a separate page, Woocommerce 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1736578559a1751636.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论