WooCommerce

Reference And Troubleshooting

This reference collects the supported WooCommerce tags, values, and common fixes after you understand the beginner flow.

Product Contexts#

Product values and product collections are available in:

  • {{ query:products }}...{{ /query:products }}
  • {{ query:product }}...{{ /query:product }} as a singular alias
  • resources/views/archive-product.php
  • resources/views/taxonomy-product_cat.php
  • resources/views/taxonomy-product_cat-{slug}.php
  • resources/views/single-product.php
  • Any path that ends with /single-product.php
  • resources/views/woocommerce/single-product.php
  • Files under resources/views/woocommerce/single-product/

Use product values such as {{ price_html }} only in those contexts.

In taxonomy-product_cat.php and taxonomy-product_cat-{slug}.php, {{ query:product }} and {{ query:products }} inherit the current product category automatically. Use {{ category_name }} outside the product loop for the current category name; inside the loop, {{ title }} is the product title.

Product category archive filenames must use WordPress taxonomy hierarchy names:

FileApplies to
taxonomy-product_cat-dames.phpOnly the dames product category.
taxonomy-product_cat.phpEvery WooCommerce product category.
archive-product.phpProduct archive/shop fallback.

page-dames.php is for a WordPress page with the slug dames. category-dames.php is for normal blog post categories. Neither one targets WooCommerce product category archives.

Product Category URLs#

By default, WooCommerce product URLs use a fixed product base such as:

text
/product/notre-v/

TemplateX can opt into category-path product URLs from TemplateX > Settings > WooCommerce. Turn on Product URLs From Categories to generate product links from WooCommerce product categories:

text
/dames/hakken/notre-v/

For that example, the product is assigned to the hakken product category, and hakken is a child of dames.

TemplateX saves WooCommerce's native product permalink setting with the custom base /%product_cat%. WooCommerce then registers the product rewrite rules and fills the category placeholder in product links.

Products assigned to multiple categories use the category WooCommerce chooses for the product permalink, normally the deepest category path. Wrong category paths for an existing product are left for WooCommerce's canonical redirect behavior.

The normal WooCommerce Permalinks screen treats that exact root-level category base as invalid and rewrites it to /product/%product_cat%, so use the TemplateX toggle when the site intentionally wants no fixed product base.

This setting removes the fixed /product/ base, so URL paths need to stay unambiguous. Avoid creating a page, product category, and product that would all want the same path. After changing the setting, TemplateX flushes rewrite rules. Add 301 redirects yourself for any old product URLs that are already indexed or shared externally.

Product Tags And Values#

SyntaxKindUse
{{ query:products }}...{{ /query:products }}Paired tagLoop over products.
{{ query:product }}...{{ /query:product }}Paired tagSingular alias for the product loop.
{{ cart:add }}...{{ /cart:add }}Paired tagRender an add-to-cart form for the current product.
{{ product:image }}Value tagRender the current product image and update it when a variation is selected.
{{ images }}...{{ /images }}Paired tagLoop over all product images, with the featured image first.
{{ gallery_images }}...{{ /gallery_images }}Paired tagLoop over only WooCommerce gallery images.
{{ categories }}...{{ /categories }}Paired tagLoop over product categories.
{{ tags }}...{{ /tags }}Paired tagLoop over product tags.
{{ attributes }}...{{ /attributes }}Paired tagLoop over product attributes.
{{ options }}...{{ /options }}Paired tagLoop over product variation options.
{{ variations }}...{{ /variations }}Paired tagLoop over available variation data.
{{ variation:select for="attribute" }}Value tagRender a select control for one variation attribute.
{{ variation:pills for="attribute" }}...{{ /variation:pills }}Paired tagRender pill choices for one variation attribute.
{{ variation:radios for="attribute" }}...{{ /variation:radios }}Paired tagRender radio-style choices for one variation attribute.

Product value tags:

ValueNotes
product_idWooCommerce product ID.
priceRaw price value.
regular_priceRegular price.
sale_priceSale price.
discountDiscount percentage as a number, such as 20 for 20% off.
price_htmlWooCommerce formatted price HTML.
skuSKU.
stock_statusRaw stock status.
stock_quantityStock quantity.
in_stockUseful in conditionals.
on_saleUseful in conditionals.
purchasableUseful before showing purchase UI.
typeProduct type.
descriptionProduct description HTML.
short_descriptionShort description HTML.
average_ratingRating number.
rating_countRating count.
review_countReview count.
rating_htmlWooCommerce rating HTML.
weightProduct weight.
dimensionsProduct dimensions.

