最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How to remove coupon dropdown feature

programmeradmin0浏览0评论

I want to remove the coupon drop down feature and just have the input field and 'add coupon' button on the checkout page. Does anyone know how I can get rid of the dropdown feature? Thank you in advance!

HTML:

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

if ( ! wc_coupons_enabled() ) {
    return;
}

if ( ! WC()->cart->applied_coupons ) {
    $info_message = apply_filters( 'woocommerce_checkout_coupon_message', __( 'Promo code?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>' );
    wc_print_notice( $info_message, 'notice' );
}
?>

<form class="checkout_coupon" method="post" style="display:none">

    <p class="form-row form-row-first">
        <input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'Promo Code', 'woocommerce' ); ?>" id="coupon_code" value="" />
    </p>

    <p class="form-row form-row-last">
        <input type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply', 'woocommerce' ); ?>" />
    </p>

    <div class="clear"></div>
</form>

I want to remove the coupon drop down feature and just have the input field and 'add coupon' button on the checkout page. Does anyone know how I can get rid of the dropdown feature? Thank you in advance!

HTML:

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

if ( ! wc_coupons_enabled() ) {
    return;
}

if ( ! WC()->cart->applied_coupons ) {
    $info_message = apply_filters( 'woocommerce_checkout_coupon_message', __( 'Promo code?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>' );
    wc_print_notice( $info_message, 'notice' );
}
?>

<form class="checkout_coupon" method="post" style="display:none">

    <p class="form-row form-row-first">
        <input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'Promo Code', 'woocommerce' ); ?>" id="coupon_code" value="" />
    </p>

    <p class="form-row form-row-last">
        <input type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply', 'woocommerce' ); ?>" />
    </p>

    <div class="clear"></div>
</form>
Share Improve this question asked May 10, 2016 at 15:31 T.DoeT.Doe 1411 silver badge4 bronze badges 3
  • 1 On checkout page, by default WooCommerce renders coupon field as input field and not dropdown. Not sure how you are seeing it as dropdown. Are you using any extra plugin for coupon. Please share your website link. – Prasad Nevase Commented May 10, 2016 at 16:17
  • Can you leave url here, I see there is no dropdown here only 2 inputs, the text input and submit for that text. Maybe you have some javascript which is animating you this area or something? – Usce Commented May 10, 2016 at 17:54
  • @ItsMePN and Usce, perhaps you're using older versions of WooCommerce? I see the animated open that the OP described. – Steven Commented May 10, 2016 at 23:16
Add a comment  | 

4 Answers 4

Reset to default 1

You can try this action. Put this line into your active theme functions.php file

remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );

Removing the Coupon Field Using Option

If you are really fed up with the coupons, you can easily remove the coupon field altogether. To do that, go to the WooCommerce > Settings page, click on the ‘Checkout’ tab. Uncheck the ‘Enable the use of coupons’ and click ‘Save Changes’ button. At this point, you no longer have the coupon field anywhere in your store.

You can do that with css - the form is hidden by default, but can be targeted like this:

.woocommerce-checkout form.checkout_coupon{
    display:block
}

(put that in style.css)

Steven is correct, but new WooCommerce styles apply styles to that form differently now so the style code should be

.woocommerce form.checkout_coupon { display:block !important; }

发布评论

评论列表(0)

  1. 暂无评论