我尝试制作一个函数,该函数在购物车为0时隐藏付款方式标题和字幕,同时使用ID优惠券



我尝试制作一个函数,该函数在使用优惠券的情况下,在购物车总数为0时添加隐藏付款方式标题。你们都可以帮我!

这就是我已经尝试的。

// Add title and subtitle for payment form.
  add_action(
     'woocommerce_review_order_before_payment', function() {
    if ($total < 1)) {
        return;
    }
    else{
    printf(
        '<h2 class="mk-wc-title">%s<small class="mk-wc-subtitle">%s</small></h2>',
        esc_html__( 'Choose your payment method', 'mk_framework' ),
        esc_html__( 'Enter your payment details.', 'mk_framework' )
    );}
} 
);

我可以使用所有帮助!

原始代码

// Add title and subtitle for payment form.
  add_action(
             'woocommerce_review_order_before_payment', function() 
            {
if ( ! is_checkout() ) {
        return;
    }
        printf(
            '<h2 class="mk-wc-title">%s<small class="mk-wc-subtitle">%s</small></h2>',
            esc_html__( 'Choose your payment method', 'mk_framework' ),
            esc_html__( 'Enter your payment details.', 'mk_framework' )
        );
}

(;

您可以尝试此

  add_action(
             'woocommerce_review_order_before_payment', function() 
            {
             $amount = floatval( preg_replace( '#[^d.]#', '', $woocommerce->cart->get_cart_total() ) );
            if ($total < 1)) 
            {
                return;
            }
            else{
            printf(
                '<h2 class="mk-wc-title">%s<small class="mk-wc-subtitle">%s</small></h2>',
                esc_html__( 'Choose your payment method', 'mk_framework' ),
                esc_html__( 'Enter your payment details.', 'mk_framework' )
            );}
        } 

最新更新