One of my current WordPress website development projects includes eCommerce for equipment rentals and sales. Rentals are typically for nine to 12 months.
To handle certain rentals, the checkout processing requires intrusive customization of the shipping section; the standard WooCommerce shipping section behavior and fields will be replaced entirely with a new shipping field group.
Most of the time, the new shipping field group will be displayed, and then, about 15% of the time, the checkout process will default to the standard WooCommerce checkout shipping fields behavior.
Which shipping section to display is determined by the renter’s choice in one of the product’s attributes. When the attribute is checked, it indicates that the delivery of the products included in the order will be grouped with other orders going to the same location. Instead of prompting for the standard shipping address fields, the renter is prompted for the building name, city, recipient, and other special info.
Testing WooCommerce Checkout Page Customizing Plugins
My initial plan was to utilize a plugin. With over 15 years of experience in the WordPress-WooCommerce realm, I was well aware of the abundance of WooCommerce checkout page customization plugins available.
I tried to implement my client’s desired shopping behavior using three different plugins. Each worked to a certain degree, and none did the whole job.
The most promising custom shipping fields plugin, a premium plugin sold on WooCommerce, worked beautifully until I started changing the values of multiple fields. The other values that should have updated based on those changes, did not update.
The plugin was so close to processing the shipping fields the way my client wanted, that I started working with the developers to test, get a fix, and implement.
We had a nine-hour difference in time and spoke different languages, however, we were enthusiastic to work together to reach a solution and, so, we Skyped through a few sessions.
Ultimately, we were not able to find a solution for this specific eCommerce scenario – and that is how I ended up writing the PHP code myself.
I was rusty with the WooCommerce hooks, so, spent hours one day searching for the optimum ones to fit this eCommerce case.
Custom PHP code with WooCommerce hooks produces the results my client wants
Shout out and big THANKS to the developers who blazed the trail and had customized WooCommerce six-ways-to-Sunday. Shout out to:
- Joshua Michaels, WordCamp presentation on YouTube, Customizing WooCommerce the Right Way with WordPress actions and filters
- Victor at Vicode Media who posted a YouTube video, How to Add Custom Fields to WooCommerce Checkout Page | No Plugins, that was very helpful, and got me started.
- Business Bloomer’s WooCommerce Visual Hook Guide: Checkout Page
- And several others who posted on YouTube about other aspects of the checkout process like processing an order that includes both a subscription and one to several one-time purchase products, and integrating that kind of order with Stripe and PayPal, etc.)
It was thanks to these pioneers that I was reminded that it is not just a matter of writing the code to make the custom shipping fields display on the checkout screen. Instead, you need to:
- Display the custom shipping fields on the checkout screen
- Save the values entered by the customer in the database
- Display the values on the order confirmation screen during checkout
- Display the values in the order’s confirmation emails post checkout
- Display the fields and provide the ability to update them on the Order details page on the Dashboard.
To make those customizations, I added actions and updated filters using other WooCommerce hooks.
The checkout process and subsequent updating of the custom shipping fields is working well at this time. Now on to static pages and fine-tuning the design in preparation for client review.
Once reviewed and approved, I’ll publish, and then can tell more about the project.
WooCommerce Checkout Page Customizations Wrap Up
Customizing WooCommerce Checkout Shipping fields using the hooks was something that I initially wanted to avoid. I don’t like to burden my clients with custom code in case we part ways some day. Having the custom PHP code instead of a plugin requires them to find a person with a skill set that is not as common to find as finding another WordPress developer.
Don’t get me wrong…I LOVE writing PHP code and have a mad skill set that goes back to the early 2000s, so, CALL ME, if you have a challenging project. Here’s mentions of other custom PHP programming I’ve done.