取消Woocommerce结帐页面上的优惠券表单 [英] Unlink coupon form on Woocommerce checkout page

查看:114
本文介绍了取消Woocommerce结帐页面上的优惠券表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我不希望用户单击链接以应用优惠券代码,我需要编辑哪个文件?

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.

推荐答案

已更新

使用专用的 woocommerce_checkout_coupon_message 过滤器钩子可以很容易地完成此操作:

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>';
}

代码位于活动子主题的function.php文件中(或活动主题)。经过测试并可以使用。

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

这篇关于取消Woocommerce结帐页面上的优惠券表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