Woocommerce: How to Give a Discount to Local Pickup?

Today I’ll show you how to give a discount to local pickup in your Woocommerce store. The solution is really easy and it will take a only couple of minutes to implement. So, lets jump in.

Why Should You Give a Discount to Local Pickup Shipping Method?

Probably you have a question? Why would I give a discount if someone comes to pick to product up? Well, two reasons:

  1. You have a small shop and therefore you have no time to hassle with the shipments all the time. Therefore, it would be much easier for you if the customer would come to the shop to pick the product up. Because…
  2. …this way you can offer the customer up-sells, cross-sells etc. It is a handy method to make your customer to visit your shop.

So, to motivate your customers to choose a local pickup shipping method you may want to consider give them a small discount.

How to Give a Percentage Discount to Local Pickup in Woocommerce?

Just grab this code here below and paste it to your functions.php file. Or better yet, use Code Snippets plugin which allows you to add custom functions without the need to modify your theme files. Pay attention though that this example adds a percentage based discount to your Woocommerce checkout.

Couple of things to point out:

1) Set your percentage in the row 5. In the example 0.15 means 15%. If you want to give a 5% discount, set it to 0.05

2) Row 6 has “Discount added” text which will be shown under the Local Pickup shipping method if the method is selected. See the screenshot below. So, change this text if needed.

// Add Percentage Discount to Local Pickup in Woocommerce
function local_pickup_discount( $cart ) {
  $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
  $chosen_shipping_no_ajax = $chosen_methods[0];
  if ( 0 === strpos( $chosen_shipping_no_ajax, 'local_pickup' ) ) {
    $discount = $cart->subtotal * 0.15; // Set your percentage. This here gives 15% discount
    $cart->add_fee( __( 'Discount added', 'yourtext-domain' ) , -$discount ); // Change the text if needed
  }
}
add_action( 'woocommerce_cart_calculate_fees', 'local_pickup_discount');

Now, if everything is correctly added then this shpuld be the end result.

Wocommerce: How to Give a Discount to Local Pickup?

How to Add a Fixed Amount Discount to Local Pickup in Woocommerce?

But what if you need to add a fixed amount discount to your local pickup shipping method? If so, then use this snippet here below.

Couple of things to point out:

1) Set your fixed amount in the row 9. In the example 5 means 5 euros. If you want to give a 10 euros discount then change this number accordingly.

2) Row 20 has “Pickup discount” text which will be shown under the Local Pickup shipping method if the method is selected. So, change this text if needed. Also, if you need to change the currency sign then it’s in the same row.

// Add Fixed Amount Discount to Local Pickup in Woocommerce
add_action( 'woocommerce_cart_calculate_fees', 'local_pickup_fixed_discount', 10, 1 );
function local_pickup_fixed_discount( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    // Only on checkout page
    if ( is_checkout() ) {
    
      $amount = 5; // <=== Set your Discount amount
		
    
        $chosen_shipping_method_id = WC()->session->get( 'chosen_shipping_methods' )[0];
        $chosen_shipping_method    = explode(':', $chosen_shipping_method_id)[0];
    
        // Only for Local pickup chosen shipping method
        if ( strpos( $chosen_shipping_method_id, 'local_pickup' ) !== false ) {
            // Calculate the discount
            $discount =  $amount;
            // Add the discount
            $cart->add_fee( __('Pickup discount') . ' (' . $amount . '€)' , -$discount );
        }
    }
}

Useful Tips

Video: How to Give a Discount to Local Pickup in Woocommerce?

Here are some of my favorite WordPress tools

Thanks for reading this article! I hope it's been useful as you work on your own websites and e-commerce sites. I wanted to share some tools I use as a WordPress developer, and I think you'll find them helpful too.

Just so you know, these are affiliate links. If you decide to use any of them, I'll earn a commission. This helps me create tutorials and YouTube videos. But honestly, I genuinely use and recommend these tools to my friends and family as well. Your support keeps me creating content that benefits everyone.

Themes: Over the past few years, I've consistently relied on two primary themes for all sorts of projects: the Blocksy theme and the Kadence Theme. If you explore this website and my YouTube channel, you'll come across numerous tutorials that delve into these themes. If you're interested in obtaining a 10% discount for both of these themes, then:

Code Snippets Manager: WPCodeBox allows you to add code snippets to your site. Not only that, but it also provides you with the capability to construct and oversee your WordPress Code Snippets library right in the cloud. You can grab it with the 20% discount here (SAVE 20% Coupon: WPSH20).

Contact forms: There are hundreds of contact forms out there but Fluent Forms is the one I like the most. If you need a 20% discount then use this link (save 20% coupon is WPSH20).

Gutenberg add-ons: If I need a good Gutenberg blocks add-on then Kadence Blocks is the one I have used the most. You’ll get a 10% discount with the coupon SIMPLEHACKS here.

Website migration: While building a website you probably need a good plugin that can help you with the migration, backups, restoration, and staging sites. Well, WpVivid is the one I have used for the last couple of years. If you use this link along with the WPSH20 coupon you’ll get a 20% discount.

Woocommerce extensions: There are a bunch of Woocommerce extensions that I like but the one that stands out is Advanced Dynamic Pricing. Once again, you’ll get a 20% discount if you use this link here (save 20% coupon is WPSH20)

Web Hosting: If you would like to have a really fast and easy-to-use managed cloud hosting, then I recommend Verpex Hosting (see my review here). By the way, this site is hosted in Verpex.)

To see all my most up-to-date recommendations, check out this resource that I made for you!

Do you want to thank me and buy me a beer?

Every donation is entirely welcome but NEVER required. Enjoy my work for free but if you would like to thank me and buy me a beer or two then you can use this form here below.

Donation Form (#2)

Janek T.
Janek T.

Improve this text: {CLIPBOARD}

- I have been passionate about Wordpress since 2011, creating websites and sharing valuable tips on using Wordpress and Woocommerce on my site.
- Be the first to receive notifications about new tutorials by subscribing to my Youtube channel .
- Follow me on Twitter here

Articles: 116