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:-

Advertisements

  • 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:-

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

  1. Christine says:

    Hello,
    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 🙂

  2. Steven Aldit says:

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

  3. 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?

  4. chua says:

    should be working.

  5. 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