mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-02 12:02:25 +08:00
20 lines
684 B
Text
20 lines
684 B
Text
add_action( 'woocommerce_before_checkout_form', 'bbloomer_uncheck_default_payment_gateway' );
|
|
|
|
function bbloomer_uncheck_default_payment_gateway() {
|
|
wc_enqueue_js( "
|
|
|
|
// ONLY RUN ON CHECKOUT PAGE LOAD
|
|
$( document.body ).on( 'updated_checkout', function() {
|
|
|
|
// ONLY RUN IF MORE THAN 1 PAYMENT OPTION
|
|
if ( $( '.woocommerce-checkout' ).find( 'input[name=\'payment_method\']' ).length === 1 ) return false;
|
|
|
|
// UNCHECK CHECKED PAYMENT METHOD
|
|
$('input[name=\'payment_method\']').prop('checked', false);
|
|
|
|
// CLOSE CHECKED PAYMENT DESCRIPTION BOX
|
|
$('div.payment_box').hide();
|
|
|
|
});
|
|
" );
|
|
}
|