dslkchyv673627 2015-09-07 10:45
浏览 100

用javascript隐藏WooCommerce Checkout按钮

I am trying to hide the Place Order Button on my WooCommerce Site, but the behavior seems to be overridden by some other script because the button would hide and then it would reappear.

I am using the storefront 1.5 theme and Wordpress 4.3

JS Loading Code :

add_action('wp_enqueue_scripts', 'order_summary_script', 9999); //last script to load
function order_summary_script() {
    wp_enqueue_script('order-summary', get_bloginfo('stylesheet_directory') . '/assets/js/order-summary.js', array('jquery'), '1.0.0', true);
}

Hiding Code:

jQuery( document ).ready(function($) {
    //hide place order button on checkout page
    $('input[name=woocommerce_checkout_place_order]').hide();
});

enter image description here

Update:

Even if I added the script to the footer per Dev Danidhariya suggestion ( which means it's the last script ) it still doesn't fix it. Wordpress Codex mention below:

JavaScript cannot be added to post content without a special WordPress Plugin that removes the filters that prevent unwanted code within the post content area, for the protection of the user.

Could this be the problem?

  • 写回答

1条回答 默认 最新

  • dongya0914 2015-09-07 11:00
    关注

    Add This code in Your Active theme Footer.php

    <script>
        jQuery( document ).ready(function($) {
            //hide place order button on checkout page
            $('input[name=woocommerce_checkout_place_order]').hide();
        });
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大