These are value tags. Do not add closing tags to them.

Raw price values are numeric. Use {{ price | currency }}, {{ regular_price | currency }}, or {{ sale_price | currency }} for WooCommerce currency formatting. Use {{ discount | percent }} to render a numeric discount as a percentage.

When a selected variation has its own description or short_description, that variation text is used. When the variation description is empty, TemplateX falls back to the parent product description.

Add-to-cart arguments:

ArgumentNotes
open_cartUse open_cart to open the first available cart drawer when the form submits.
variation_urlUse variation_url to keep the current URL in sync with the selected variation and restore that variation from shared URLs.

Product image arguments:

ArgumentNotes
classApplied to the generated <img>.
sizeWordPress image size to request. Default is full. Not rendered as an HTML attribute.
altOptional alt text override. If omitted, TemplateX uses the attachment alt text.
Any valid image attributePassed through to the generated <img>, for example loading, decoding, or fetchpriority.

Variation control arguments:

ArgumentTagsNotes
forAll variation controlsAttribute slug, taxonomy name, submitted input name, or label.
attributeAll variation controlsAlias for for.
classAll variation controlsApplied to the select or each generated choice button.
active_classvariation:pills, variation:radiosAdded when a choice is selected.
selected_classvariation:pills, variation:radiosAlias for active_class.
unavailable_classvariation:pills, variation:radiosAdded when a choice is out of stock or otherwise unavailable. Hover variant classes and cursor-pointer are removed for unavailable choices.
disabled_classvariation:pills, variation:radiosAlias for unavailable_class.
non_active_class or inactive_classvariation:pills, variation:radiosAlias for unavailable_class. Prefer unavailable_class so the state is not confused with an unselected choice.
unavailableAll variation controlsdisable, hide, or show. Default is disable.
placeholdervariation:selectOptional empty first option.
imagevariation:pills, variation:radiosUse variation or auto to expose variation image values; use none to skip images.

Choice values inside variation:pills and variation:radios:

ValueNotes
labelHuman label.
valueSubmitted WooCommerce value.
slugSanitized slug.
selectedWhether the choice is currently selected.
availableWhether at least one matching variation is in stock and purchasable.
image.src, image.alt, image.width, image.heightVariation image data when available.
price, regular_price, sale_price, discount, price_htmlMatching variation price data.
sku, stock_status, stock_quantityMatching variation inventory data.
prices.min, prices.max, prices.htmlAggregate price data when multiple variations match a choice.
variationsMatching variation rows for advanced output.

Cart Tags And Values#

SyntaxKindUse
{{ cart }}...{{ /cart }}Paired tagStart a cart context.
{{ cart:items }}...{{ /cart:items }}Paired tagLoop over cart items.
{{ cart:trigger }}...{{ /cart:trigger }}Paired tagRender a cart drawer trigger button.
{{ cart:overlay }}...{{ /cart:overlay }}Paired tagRender a cart drawer overlay.
{{ cart:panel }}...{{ /cart:panel }}Paired tagRender a drawer panel.
{{ cart:close }}...{{ /cart:close }}Paired tagRender a drawer close button.
{{ cart:update }}...{{ /cart:update }}Paired tagRender an item quantity update form.
{{ cart:remove }}...{{ /cart:remove }}Paired tagRender an item remove form.
{{ coupon }}...{{ /coupon }}Paired tagRender a coupon form.
{{ notices }}Value tagPrint WooCommerce notices.

Cart value tags inside {{ cart }}:

ValueNotes
count or item_countCart item count.
cart_urlCart page URL.
checkout_urlCheckout page URL.
subtotalFormatted subtotal.
totalFormatted total.

Cart drawer triggers open on click by default. Add open_on="hover" or the shorthand hover to {{ cart:trigger }} when the drawer should also open on hover. Open drawers close with {{ cart:close }}, Escape, backdrop clicks, or any click outside the active overlay.

Cart item value tags inside {{ cart:items }}:

ValueNotes
keyCart item key.
product_idProduct ID.
titleProduct title.
url or permalinkProduct URL. Variation cart items include variation_id and selected attribute_* query parameters.
quantityQuantity.
priceFormatted unit price.
line_totalFormatted line total.
line_subtotalFormatted line subtotal.
product_image, featured_image, featured, or image_urlImage URL.
thumbnail_urlThumbnail URL.
thumbnail or imageWooCommerce image HTML.
remove_urlRemove URL.

