Skip to main content

Product

Display WooCommerce product data in your templates. Requires WooCommerce to be active.

The Product provider inherits all Post fields — title, link, excerpt, thumbnail, dates, author, custom fields, and everything else. Only product-specific fields are listed here.

In the WC admin UI, post fields are renamed: content is the product Description, excerpt is the product Short Description.

Requires WooCommerce

The Product provider only activates when WooCommerce is active. If WooCommerce is deactivated, product fields return empty values. Post fields (title, link, etc.) still work because products are a custom post type.

How It Works

When you loop over products with post_type: 'product', use any variable name — Unblock detects the post type from each WP_Post and exposes the matching product fields automatically:

{% for product in get_posts({post_type: 'product', posts_per_page: 6}) %}
{{ product.title }}
{{ product.price | currency }}
{% endfor %}

You still have access to every Post field — product.title, product.thumbnail, product.excerpt, product.link, etc.

All Fields

FieldArgumentsReturnsDescription
skustringProduct SKU
product_typestringsimple, variable, grouped, or external
categoryTerm | nullPrimary product category (first product_cat term, comparable to a string)
categoriesTerm[]Product categories (product_cat taxonomy)
tagsTerm[]Product tags (product_tag taxonomy)
attributesarrayAll product attributes (normalized: name, label, value, taxonomy, visible, variation)
attributenamestringA single attribute formatted as a comma-separated string
variationslimitProduct[]Purchasable variations (variable products only)
variation_attributesarrayVariation's attribute selection (variations only, {slug: value})
pricestringEffective price (sale price if on sale, regular otherwise)
regular_pricestringRegular price
sale_pricestringSale price (empty if not on sale)
is_on_saleboolWhether the product is currently on sale
discount_percentfloat | nullDiscount percentage (null if not on sale)
price_htmlstringFull WooCommerce price HTML (includes <del> for sale)
date_on_sale_fromformatstring | nullSale start date (null if not scheduled)
date_on_sale_toformatstring | nullSale end date (null if not scheduled)
stock_quantityint | nullStock quantity (null if not tracked)
stock_statusstringinstock, outofstock, or onbackorder
is_in_stockboolWhether the product is in stock
is_on_backorderboolWhether currently on backorder
is_virtualboolWhether virtual (no shipping)
is_downloadableboolWhether downloadable
is_featuredboolWhether marked as featured
is_purchasableboolWhether the product can be added to the cart
min_purchase_quantityintMinimum purchase quantity
max_purchase_quantityintMaximum purchase quantity (-1 if unlimited)
weightstringProduct weight
lengthstringProduct length
widthstringProduct width
heightstringProduct height
dimensionsstringFormatted dimensions (L × W × H unit)
shipping_classstringShipping class slug
product_gallerylimitImage[]Gallery images (each is a full Image object)
upsellslimitProduct[]Upsell products (each is a full Product)
cross_sellslimitProduct[]Cross-sell products (each is a full Product)
relatedlimit, excludeProduct[]Related products auto-computed by WooCommerce. Default limit 5. Accepts positional args or a config object ({limit, exclude}).
total_salesintTotal units sold
average_ratingstringAverage rating (0–5, '0' by default)
review_countintNumber of reviews
add_to_cart_urlstringAdd to cart URL
add_to_cart_textstringAdd to cart button text

The currency filter

Formats a number as WooCommerce currency using wc_price(). Uses your store's configured currency symbol, thousand separator, and decimal settings.

{{ product.price | currency }}            <!-- $29.99 -->
{{ product.regular_price | currency }} <!-- $39.99 -->

Without currency, you get the raw number. With it, you get the formatted output matching your WooCommerce settings.

Common Patterns

Sale badge

{% if product.is_on_sale %}
<s>{{ product.regular_price | currency }}</s> -{{ product.discount_percent }}%
{% endif %}
{{ product.price | currency }}

Stock status

{% if product.is_in_stock %}In stock{% endif %}
{% if not product.is_in_stock %}Out of stock{% endif %}
{% for image in product.product_gallery %}
{{ image.src('thumbnail') }}
{{ image.alt }}
{% endfor %}

Upsells section

{% for upsell in product.upsells(4) %}
{{ upsell.thumbnail.src('medium') }}
{{ upsell.title }}
{{ upsell.price | currency }}
{% endfor %}
Common mistake

Don't forget the currency filter when displaying prices. Without it, product.price returns a raw number like 29.99 — no currency symbol, no formatting. Always use {{ product.price | currency }} to match your WooCommerce store settings.

Next Steps

  • Post provider — All inherited fields available on products
  • Image provider — Working with gallery images and thumbnails
  • Loop — Query and loop over products with get_posts