How to Add Multiple Local Pickup Locations to Woocommerce

Woocommerce comes with a default ‘local pickup’ shipping option which works fine if you have only one location. If you have multiple shops that you want customers to pick from then you need to customize the checkout page to add more locations.

woocoommerce store pickup
Woocomerce Local pickup shipping option

You can buy the Local pickup plus plugin which costs a whopping $79.00 bucks or follow my tutorial and add more locations for free without a plugin.

Here are the steps to adding multiple locations for Woocommerce local pickup shipping option:

  1. Open your theme folder and create a backup of your functions.php file for safety. Open the file for editing.To add the multiple locations dropdown in the shipping column insert this piece of code in your functions.php file.
    /**
     * Add store location select dropdown in checkout page
     **/
    add_filter( 'woocommerce_checkout_fields' , 'custom_store_pickup_field');
    
    function custom_store_pickup_field( $fields ) {
          $fields['shipping']['store_pickup'] = array(
         'type'     => 'select',
    	        'options'  => array(
    		'option_1' => 'Option 1 text',
                    'option_2' => 'Option 2 text',
    		'option_3' => 'Option 2 text'
            ),
         'label'     => __('Store Pick Up Location', 'woocommerce'),
        'required'  => false,
        'class'     => array('store-pickup form-row-wide'),
        'clear'     => true
         );
    
         return $fields;
    }
    

    Save your functions.php file then refresh your checkout page. The dropdown field should display something like this:
    select-dropdown-checkout-page

  2. To display the store location under order details add this to functions.php
    /**
     * Update the order meta with store location pickup value
     **/
    add_action( 'woocommerce_checkout_update_order_meta', 'store_pickup_field_update_order_meta' );
    function store_pickup_field_update_order_meta( $order_id ) {
    				if ( $_POST[ 'store_pickup' ] )
    								update_post_meta( $order_id, 'Store PickUp Location', esc_attr( $_POST[ 'store_pickup' ] ) );
    }
    

    Save your functions.php file then do a test transaction and select a store location. Open order details from the admin dashboard. Viewing the custom fields for your order details should show you this:
    custom-field-store-location

  3. Customize this code to use your own store locations
      'option_1' => 'Option 1 text',
      'option_2' => 'Option 2 text',
      'option_3' => 'Option 3 text'
    

    Mine looks like this:
    woocommerce-select-checkout-page

This is an simple solution for having multiple pickup points for your Woocommerce online store. You don’t have to buy additional pricey plugins that can add bloat to your WordPress site.

Thanks for the tips at Stackexchange on using the select options in the hooks. Reply with a comment below if you have anything to add. Share this post with a like or tweet if you found it helpful or informative.

Like, Tweet and Share!

16 Responses to “How to Add Multiple Local Pickup Locations to Woocommerce”

  1. Howie

    Nice code, but it doesn’t seem to work.

    Just before the line ‘type’ => ‘select’, I believe it’s missing an array?

    Reply
  2. Howie

    Thanks Caleb! Now the select field is added to the checkout page, however it is added inside the billing information, and not where the customer selects shipping solution.

    The best way (at least as I see it) would be to have it placed around the same area where a customer selects “local pickup”. If local pickup is selected then the customer can easily choose which option they want to select from the dropdown.

    Reply
    • Caleb Serna

      The best I could do was to change it from

      $fields['billing']['store_pickup']

      to

      $fields['shipping']['store_pickup']

      so that it appears in the shipping column at checkout page.
      I know it would be better if the select field would be available exactly when they choose shipping option but it seems pretty complicated. Let me know if you find a way to do that.

      Reply
  3. Marissa

    This is brilliant! Thank you!

    Quick question: When I go to my order details it just shows me: Option_1 Is there a way for it show me the name of my store in the order details? I have many stores and to keep track might be a bit difficult. Either way, this still at least saved me 79 dollars!

    Reply
    • Caleb Serna

      Yes you can rename option_1 to whatever your store name is. For example

        'san francisco store' => 'San Francisco',
        'oakland store' => 'Oakland',
        'los angeles store' => 'Los Angeles'
      

      I recommend using underscores for spaces to prevent conflicts.

      e.g. san_francisco_store
      Reply
    • Busisiwe

      Hi Glen, my Plugin saves the AIOSEOP details asngait the base Product’s Post ID, AIOSEOP checks for these details for each Post/Product, I suspect variable Products are being displayed differently to other Types.

      Reply
  4. Marissa

    Thank you so much.

    Do you know a way to make this field required? I can’t figure out the code.

    Reply
    • Caleb Serna

      First set required to true. If you need a custom warning message add this to your code:

      function custom_checkout_field_alert( ) {
          global $woocommerce;
              if ( !$_POST[ 'store_pickup' ] )
      $woocommerce->add_error( __( 'Please select store location.' ) );
      } 
      add_action( 'woocommerce_checkout_process', 'custom_checkout_field_alert' );
      
      Reply
    • Mimi

      Hi Alexander, I just tested it again and it’s still wirokng for me. All I can suggest is to make sure each of your NVP variables & values are correct PayPal has been known to provide an error message that has nothing to do with the real problem.

      Reply
  5. Angel

    Thanks for sharing this valuable piece of code!
    It works great but what if you want to check if the user has chosen local pick up? It’s displayed even if the user has chosen other shipping method. Thanks in advance

    Reply
  6. John

    When I did this, nothing showed up. I put the step 1 code in functions.php and nothing happens.

    Reply
  7. John

    Caleb, I added this and finally got it to show up. But it is showing up under the shipping information, where you would click if the shipping address was different. Why isn’t it showing under the shipping method?

    Reply
  8. June Bug

    I tried to copy the code into the function.php but I didn’t see the changes?

    Reply
  9. Ehud

    Thanks for sharing the code. However, it is possible to have the local pickup locations options show up only on local pickup? If I choose free delivery or local delivery options it still shows up, which does’t make sense. Thanks in advance

    Reply

Leave a Reply

Published Last updated