woocommerce_before_calculate_totals在自定义单一产品模板上不起作用

时间:2019-10-13 23:23:02

标签: php wordpress templates woocommerce

经过2-3天的挫败和故障排除,我感到内:我的自定义单一产品模板。我发现,如果我删除了具有自定义div和HTML排列的自定义模板-设计已损坏,但所需的输出即将到来。

我的主要问题:
根据我上一个问题的Product custom checkbox option that changes Woocommerce cart item price答案,其中可以添加到商品价格中一个额外的选项(复选框),但并没有添加到总计在购物车页面上。

woocommerce_before_calculate_totals挂钩不适用于自定义single-product.php吗?

是什么原因造成的? 有什么解决办法?

自定义Single-product.php位于下面的mytheme/woocommerce/single-product.php中:

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

<div class="wrap wrap2">

    <div class="fcontent whitebg wshadow">
        <div class="frow">
            <h1 class="italic"><?php the_title(); ?></h1>
            <img src="https://wptravelengine.com/wp-content/uploads/edd/2018/07/Stripe-Payment-1000x683.jpg" alt="">
        </div>
    </div><!-- content -->

    <div class="sidebar">
        <div class="sleft whitebg">
            <?php if(have_posts()): while(have_posts()): the_post(); ?>
                <?php the_content(); ?>
            <?php endwhile; endif;?>
        </div>
        <div class="sright">
            <div class="somethemname_addcart browser-compatible whitebg">
                <form action="" id="order">
                    <div class="bbuynow">
                        <div class="bbuynow_one">
                            <?php while ( have_posts() ) : the_post(); ?>
                            <?php
                            wc_get_template_part( 'content', 'single-product' );
                            ?>
                            <?php endwhile; // end of the loop. ?>          
                        </div>                          
                </form>
            </div>

            <div class="browser-compatible whitebg">
                <h6>Browser compatibility</h6>
                <div class="browsers">
                    <div><img width="50px" height="50px" src="<?php bloginfo('stylesheet_directory');?>/img/svg/browsers/chrome.svg" /></div>
                    <div><img width="50px" height="50px" src="<?php bloginfo('stylesheet_directory');?>/img/svg/browsers/edge.svg" /></div>
                    <div><img width="50px" height="50px" src="<?php bloginfo('stylesheet_directory');?>/img/svg/browsers/firefox.svg" /></div>
                    <div><img width="50px" height="50px" src="<?php bloginfo('stylesheet_directory');?>/img/svg/browsers/opera.svg" /></div>
                    <div><img width="50px" height="50px" src="<?php bloginfo('stylesheet_directory');?>/img/svg/browsers/safari.svg" /></div>
                    <div><img width="50px" height="50px" src="<?php bloginfo('stylesheet_directory');?>/img/svg/browsers/internet-explorer.svg" /></div>
                </div>
            </div>
            <div class="browser-compatible whitebg">
                <table class="prod-desc">
                    <caption></caption>
                    <tr>
                        <td>Last Updated</td>
                        <td>January 29 2019</td>
                    </tr>
                    <tr>
                        <td>Created</td>
                        <td>29 January 1206 B.C.</td>
                    </tr>
                    <tr>
                        <td>Compatible with</td>
                        <td>Woocommerce 3.X</td>
                    </tr>
                    <tr>
                        <td>Four</td>
                        <td>4</td>
                    </tr>
                    <tr>
                        <td>Five</td>
                        <td>5</td>
                    </tr>
                    <tr>
                        <td>Six</td>
                        <td>6</td>
                    </tr>
                    <tr>
                        <td>Seven</td>
                        <td>7</td>
                    </tr>
                </table>
            </div>
        </div>
    </div><!-- fcontent whitebg -->

    <!-- This was the area for the table-->

</div>



<?php
    do_action( 'woocommerce_after_main_content' );
    // do_action( 'woocommerce_sidebar' );
?>

类似地,content-single-product.php也在这里休息→ mytheme/woocommerce/content-single-product.php

0 个答案:

没有答案
相关问题