Removing unnecessary text elements from order confirmation pages results in an easier-to-understand layout & keeps the focus on essential order details. In the context of WooCommerce, store owners often seek the removal of the ‘Shipping Via’ text from the Thank You and View Order pages. Usually, store owners customize the WooCommerce Thank You page often as that page appears right after an order is placed. So you could present further options like an upsell, order bumps, etc.
This post provides a guide on how to hide the “Shipping Via” text on the WooCommerce view order page.
Where to Add Custom Code in WooCommerce
It is advisable to add the code snippets to the functions.php file of your child theme. Access the file directly from Appearance->Theme File Editor->Locating the child theme’s functions.php from the right sidebar. You can also access it from your theme’s directory file. Insert the following code snippet in functions.php. The alternative & easy option is to install the Code Snippets plugin. You can then add the code as a new snippet via the plugin.
Solution: Hiding the “Shipping Via” text on WooCommerce View Order Page
Below is the code snippet, that helps to hide the “Shipping via” text on both the WooCommerce View Order & Thank You page.
add_filter( 'woocommerce_order_shipping_to_display_shipped_via', '__return_empty_string' );
In the below output, an order details and its shipping method i.e. “Via Flat rate” text has got hidden on the view order page.
Here, another output shows the ” Via Flat rate” text has also got hidden on the thank you page after the checkout page as shown below.
This code snippet uses the add_filter function to modify the display of the shipping information on the order details page in WooCommerce.
The woocommerce_order_shipping_to_display_shipped_via filter is used to control how the shipped via information is displayed. In this case, the __return_empty_string function is used to return an empty string, effectively hiding the shipped via information from being shown. Also, this function is a valuable tool within the WooCommerce ecosystem that allows you to control the display of shipping information on your order-related pages.
Let us know your feedback on how the code was useful or any other queries in the comments section.