【问题标题】:Move a row in Woocommerce checkout page after the total在总计之后在 Woocommerce 结帐页面中移动一行
【发布时间】:2018-07-26 17:59:17
【问题描述】:

我需要交换我的 checkout-review-order-table 中的两行(税金和总价) - 我希望税金显示在总价上方,然后我需要在总价下方和附加行。

如果有可能解决functions.php中的问题,那就太好了

screenshot checkout

如果您需要任何其他信息,请告诉我。

感谢任何帮助。

【问题讨论】:

    标签: php wordpress woocommerce checkout


    【解决方案1】:

    在 Woocommerce 结帐页面中,您需要覆盖模板 checkout/review-order.php via the theme

    您将不得不移动税块

        <?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
            <?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
                <?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
                    <tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
                        <th><?php echo esc_html( $tax->label ); ?></th>
                        <td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
                    </tr>
                <?php endforeach; ?>
            <?php else : ?>
                <tr class="tax-total">
                    <th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
                    <td><?php wc_cart_totals_taxes_total_html(); ?></td>
                </tr>
            <?php endif; ?>
        <?php endif; ?>
    

    总块之后:

        <?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
    
        <tr class="order-total">
            <th><?php _e( 'Total', 'woocommerce' ); ?></th>
            <td><?php wc_cart_totals_order_total_html(); ?></td>
        </tr>
    
        <?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
    
    <!-- #### ====> IN HERE <==== #### -->
    

    它会很好地工作。用其他方式是不可能的。


    文档:Template structure & Overriding templates via a theme

    【讨论】:

      猜你喜欢
      • 2017-01-20
      • 2017-08-19
      • 2018-07-20
      • 2015-11-29
      • 1970-01-01
      • 2021-02-08
      • 2016-07-20
      • 2015-01-17
      • 2020-11-03
      相关资源
      最近更新 更多