WC Shortcodes

Here is a list of the provided shortcodes that you can use in WooCommerce dynamic templates.

Product data

[lc_wc_product]

Returns a string with the value of a WooCommerce product object property. This is the most direct way to get raw product data. Generally useful to display small data, values, product name, price etc. Check out also the other shortcodes if you need to display data in a more structured way.

Attributes:

  • get: the desired property name. EG: id, name, description, or see the list below. Defaults to "name".
  • filter: optional filter function name to run against the result.  You can  use any php built-in or custom function accepting one argument.

Examples:

Returns the product name.
The second example is with a demo filter function.

[lc_wc_product get="name"]
[lc_wc_product get="name" filter="lc_to_uppercase"]

Returns the product price

[lc_wc_product get="price_html"]

Returns the product short description, converting newlines into breaks

[lc_wc_product get="short_description" filter="wpautop"]

HTML Examples:

<!-- Product Title -->
 <h1 class="display-2 fw-bolder">[ lc_wc_product get="name"]</h1>
<!-- END Product Title -->

 

<!-- Product Desc -->
<div class="lead text-secondary-400 mb-4">
    [ lc_wc_product get="short_description" filter="wpautop"]
</div>
 
<!-- END Product Desc -->

Full list of valid values for the get parameter

Parameter Description Formatted Parameter
id Returns the unique ID for this object. get="id"
description Get product description. get="description"
formatted_name Get product name with SKU or ID. Used within admin. get="formatted_name"
featured If the product is featured. get="featured"
name Get product name. get="name"
title Get the product's title. For products this is the product name. get="title"
type Get internal type. Should return string and should be overridden by child classes. get="type"
virtual Get virtual. get="virtual"
total_sales Get number total of sales. get="total_sales"
short_description Get product short description. get="short_description"
sku Get SKU (Stock-keeping unit) – product unique ID. get="sku"
slug Get product slug. get="slug"
status Get product status. get="status"
permalink Product permalink. get="permalink"
catalog_visibility Get catalog visibility. get="catalog_visibility"

Pricing Data:

Parameter Description Formatted Parameter
price Returns the product's active price. get="price"
date_on_sale_from Get date on sale from. get="date_on_sale_from"
date_on_sale_to Get date on sale to. get="date_on_sale_to"
display_price Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting. get="display_price"
price_excluding_tax Returns the price (excluding tax) – ignores tax_class filters since the price may *include* tax and thus needs subtracting. get="price_excluding_tax"
price_html Returns the price in html format. get="price_html"
price_html_from_text Functions for getting parts of a price, in html, used by price_html. get="price_html_from_text"
price_html_from_to Functions for getting parts of a price, in html, used by price_html. get="price_html_from_to"
price_including_tax Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes. get="price_including_tax"
price_suffix Get the suffix to display after prices > 0. get="price_suffix"
sale_price Returns the product's sale price. get="sale_price"
regular_price Returns the product's regular price. get="regular_price"
tax_class Returns the tax class. get="tax_class"
tax_status Returns the tax status. get="tax_status"

Stock or Inventory Data:

Parameter Description Formatted Parameter
backorders Get backorders. get="backorders"
availability Returns the availability of the product. get="availability"
max_purchase_quantity Get max quantity which can be purchased at once. get="max_purchase_quantity"
min_purchase_quantity Get min quantity which can be purchased at once. get="min_purchase_quantity"
stock_managed_by_id If the stock level comes from another product ID, this should be modified. get="stock_managed_by_id"
stock_quantity Returns number of items available for sale. get="stock_quantity"
stock_status Return the stock status. get="stock_status"
total_stock Get total stock - This is the stock of parent and children combined. get="total_stock"
sold_individually Return if should be sold individually. get="sold_individually"
low_stock_amount Get low stock amount get="low_stock_amount"

Shipping Data:

Parameter Description Formatted Parameter
height Returns the product height. get="height"
length Returns the product length. get="length"
weight Returns the product's weight get="weight"
width Returns the product width. get="width"
dimensions Returns formatted dimensions. get="dimensions"
manage_stock Return if product manage stock. get="manage_stock"
shipping_class Returns the product shipping class SLUG. get="shipping_class"
shipping_class_id Get shipping class ID. get="shipping_class_id"

Ratings and Reviews: 

Parameter Description Formatted Parameter
rating_count Get the total amount (COUNT) of ratings, or just the count for one rating e.g. number of 5 star ratings. get="rating_count"
rating_counts Get rating count. get="rating_counts"
rating_html Returns the product rating in html format. get="rating_html"
review_count Get review count. get="review_count"
reviews_allowed Return if reviews is allowed. get="reviews_allowed"
average_rating Get average rating. get="average_rating"

Product Categories

[lc_the_terms]

