In the world of e-commerce, providing efficient shipping options is crucial for customer satisfaction. One such option is “Local Pickup“, which allows customers to collect their purchases directly from a designated location. However, it is essential to offer this option only to specific customers under certain conditions. In this blog post, I will discuss how to display the “Local Pickup” option exclusively for customers when the following conditions are met:
- Selected country is India
For this example i’m using the India and it’s states but you can modify it according to your requirements. - Selected state is any one from India (except Andaman and Nicobar Islands)
- Selected product(s) in the cart are either ‘Nespresso Coffee Machine’ (that has product ID = 100) or ‘Breville The Smart Pro Coffee Grinder’ (that has product ID = 200) or both.
Why Local Pickup?
Local pickup is an excellent shipping choice for customers who want to save on shipping costs or receive their products quickly. However, it’s essential to restrict this option to customers in specific areas where sellers have physical stores and offer certain eligible products for pickup.
Setting Up the Conditions
To display the “Local Pickup” option only for customers under specific cart conditions, you will need to implement custom logic. In this example, I will use WooCommerce, a popular e-commerce platform for WordPress. Follow these steps:
1. Access your WordPress admin panel
Log in to your WordPress dashboard and navigate to your WooCommerce settings.
2. Create or modify the "Local Pickup" shipping method for all physical locations
For this setup, I am assuming that you only have one shipping zone set up for all Indian states, including Andaman and Nicobar Islands.
If you do not have a “Local Pickup” shipping method already, create it by following the instructions provided here: https://woocommerce.com/document/local-pickup/, for your store’s physical locations.
3. Add custom code
To apply custom logic for the cart conditions, you will need to add some code to your WordPress theme’s functions.php file. Here is a sample code snippet that you can use:
4. Save changes
Remember to save your changes to the functions.php file.
Testing your setup
After implementing these changes, it is essential to thoroughly test your website’s shopping cart to ensure that the “Local Pickup” option only appears for specific locations when the specified product conditions are met.
Additionally, test the backend of the website to confirm that everything is working without any issues.
Conclusion
By customising your e-commerce platform, such as WooCommerce, you can exclusively offer a “Local Pickup” option to customers when certain product conditions are met. This not only provides a more tailored shopping experience but also helps streamline your shipping operations by excluding areas where local pickup may not be possible due to the absence of a physical store location.