WooCommerce: Exclusive discounts only for customers

Have you ever thought about applying the customer pricing policy as a loyalty strategy? Well, you should know that it is a very powerful tool, if you know how to take advantage of it.

What is the purpose of applying customer discounts?

Whether you’re considering a discount strategy for customers who have already made a purchase, or you’re simply looking to encourage customer registration, you should know that it can be an important sales driver.

Some of the most famous Ecommerce companies use this strategy to build customer loyalty and promote sales.

Because when you are able to generate a large customer base thanks to exclusive discounts for them you have a very powerful user base to encourage them to make more purchases, either from a newsletter or simply from their user account.

It is more than demonstrated the enormous potential to encourage registration, membership, to obtain exclusive discounts for registered customers, most of the private sale online stores use it successfully.

What is the first step?

The first step is to get visitors to register for the exclusive customer-only discounts.

This can be done as easily as the Store Notice that comes with every WooCommerce installation by default.

Simply customize it to encourage visitors to register for the customer-only discount.

However, since you are encouraging them to register on your online store’s account page you should make sure that registration is allowed, which you do with this WooCommerce setting…

You have the setting in WooCommerce > Settings > Accounts and privacy.

Once active, when a user visits the “My Account” page he or she can log in if he or she was already a customer or register as a new customer.

Finally, make sure that in the general WordPress settings you mark the “Customer” profile as the default user profile.

How do i apply discounts on WooCommerce to registered users only?

Once the above is done, let’s get down to business!

There are two main ways you can apply discounts to your already registered customers, which are of course connected.

Apply discounts to customers with a code

There’s a code that makes it easier for you to do this:

/* Part 1 - WooCommerce product */
add_filter( 'woocommerce_get_price_html', 'wphelp_customers_product_discount', 9999, 2 );
function wphelp_customers_product_discount( $price_html, $product ) {
    if ( is_admin() ) return $price_html;
    if ( '' === $product->get_price() ) return $price_html;
    if ( wc_current_user_has_role( 'customer' ) ) {
        $orig_price = wc_get_price_to_display( $product );
        $price_html = wc_price( $orig_price * 0.80 );
    return $price_html;
/* Part 2 - Cart and proceed to checkout */
add_action( 'woocommerce_before_calculate_totals', 'wphelp_cart_customer_discount', 9999 );
function wphelp_cart_customer_discount( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return;
    if ( ! wc_current_user_has_role( 'customer' ) ) return;
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
        $product = $cart_item['data'];
        $price = $product->get_price();
        $cart_item['data']->set_price( $price * 0.80 );
}Code language: PHP (php)

This code applies a 20% discount ( $orig_price * 0.80 ) to each product or to the whole cart if the user has the (customer) profile and is connected.

Otherwise it shows the visitor the normal price you entered when creating the product, including normal discounts if any.

In other words, the connected customer would see it with the 20% discount added but the rest would see it with the normal price.

As always, the above code can be added to the end of the functions.php file of the active theme or to your customization plugin.

Apply discounts to customers with plugins

There are several plugins that allow for such customizations in WooCommerce, you can even find them in the WordPress.org directory, but none of them are free, customization of prices by user type is always a premium option.

And of the plugins that offer these user profile price customizations, the best one with the best price/performance ratio is WooCommerce Role Based Prices.

As soon as you install it you have a new settings page in Yith > Role Based Prices where you can configure all aspects.

The first thing is to define at what price the special discounts (normal or discounted) will be applied…

To then configure which user profiles are eligible for discounts.

And, the most important settings page, the price rules page.

And adding rules is really easy, you just have to fill in a few fields to set it up.

As you see in the previous capture, it’s very simple

  1. You choose which user profile to apply to.
  2. You define if it will be applied to all products or filter by categories or labels (exclusion or inclusion).
  3. You specify if the discount will be fixed or by percentage.
  4. You write the value.
  5. You apply a priority if there are any other rules about the same products and/or profiles.

The rules will be applied automatically, but you can also create specific pricing rules for each product.

On the product creation/edit page you will see a new field from which you can create custom rules by product.

Just like the global rules, simple to create and configure.

Finally, you can even customize the texts that will be shown to visitors, to encourage them to register and get discounts.

This is always important, don’t you think?

As you can see, WooCommerce Role Based Prices is a plugin with enormous possibilities, because not only can you apply price rules by user profile…

  • You can edit prices (in percentage and quantity) for a single product, a category or product label, based on user profiles, etc.
  • You can apply different prices to both the normal and the discounted price
  • You can change the visibility of the add to cart button, the price based on profiles, the price, everything, according to the user profile
  • You can show or hide product taxes based on user profiles
  • Works with variable products.

Whether you use the code or prefer to opt for the plugin, I hope you will be encouraged to create a discount strategy for customers, it is proven to be very powerful, and can help you to increase loyalty and sales in your Ecommerce.

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top