duanjiaren8188 2015-11-15 19:26
浏览 43

如何在woocommerce thankyou页面中添加或显示产品价格?

For example, 2 x $12 =$ 24. I want to display the $12 in thankyou page after the user place the order.

The code is in the order-details-item.php. For default woocommerce thankyou page, they don't display the product unit price. Is there a way to display it? This the woocommerce default code from order-details-item.php. Can someone help me?

if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
  return;
}
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
 <td class="product-name">
    <?php
        $is_visible = $product && $product->is_visible();

        echo apply_filters( 'woocommerce_order_item_name', $is_visible ? sprintf( '<a href="%s">%s</a>', get_permalink( $item['product_id'] ), $item['name'] ) : $item['name'], $item, $is_visible );
        echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '&times; %s', $item['qty'] ) . '</strong>', $item );

        do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );

        $order->display_item_meta( $item );
        $order->display_item_downloads( $item );

        do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order );
    ?>
  </td>
  <td class="product-total">
    <?php echo $order->get_formatted_line_subtotal( $item ); ?>
  </td>
 </tr>
  <?php if ( $order->has_status( array( 'completed', 'processing' ) ) && (  $purchase_note = get_post_meta( $product->id, '_purchase_note', true ) ) ) : ?>
 <tr class="product-purchase-note">
  <td colspan="3"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td>
 </tr>
  <?php endif; ?>
  • 写回答

1条回答 默认 最新

  • dpswo40440 2016-10-14 05:02
    关注

    Here is what you need to do:

    echo $_product->get_price_html();
    

    That will display the unit price for that line item.

    评论

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来