简体   繁体   中英

Hiding WooCommerce Checkout Button with javascript

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();
});

在此处输入图片说明

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM