Woocommerce: Coupon for new customer / first order only

woocommerceOne of my customer request to offer a coupon for all new customer / first order only. But i do not manage to find any free plugin that able to achieve this. So i decided to dig into woocommerce checkout process and write my own function to achieve this.

To apply coupon for new customer in Woocommerce, follow the steps below:-


  • Before apply the code below, you have to create a new COUPON. I’ve created a new coupon name ‘firstlove’
  • Now you can copy and paste the code below into your theme functions.php
  • once done, you can try to apply the coupon code for a new customer. It should work as expected.

If the code above could not satisfied your requirement, you can freely modify.

Happy Coding!

Share this with your friends:-

6 Responses to “Woocommerce: Coupon for new customer / first order only”

  1. Allan frança dutra says:

    hello everyone, I’ve change this code for run in my woocommerce. first of all, I changed the add_action to

    add_action(‘woocommerce_applied_coupon’,’check_new_customer_coupon’, 0);

    so, this way, every time a new cupon has added to cart, the code will run, not just after finish an order.
    and I changed $customer_orders
    that’s is the result:
    $customer_orders = get_posts( array(
    ‘numberposts’ => -1,
    ‘meta_key’ => ‘_customer_user’,
    ‘meta_value’ => get_current_user_id(),
    ‘post_type’ => wc_get_order_types(),
    ‘post_status’ => array_keys( wc_get_order_statuses() ),
    ) );

    I don’t know, but, looks like ‘post_type’ => ‘shop_order’, is deprecated, for me dosen’t work

    I hope help someone, and sorry for my english, I’m not fluent.

  2. Christine says:

    I have tried out your code in WooCommerce version 3.06 and unfortunately it is not working.
    I just love the idea of having a new customer-first order coupon and I am wondering if you could make it work in the later WC versions?
    I would really appreciate it! Thank you so very much 🙂

  3. Steven Aldit says:

    Thanks mate, I got this working and going to launch a campaign soon!

  4. Cathy says:

    This section of the code does not work:

    WC()->cart->remove_coupon( $new_cust_coupon_code );

    The notification will show but the coupon does not get removed from the cart. Is there an update to the code to make this work?

  5. chua says:

    should be working.

  6. Tommy Damani says:

    Hey man can you please tell me if this code is still good to use with the current WooCommerce?

Leave a Reply