You can use the lc_the_terms shortcode to print the relevant product categories as links or span elements.

You can optionally use the parent parameter to display only childs of a specific category.

Example:

[lc_the_terms taxonomy="product_cat" class="badge rounded-pill bg-info" link="0" parent=""] 

Product Category

[lc_wc_product_category]

Returns the product category. Returns the category name or the category page URL.

Attributes:

  • get  Leave parameter empty to get the category name or set to "url" to retrieve the category page URL.

Example:

[lc_wc_product_category get="url"]
 <a href="[lc_wc_product_category get='url']">[lc_wc_product_category]</a>

On sale

[lc_wc_on_sale_badge]

If the product is on sale, it returns a customisable HTML element, a badge by default.

If the product is not on sale, it returns an empty value.

Attributes:

  • class  (Defaults to: badge bg-success rounded-pill) Set the class for the SPAN html element
  • label The label text, defaults to: Sale!

Example:

[lc_wc_on_sale_badge class="badge bg-success rounded-pill"]

Reviews

[lc_wc_rating]

Returns average product rating as HTML star rating. Useful for archive templates: displays review data in a concise way.

Attributes:

  • none

Example:

[lc_wc_rating]

Related Products

Returns related products, using the WooCommerce template: 'single-product/related.php'

Attributes:

  • columns
  • posts_per_page
  • orderby
  • order

Example:

[lc_wc_related columns="4" posts_per_page="4" orderby="rand" order="desc"]

Carousel

Returns the product images as a Bootstrap 5 Carousel.
Shows the main product image as the first carousel item, then includes all gallery items, and then product variation images.

Attributes:

  • image_class  The CSS class for the images

Example:

[lc_wc_carousel]

Add To Cart form

[lc_wc_product_add_to_cart]

Returns the product add to cart form. This is the one to use on the product page.

Attributes:

  • None

Example:

[lc_wc_product_add_to_cart]

Notices

[lc_wc_notices]

Returns the WooCommerce notices (messages) as HTML.
Eg, the "product added to cart" message.

Attributes:

  • None

Example:

[lc_wc_notices]

 

Product Rating

[lc_wc_product_rating]

Returns the full rating information. Useful in the the single product page.
It does basically recall the WooCommerce template: 'single-product/rating.php'. If there are reviews, it does also display a button to scroll and open the appropriate Reviews tab.

Attributes:

  • None

Example:

[lc_wc_product_rating]

Description tab

[lc_wc_product_tab_description]

Returns the product description, prepending the "Description" label. Uses the specific tab content template: 'single-product/tabs/description.php'

Attributes:

  • None

Example:

[lc_wc_product_tab_description]

 

Additional Information tab

[lc_wc_product_tab_additional_information]

Returns the product additional information, using the content template: 'single-product/tabs/additional-information.php'

Attributes:

  • None
[lc_wc_product_tab_additional_information]

Reviews Tab

[lc_wc_product_tab_reviews]

Returns the Woocommerce product reviews and the new review form.

Attributes:

  • None

Example:

[lc_wc_product_tab_reviews]

 

WooCommerce Text Labels (Multilanguage)

[lc_wc_label]

Returns Woocommerce label content. Translates it if appropriate.

Attributes:

  • Text The text to return

Example:

[lc_wc_label text="Hello"]

Loop: Add To Cart

[lc_wc_add_to_cart]

Returns the "add to cart" link for the loop.

Attributes:

  • Class the CSS Class for the link element

Example:

[lc_wc_add_to_cart]

Loop: Order by

[lc_wc_order_by]

Returns the Woocommerce Select element for product sorting.

Attributes:

  • None

Example:

[lc_wc_order_by]

Loop: Number of Results

[lc_wc_result_count]

Returns the number of results message, eg: Showing 1-12 of 17 results

Attributes:

  • None

Example:

[lc_wc_result_count]

Retrieving WooCommerce page URLs

[lc_wc_get_page_url]

Returns URLs  for the WooCommerce - specific pages.

Attributes:

  • page Defaults to "shop". Accepted values include myaccount, edit_address, shop, cart, checkout, pay, view_order, terms.

Example:

[lc_wc_get_page_url]

WooCommerce Filters Sidebar (typically for Shop Page)

[lc_wc_sidebar]

Returns the WooCommerce Shop Sidebar. You can customize the widgets using the Customizer.

Attributes:

  • none  

Example:

 

[lc_wc_sidebar]

WooCommerce Blocks: Mini Cart

[lc_wc_block]

Returns a WooCommerce Gutenberg Block.
Especially useful to display the Mini Cart, which can be typically used in the site header.

Attributes:

  • name  The WooCommerce Gutenberg Block to retrieve.

Example:

[lc_wc_block name="mini-cart"]