Unlink coupon form on Woocommerce checkout page

2020-04-16 06:40发布

Which file do I need to edit if I don’t want user to click the link to apply the coupon code?

In simple, I want no LINK to be clicked on.

I want the apply coupon appear below the text "Have a coupon?" so that user can ALWAYS see the section.

1条回答
Evening l夕情丶
2楼-- · 2020-04-16 07:03

Updated

This can be done very easily using dedicated woocommerce_checkout_coupon_message filter hook:

add_filter( 'woocommerce_checkout_coupon_message', 'custom_checkout_coupon_message', 20, 1 );
function custom_checkout_coupon_message( $message ) {
    ?>
        <script type='text/javascript'>
            jQuery(document).ready( function($){
                setTimeout(function(){
                    $('form.checkout_coupon').css('display','block');
                }, 300);
            });
        </script>
    <?php
    // HERE your custom message
    return __( 'Have a coupon?', 'woocommerce' ) . ' <a class="showcoupon-off">' . __( 'Below you can enter your coupon code', 'woocommerce' ) . '</a>';
}

Code goes in function.php file of the active child theme (or active theme). Tested and works.

enter image description here

查看更多
登录 后发表回答