How to display product lead times elsewhere on your site
The WooCommerce Lead Time plugin can display product lead times on the single product page, shop page, product category pages, cart, checkout, and order details pages/emails. To ensure that the plugin works with all themes, we have coded it so that the lead time will only appear on the single product page, and not any other pages where your theme shows stock information.
We understand that you may sometimes wish to show lead times in order places where you display products, such as the shop or category pages. This article provides a choice of two methods for how to do this.
You may also like: How to change the position of the lead time on the product page
The lead time shortcode
WooCommerce Lead Time has a [lead_time]
 shortcode which you can use to display the lead time anywhere on your site.
Use [lead_time]
to show the lead time for the current product. This only works if you're using it on a single product page and it won't display anything if you use it elsewhere.
Use [lead_time id="123"]
to display the lead time for a specific product elsewhere in your store, replacing "123" with the ID of the relevant product.
Using WooCommerce Product Table
The simplest way to display lead times away from the single product page is to use our other plugin, WooCommerce Product Table.
WooCommerce Product Table lets you list any or all of your products anywhere on your site. You can either add it to standard pages in WordPress, or to your shop and category pages.
When you use WooCommerce Lead Time together with WooCommerce Product Table, you can add a lead_time
 column which displays the lead time within the product table.
Using WooCommerce Quick View Pro
If you don't want to list products in a table, then you can use another Barn2 plugin - WooCommerce Quick View Pro. This is also designed to work with WooCommerce Lead Time.
The plugin adds quick view buttons to your shop and category pages, allowing customers to view product information and purchase from a quick view lightbox instead of the single product page. Your lead times will appear in the lightbox, so it's an ideal way to show the lead time away from the product page.
Using WooCommerce Fast Cart
You can use WooCommerce Lead Time to display the lead time on the standard cart and checkout pages. If you don't want customers to have to visit separate pages to view these lead times and complete their order, then you can use WooCommerce Fast Cart instead.
This plugin works alongside WooCommerce Lead Time and the lead time appears in a popup cart and/or checkout. It's a great way for customers to complete their purchase without having to visit multiple pages.
Doing it programmatically
Alternatively, we have provided a template function so that you (or your developer)Â can display the lead time anywhere on your site.
Please note that this code is aimed at developers. If you feel comfortable using them, our article on how to use code snippets can serve as a guide. If you don't know how to use it, then we recommend posting a job on Codeable where one of their pre-approved WordPress experts will send you a quote. We have partnered with them to provide customizations for our plugins.
You can retrieve the product lead time for custom display by using one of the following template functions:
- wclt_get_lead_time - retrieves the lead time with the the suffix and prefix.
- wclt_get_lead_time_raw -Â retrieves the lead time without the the suffix and prefix.
As an example, below we retrieve the lead time within a product loop.
$product = wc_get_product( get_the_ID() ); $lead_time = wclt_get_lead_time( $product );