Woocommerce 结账页面显示订单摘要 2 次?

2024-03-09

On the checkout page when user checkbox for the shipping details the order summary doubles. I have done many modifications in the in past. So i think i made mistake.On clicking shipping information checkbox. the order summary becomes double. only subtotal, shipping and total. I am providing review-order.php code. I think the problem is in after the end of table tag. enter image description here enter image description here

<?php
/**
 * Review order table
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/review-order.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.8.0
 */

defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
    <thead>
        <tr>
            <th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
            <th class="product-total"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
        </tr>
    </thead>
    <tbody>
        <?php
        do_action( 'woocommerce_review_order_before_cart_contents' );

        foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
            $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );

            if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
                ?>
                <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
                    <td class="product-name">
                        <?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
                        <?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '&times;&nbsp;%s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
                        <?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
                    </td>
                    <td class="product-total">
                        <?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
                    </td>
                </tr>
                <?php
            }
        }

        do_action( 'woocommerce_review_order_after_cart_contents' );
        ?>
    </tbody>
</table>


        <div class="cart-subtotal">
            <h2><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></h2>
            <div class="order-detail-summary-item"><?php wc_cart_totals_subtotal_html(); ?></div>
        </div>

        <?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
            <div class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
                <h2><?php wc_cart_totals_coupon_label( $coupon ); ?></h2>
                <div class="order-detail-summary-item"><?php wc_cart_totals_coupon_html( $coupon ); ?></div>
            </div>
        <?php endforeach; ?>
<h2>Shipping</h2>
        <?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>

            <?php do_action( 'woocommerce_review_order_before_shipping' ); ?>

            <?php wc_cart_totals_shipping_html(); ?>

            <?php do_action( 'woocommerce_review_order_after_shipping' ); ?>

        <?php endif; ?>

        <?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
            <div class="fee">
                <h2><?php echo esc_html( $fee->name ); ?></h2>
                <div class="order-detail-summary-item"><?php wc_cart_totals_fee_html( $fee ); ?></div>
            </div>
        <?php endforeach; ?>

        <?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 ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited ?>
                    <div class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
                        <h2><?php echo esc_html( $tax->label ); ?></h2>
                        <div class="order-detail-summary-item"><?php echo wp_kses_post( $tax->formatted_amount ); ?></div>
                    </div>
                <?php endforeach; ?>
            <?php else : ?>
                <div class="tax-total">
                    <h2><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></h2>
                    <div class="order-detail-summary-item"><?php wc_cart_totals_taxes_total_html(); ?></div>
                </div>
            <?php endif; ?>
        <?php endif; ?>

        <?php do_action( 'woocommerce_review_order_before_order_total' ); ?>

        <div class="order-total">
            <h2><?php esc_html_e( 'Total', 'woocommerce' ); ?></h2>
            <div class="order-detail-summary-item"><?php wc_cart_totals_order_total_html(); ?></div>
        </div>

        <?php do_action( 'woocommerce_review_order_after_order_total' ); ?>

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Woocommerce 结账页面显示订单摘要 2 次? 的相关文章

