douxun3496 2018-01-12 14:12
浏览 139
已采纳

在Woocommerce结帐页面隐藏优惠券通知单

On my website the checkout page containing "Have a coupon? Click here to enter your code" box. I don't want this field on checkout page.I applying coupon via URl. I want to remove this box from checkout page by CSS. I attached the screenshot of that box in my checkout page. enter image description here

Is this possible?

I have already tried this:

function hide_coupon_field_on_checkout( $enabled ) {
    if ( is_checkout() ) {
        $enabled = false;
    }
    return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_checkout' );

But it disable coupons functionality in checkout page.

Any help will be appreciated.

  • 写回答

3条回答 默认 最新

  • dongyi6845 2018-01-12 19:33
    关注

    You can use a custom function hooked in woocommerce_before_checkout_form action hook that will remove the notice coupon form without disabling coupon functionality in checkout page:

    add_action( 'woocommerce_before_checkout_form', 'remove_checkout_coupon_form', 9 );
    function remove_checkout_coupon_form(){
        remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
    }
    

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

    Tested and works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?