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

Thank you for reading this article. I hope you found it helpful as you build your own websites and e-commerce sites. Here are some tools I use as a Wordpress developer and enthusiast that I hope you’ll also find helpful.

These are affiliate links, so if you do decide to use any of them, I’ll earn a commission and this helps me create these tutorials and make Youtube videos. But in all honesty, these are the exact tools that I use and recommend to everyone, even my friends and family.

Themes: For the last couple of years I have two go-to themes which I use for every kind of projects. Those two themes are Blocksy theme and Kadence Theme. On this site and my Youtube channel you’ll see a lot of tutorials I have made about them. If you would like to get a 10% discount for both of them then:

Code Snippets manager: WPCodeBox allows you to add code snippets to your site. Also, it allows you to build and manage your WordPress Code Snippets library 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 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 20% discount.

Woocommerce extensions: There are a bunch of Woocommerce extensions that I really like but the one that stands really 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). Btw, this site is hosted in Verpex.)

To see all my of 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)

Best selling plugins

Janek T.
Janek T.

I am a Wordpress enthusiast who has been making websites since 2011. In this site I am offering simple to follow tips on how to use Wordpress and Woocommerce.
If you want to be the first to be notified about the new tutorials then please subscribe to my Youtube channel here
Follow me in Twitter here

Articles: 96