首页 文章

删除或隐藏购物车页面中的优惠券字段 - WooCommerce

提问于
浏览
1

目前我有基于我制作的functions.php脚本自动应用的优惠券 . 我正试图从购物车页面中完全删除优惠券字段,但无法弄清楚如何操作 . 我尝试了其他地方提到的脚本,如下所示:

/ hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
    if ( is_cart() ) {
        $enabled = false;
    }
    return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' );

问题是因为这会在购物车中禁用优惠券,然后它也会删除我为客户创建的折扣,并且不会在购物车页面上显示任何折扣 . 这会让客户感到困惑 . 如何在购物车页面上隐藏或删除此优惠券字段?我是否需要使用CSS或为购物车文件创建子主题?

是否有任何钩子我可以使用钩子上的remove_action,就像在结账页面上一样?

提前致谢 .

1 回答

  • 0

    您可以使用此CSS代码:

    .woocommerce #content table.cart td.actions .coupon, .woocommerce table.cart td.actions .coupon, .woocommerce-page #content table.cart td.actions .coupon, .woocommerce-page table.cart td.actions .coupon {
        display:none;
    }
    

相关问题