Checkout Tags And Values#

SyntaxKindUse
{{ checkout }}Value tagRender WooCommerce's full checkout.
{{ checkout }}...{{ /checkout }}Paired tagStart a custom checkout context.
{{ checkout:form }}...{{ /checkout:form }}Paired tagRender the checkout form.
{{ checkout:billing }}...{{ /checkout:billing }}Paired tagLoop over billing fields.
{{ checkout:shipping }}...{{ /checkout:shipping }}Paired tagLoop over shipping fields.
{{ checkout:account }}...{{ /checkout:account }}Paired tagLoop over account fields.
{{ checkout:order_fields }}...{{ /checkout:order_fields }}Paired tagLoop over order note fields.
{{ checkout:fields group="billing" }}...{{ /checkout:fields }}Paired tagLoop over an explicit field group.
{{ checkout:order }}Value tagPrint order review.
{{ checkout:payment }}Value tagPrint payment methods.
{{ checkout:submit }}...{{ /checkout:submit }}Paired tagRender the place-order button.

Checkout field value tags:

ValueNotes
keyField key.
idField ID.
nameInput name.
typeField type.
labelLabel text.
placeholderPlaceholder text.
descriptionDescription text.
requiredRequired flag.
valueCurrent value.
priorityField priority.
classField wrapper classes.
input_classInput classes.
label_classLabel classes.
autocompleteAutocomplete value.
optionsSelect option collection.
inputInput markup only.
fieldFull WooCommerce field markup.

{{ input }} and {{ field }} are value tags. Do not write closing tags for them.

Native Page Tags#

SyntaxKindUse
{{ my_account }}Value tagPrint WooCommerce My Account output.
{{ order_pay }}Value tagPrint WooCommerce order payment output.
{{ order_received }}Value tagPrint WooCommerce order received output.
{{ notices }}Value tagPrint WooCommerce notices.

Kebab-case aliases also work for the native page tags:

php
{{ my-account }}{{ order-pay }}{{ order-received }}

Email Template Overrides#

WooCommerce email overrides use native WooCommerce template paths under resources/views/woocommerce/emails/:

          • customer-completed-order.php
          • email-header.php
          • email-footer.php
          • email-styles.php

Those files compile and publish to the theme's native woocommerce/emails/ folder.

Common WooCommerce email variables:

VariableNotes
$orderThe WC_Order object for order emails.
$email_headingThe configured email heading.
$sent_to_adminWhether this email is for the store admin.
$plain_textWhether WooCommerce is rendering the plain text version.
$emailThe WooCommerce email object.

Email overrides are not product loop, cart, checkout, or account contexts. Use WooCommerce's email variables and hooks for order content.

Common Problems#

Product values print blank#

Check that the template is inside a product context. {{ price_html }} works inside {{ query:products }} and product-aware single product paths. It does not work on a normal page unless you first query products.

Product lists show everything#

Add limit:

php
{{ query:products limit="8" }}  <h2>{{ title }}</h2>{{ /query:products }}

Without limit, TemplateX asks WordPress for all matching products.

Add to cart does not render#

{{ cart:add }} needs a current product. Move it inside {{ query:products }} or a single product template.

Variable products do not choose a variation#

Prefer the generated variation controls inside {{ cart:add }}:

php
{{ variation:pills for="maat" }}  {{ label }}{{ /variation:pills }}{{ variation:select for="kleur" placeholder="Choose color" }}

TemplateX handles the WooCommerce field names, submitted values, and selected variation ID.

If you use raw {{ options }} loops instead, select controls should use name="{{ name }}". Radio controls inside {{ values }} should use name="{{ parent.name }}" and value="{{ value }}".

If selected variation values do not appear, make sure visible product values such as {{ price_html }}, {{ price }}, or {{ sale_price }} are printed near the matching {{ cart:add }} form.

Cart update or remove controls behave strangely#

{{ cart:update }} and {{ cart:remove }} render forms. Do not place them inside another form.

Checkout payment methods are missing#

Use plain {{ checkout }} first. If you use a custom checkout layout, include {{ checkout:payment }} inside {{ checkout:form }}.

WooCommerce notices disappear#

Use one clear {{ notices }} location per page. WooCommerce can clear notices after rendering them.