随机推荐

  • IntelliJ 中的 Intellisense 不再工作

    我目前正在运行 IntelliJ IDEA 13 1 运行 IntelliJ 13 时 智能感知 自动完成停止工作 我尝试升级 但仍然不起作用 我可以使用显式调用代码完成ctrl space 我看了进去设置 gt 编辑器 gt 代码完成看起
  • 测试容器;在 docker 内运行 @Testcontainers 测试 [在 Docker 内运行 Docker]

    如何跑步 Testcontainers基于 docker 容器内的测试用例 我有一个简单的 Spring Boot 应用程序 它具有集成测试 组件级别 可以使用以下命令与容器进行交互Testcontainers 测试用例从外部容器 本地机器
  • 处理按键事件时 NSTextField 泄漏

    我是这个论坛的新手 我已经搜索过 但没有找到这个问题的任何答案 这个问题在本周的大部分时间里一直困扰着我 每次按下按键时 NSTextField 都会导致内存泄漏 我已将这个问题从我的代码中分离出来 并且可以按如下方式重现 创建一个新的 C
  • 如何禁用 UIWebview 水平滚动?

    我尝试通过插入来禁用它 到我的 HTML 字符串中 以及上面的十几个变体 徒劳地希望我只是搞砸了标签语法 但似乎没有什么可以阻止 UIWebView 水平滚动 然而 有些应用程序可以做到这一点 例如 MobileRSS 并且可能由于它们没有
  • iOS上删除大文件文件夹的性能

    假设我的 iOS 应用程序的数据目录中有一个文件夹 其中包含数千个小文件 删除此文件夹 通过 NSFileManager removeItemAtPath 需要相当长的时间 但在 OS X 上 删除具有相同内容的文件夹非常快 它似乎只是从文
  • Java 项目的包结构?

    在 Java Web 应用程序中设置包结构的最佳实践是什么 您将如何设置您的 src 单元测试代码等 你可以关注maven的标准项目布局 http maven apache org guides introduction introduct
  • shell中实时去除回车

    对于上下文 我尝试创建一个 shell 脚本来简化 ffmpeg 的实时控制台输出 仅显示正在编码的当前帧 我的最终目标是在某种进度指示器中使用此信息进行批处理 对于那些不熟悉 ffmpeg 输出的人来说 它将编码的视频信息输出到 stdo
  • pandas 对布尔类型应用过滤器

    这些是我的 DataFrame 的类型 count int64 word object cat1 bool cat2 object cat3 bool dtype object 如何对 cat1 和 cat2 中的布尔值进行过滤 就像是 d
  • 如何在 C# 中使用可选参数?

    Note This question was asked at a time when C did not yet support optional parameters i e before C 4 我们正在构建一个从 C 类以编程方式生
  • 如何检索 git 中两次提交之间更改的 maven 模块列表

    我有一个带有主模块和多个子模块的 Maven 项目 我想知道是否有一种简单的方法来检索两次提交之间更改的所有模块 无论如何 在问题提出近三年后 我基于 git diff 的启发式设计 基于 Maven 工件受惯例支配的事实 提取所有文件更改
  • 从 CursorAdapter.get() 返回对象

    我正在重写 CursorAdapter 我需要获取最后一项 问题是 CursorAdapter 实际上有一个 get 方法 但源是一个数据库 它返回一个普通对象 我什至不知道它是什么 我希望它返回一个 Cursor 对象 尽管如此 我怎样才
  • Android studio logcat最大行数

    我正在使用连接到 Android Studio 的真实设备进行测试 由于我不想中断多线程行为 因此我在代码中添加了大量日志语句以了解发生了什么 在 logcat 中 我看到了即将到来的语句 到目前为止一切顺利 运行完整测试后 我发现我的日志
  • 我应该从 MVC 框架中的控制器或模型中调用 redirect() 吗?

    我正在使用 MVC PHP 框架 Codeigniter 并且我有一个直接的问题 即从哪里调用redirect 控制器还是模型 设想 用户导航到 www example com item 555 在我的模型中 我在项目数据库中搜索 ID 为
  • 如何在使用 Moq 的测试中引发事件?

    以下是父类中的部分代码实现 handler FooUpdateDelegate FooUpdate OnFooUpdate protected abstract void OnFooUpdate ref IBoo boo string s
  • 如何在解决方案级别使用 Microsoft.Net.Compilers?

    我想开始使用Microsoft Net Compilers https www nuget org packages Microsoft Net Compilers 简化我们的构建服务器的工作 但是 我只能让它在每个项目级别 https s
  • 木偶如何判断变量是否已设置

    在木偶类中 我应该如何测试变量是否已设置 现在我只是检查变量是否未定义 if http port undef run command run command http port http port 有没有更好的方法来检查变量是否已声明 如果
  • 如何在视图中使用Django缓存而不缓存所有页面

    我尝试使用 Django Cache 来改善我的观点 效果很好 400 毫秒到 8 毫秒是完美的 但是当用户第一次访问页面时 Django 会在标题中缓存包含用户信息的页面 当我尝试注销时 页面会继续包含用户信息 我也尝试在模板中使用缓存
  • 使用 ionic 构建网站的移动网页版本是个好主意吗? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我在一家初创公司工作 我们决定拥有一个自适应网站而不是响应式网站 因此我们基本上为不同设备提供不同的视图 以便我们为两端 移动 桌面
  • 禁用 Oreo 中的状态栏拉动

    通过禁用状态栏的拉动和单击来 kiosk 应用程序的方法在 android 8 上不起作用 Android中如何禁用状态栏点击和下拉 https stackoverflow com questions 29969086 how to dis
  • Woocommerce 结账页面显示订单摘要 2 次?

    On the checkout page when user checkbox for the shipping details the order summary doubles I have done many modification