可以使用get_name()在表上显示产品名称;
我无法在订单页面上回应产品名称。我正在使用WooCommerce使用Ultimate Member插件。 “ get_id();”工作正常。我使用“ $ order-> get_name()”来回荡订购的产品名称。但这向我显示了尝试加载页面时的错误。
<tbody>
<?php
foreach( $customer_orders as $customer_order ) {
$order = wc_get_order( $customer_order->ID );
$order_id = $customer_order->ID;
$order_data = $order->get_data();
$order_date = strtotime( $order->get_date_created() );
?>
<tr class="order" data-order_id="<?php echo esc_attr( $order_id ); ?>">
<?php do_action( 'um_woocommerce_orders_tab_before_table_row', $order, $customer_orders ); ?>
<td class="order-total" data-title="<?php _e( 'Item', 'um-woocommerce' ); ?>">
<?php echo $order->get_name() ?></td>
<td class="order-date" data-title="<?php _e( 'Date', 'um-woocommerce' ); ?>">
<time
datetime="<?php echo wp_date( 'Y-m-d', $order_date ); ?>"><?php echo wp_date( $date_time_format, $order_date ); ?></time>
</td>
<td class="order-status" data-title="<?php _e( 'Status', 'um-woocommerce' ); ?>">
<span
class="um-woo-status <?php echo $order->get_status(); ?>"><?php echo wc_get_order_status_name( $order->get_status() ); ?></span>
</td>
<td class="order-total" data-title="<?php _e( 'Total', 'um-woocommerce' ); ?>">
<?php echo $order->get_formatted_order_total() ?></td>
<td class="order-detail">
<a href="<?php echo esc_url( "$url#$order_id" ); ?>" class="um-woo-view-order um-tip-n"
title="<?php esc_attr_e( 'View order', 'um-woocommerce' ); ?>"><i class="um-icon-eye"></i></a>
<?php do_action( 'um_woocommerce_orders_tab_actions', $order, $customer_orders ); ?>
</td>
<?php
if ( UM()->options()->get('woo_account_order_ations') ) {
$actions = wc_get_account_orders_actions( $order );
echo '<td class="order-actions">';
if ( !empty( $actions ) ) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
echo '</td>';
}
?>
<?php do_action( 'um_woocommerce_orders_tab_after_table_row', $order, $customer_orders ); ?>
</tr>
<?php } ?>
</tbody>
I can't echo the product name on my order page. I'm using ultimate member plugin with WooCommerce. "get_id();" is working just fine. I used "$order->get_name()" to echo the ordered product name. but it shows me error when tried to load the page.
<tbody>
<?php
foreach( $customer_orders as $customer_order ) {
$order = wc_get_order( $customer_order->ID );
$order_id = $customer_order->ID;
$order_data = $order->get_data();
$order_date = strtotime( $order->get_date_created() );
?>
<tr class="order" data-order_id="<?php echo esc_attr( $order_id ); ?>">
<?php do_action( 'um_woocommerce_orders_tab_before_table_row', $order, $customer_orders ); ?>
<td class="order-total" data-title="<?php _e( 'Item', 'um-woocommerce' ); ?>">
<?php echo $order->get_name() ?></td>
<td class="order-date" data-title="<?php _e( 'Date', 'um-woocommerce' ); ?>">
<time
datetime="<?php echo wp_date( 'Y-m-d', $order_date ); ?>"><?php echo wp_date( $date_time_format, $order_date ); ?></time>
</td>
<td class="order-status" data-title="<?php _e( 'Status', 'um-woocommerce' ); ?>">
<span
class="um-woo-status <?php echo $order->get_status(); ?>"><?php echo wc_get_order_status_name( $order->get_status() ); ?></span>
</td>
<td class="order-total" data-title="<?php _e( 'Total', 'um-woocommerce' ); ?>">
<?php echo $order->get_formatted_order_total() ?></td>
<td class="order-detail">
<a href="<?php echo esc_url( "$url#$order_id" ); ?>" class="um-woo-view-order um-tip-n"
title="<?php esc_attr_e( 'View order', 'um-woocommerce' ); ?>"><i class="um-icon-eye"></i></a>
<?php do_action( 'um_woocommerce_orders_tab_actions', $order, $customer_orders ); ?>
</td>
<?php
if ( UM()->options()->get('woo_account_order_ations') ) {
$actions = wc_get_account_orders_actions( $order );
echo '<td class="order-actions">';
if ( !empty( $actions ) ) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
echo '</td>';
}
?>
<?php do_action( 'um_woocommerce_orders_tab_after_table_row', $order, $customer_orders ); ?>
</tr>
<?php } ?>
</tbody>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
订单对象没有 get_name()函数。您需要通过订单项目循环以获取产品对象并使用
$ $ product-&gt; get_name()
函数There is no get_name() function for order object. You need loop through the order items to get the product object and use the
$product->get_name()
function