【问题标题】:Woocommerce All JS And Jquery elements are not loadingWoocommerce所有JS和Jquery元素都没有加载
【发布时间】:2013-12-16 18:31:19
【问题描述】:

我通过创建 woocommerce.php 并在我的 functions.php 文件中添加一个自定义函数来使我的主题与 woocommerce 兼容

add_theme_support( 'woocommerce' ); 

这就是我的 woocommerce.php 文件的样子:

<?php
                global $mandigo_options, $dirs;

                get_header();

                // heading level for page title (h1, h2, div, ...)
                $tag_post_title_single = $mandigo_options['heading_level_post_title_single'];
            ?>
                <td id="content" class="<?php echo ($mandigo_options['sidebar_always_show'] ? 'narrow' : 'wide'); ?>column"<?php if (mandigo_sidebox_conditions($single = true)) { ?> rowspan="2"<?php } ?>>

                    <div class="woocommerce">
                        <?php woocommerce_content(); ?>
                    </div>




                </td>

            <?php
                // if we have at least one sidebar to display
                if ($mandigo_options['sidebar_always_show'] && $mandigo_options['sidebar_count']) {
                    if (mandigo_sidebox_conditions($single = true))
                        include (TEMPLATEPATH . '/sidebox.php');

                    include (TEMPLATEPATH . '/sidebar.php');

                    // if this is a 3-column layout
                    if ($mandigo_options['layout_width'] == 1024 && $mandigo_options['sidebar_count'] == 2)
                        include (TEMPLATEPATH . '/sidebar2.php');
                }

                get_footer();
            ?>

现在一切正常,但我找不到添加到购物车按钮,并且所有使用 javascript 或 jquery 的元素都没有加载。

我试过了:

  1. 使用 wordpress JQuery 更新器

  2. 将jquery库引用放到header.php中

  3. 停用所有插件

我有 woocommerce 字段中必要元素的所有字段,例如价格,但很明显这是 JS 或 JQuery 错误。

这是一个链接到该网站的产品页面:

http://www.doctor-detail.com/product/gift-card-product-2

任何帮助将不胜感激!

【问题讨论】:

    标签: javascript php jquery wordpress woocommerce


    【解决方案1】:

    当我检查站点并检查控制台时,我发现虽然我在我的站点标题中链接到最新的 jquery,但它使用的是主题的主 jquery。

    所以,我需要做的就是从 JS 文件夹中删除主题是 Jquery 文件。

    之后 woocommerce 工作正常。

    【讨论】:

      【解决方案2】:

      您应该在functions.php 中使用wp_enqueue_script() 而不是在header.php 中链接,请记住默认情况下JQuery 已入队。如果您需要更改版本,首先您必须取消注册默认版本。

      【讨论】:

        猜你喜欢
        • 2018-05-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-16
        相关资源
        最近更新 更多