简体   繁体   English

Woocommerce 在结帐页面通过付款隐藏优惠券字段

[英]Woocommerce Hide coupon field by Payment at Checkout Page

I already hide the coupon field on the cart page.我已经隐藏了购物车页面上的优惠券字段。 Now I try to hide or show the coupon field depending on the payment method at the checkout page.现在我尝试根据结帐页面的付款方式隐藏或显示优惠券字段。

I tried this code: Woocommerce Payment Method Detection in Checkout Page我试过这个代码: Woocommerce Payment Method Detection in Checkout Page

But it won't work.但它不会工作。 Do you have any hints for me.你对我有什么提示吗。 Thanks a lot非常感谢

You can use woocommerce 'woocommerce_coupons_enabled' action hooks.您可以使用 woocommerce 'woocommerce_coupons_enabled' 动作挂钩。 Try below code试试下面的代码

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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