Javascript woocommerce\u添加到\u购物车挂钩在添加产品后清空购物车

Javascript woocommerce\u添加到\u购物车挂钩在添加产品后清空购物车,javascript,php,wordpress,woocommerce,Javascript,Php,Wordpress,Woocommerce,我在Woocommerce中添加了一个弹出窗口,每次用户将产品添加到其购物车时,该窗口都会显示添加的项目以及在后端的ACF字段中为每个产品设置的相关项目 我在functions.php中的代码如下所示: add_action('woocommerce_add_to_cart', 'display_more_modal', 10, 6); function display_more_modal( $cart_item_key, $product_id, $quantity, $variation_

我在Woocommerce中添加了一个弹出窗口,每次用户将产品添加到其购物车时,该窗口都会显示添加的项目以及在后端的ACF字段中为每个产品设置的相关项目

我在functions.php中的代码如下所示:

add_action('woocommerce_add_to_cart', 'display_more_modal', 10, 6);
function display_more_modal( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) {
    ?>
        <div class="remodal" data-remodal-id="modal" data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
            <button data-remodal-action="close" class="remodal-close"></button>
                <h3 class="remodal-header">Item added to cart!</h3>

                <?php 
                /* Display all the items currently in your cart */
                global $woocommerce; 
                $currency = get_woocommerce_currency_symbol();
                ?>
                    <div class="cart-wrapper">
                        <?php
                            $item = new WC_Product($product_id);
                            $item_thumb = wp_get_attachment_image_src( get_post_thumbnail_id($product_id));
                        ?>
                            <div class="row cart-item-wrapper">
                                <div class="col-4">
                                    <img class="cart-image" src="<?php echo $item_thumb[0]; ?>" alt="">
                                </div>
                                <div class="col-8">
                                    <a href="<?php echo $cart_product->post->guid; ?>"><h1 class="remodal-cart-item-heading"><?php echo $item->get_title(); ?></h1></a>
                                    <?php 
                                    $categories = wp_get_post_terms( $product_id, 'product_cat' );
                                    foreach($categories as $category) :
                                    ?>
                                        <?php if($category->slug == 'bikes') : ?>
                                            <?php 
                                                $frame_size = wc_attribute_label($variation['attribute_pa_frame-size']);
                                                $build_type = wc_attribute_label($variation['attribute_pa_build-type']);   
                                            ?>
                                            <p class="cart-meta">Frame Size: <?php echo $frame_size; ?></p>
                                            <p class="cart-meta">Build Type: <?php echo $build_type; ?></p>
                                        <?php endif; ?>
                                    <?php endforeach; ?>
                                    <span class="cart-amount"><?php echo $currency . $item->get_price(); ?></span>
                                </div>
                            </div>
                    </div>
                <?php

                ?>
                <div class="btn-wrapper right">
                    <a class="remodal-cart-btn font-18" href="<?php echo $woocommerce->cart->get_cart_url(); ?>">View cart</a>
                    <a class="remodal-cart-btn font-18" href="<?php echo $woocommerce->cart->get_checkout_url(); ?>">Checkout</a>
                </div>

                <?php 
                $related_products = get_field('upsell_products', $product_id);
                if($related_products) :
                ?>

                <h3 class="remodal-header">You may also like</h3>
                <div class="row related-items-wrapper">
                    <?php
                    /* Display related items that the user may be interested in. */
                    foreach($related_products as $post) :
                        setup_postdata($post);
                        $related_product = new WC_Product($post['upsell_product']->ID);
                        $featured_image = wp_get_attachment_image_src( get_post_thumbnail_id($post['upsell_product']->ID));
                    ?>
                        <div class="col-3">
                            <img src="<?php echo $featured_image[0]; ?>" alt="">
                            <h3 class="upsell-title"><?php echo $post['upsell_product']->post_title; ?></h3>
                            <div class="btn-wrapper">
                                <a class="remodal-cart-btn font-12" href="<?php echo $post['upsell_product']->guid; ?>">View item</a>
                            </div>
                        </div>
                    <?php
                    endforeach; 
                    wp_reset_postdata();
                    ?>
                </div>
                <?php endif; ?>
                <div class="btn-wrapper center">
                    <a class="remodal-cart-btn font-18" href="<?php echo get_site_url(); ?>/shop">Continue shopping</a> 
                </div>
        </div>
    <?php
  }
add_动作('woocommerce_add_to_cart','display_more_model',10,6);
功能显示\u更多\u模式($cart\u item\u key、$product\u id、$quantity、$variation\u id、$variation、$cart\u item\u data){
?>
项目已添加到购物车!
“alt=”“>
框架尺寸:

构建类型:

你可能也喜欢 “alt=”“>
你能解决这个问题吗?我也有同样的问题