Skip to content

Template overrides

Polski for WooCommerce renders its storefront output from PHP templates in wp-content/plugins/polski/templates/. To change one, copy it to a polski/ folder in your theme with the same subfolder path; the plugin then loads your copy. Email templates are the exception: they follow WooCommerce's own woocommerce/ override path.

  1. Find the original template in the plugin directory: wp-content/plugins/polski/templates/
  2. Copy the file to your theme directory: wp-content/themes/your-theme/polski/
  3. Preserve the subdirectory structure
  4. Modify the copied file

The plugin will automatically detect the template in your theme and use it instead of the default.

Example: to override the Omnibus price on the product page, copy:

wp-content/plugins/polski/templates/single-product/omnibus-price.php

to:

wp-content/themes/your-theme/polski/single-product/omnibus-price.php

The plugin looks the file up with WordPress's locate_template(), so the order is:

  1. wp-content/themes/child-theme/polski/
  2. wp-content/themes/parent-theme/polski/
  3. wp-content/plugins/polski/templates/
Template file Description
single-product/omnibus-price.php Omnibus lowest price
single-product/unit-price.php Unit price
single-product/tax-info.php VAT notice
single-product/shipping-notice.php Shipping costs notice
single-product/delivery-time.php Delivery time
single-product/manufacturer.php Manufacturer information
single-product/brand.php Brand
single-product/gpsr-info.php GPSR information
single-product/safety-info.php Safety information
single-product/consumer-info.php Consumer information
single-product/green-claim.php Environmental claim
single-product/food-info.php Food information
single-product/featured-video.php Featured video
single-product/waitlist-form.php Waitlist form
single-product/wishlist-button.php Wishlist button
single-product/compare-button.php Compare button
Template file Description
loop/omnibus-price.php Omnibus lowest price
loop/unit-price.php Unit price
loop/delivery-time.php Delivery time
loop/brand.php Brand
loop/wishlist-button.php Wishlist button
loop/compare-button.php Compare button
loop/quick-view-button.php Quick view button
archive/infinite-scroll.php Infinite scroll
Template file Description
checkout/legal-checkboxes.php Legal checkboxes at checkout, registration and pay-for-order
forms/withdrawal-form.php Withdrawal form
forms/withdrawal-guest.php Withdrawal form for guests
forms/withdrawal-lookup.php Order lookup for guest withdrawal
forms/dsa-report.php DSA report form
forms/ajax-search.php AJAX search
forms/ajax-filters.php AJAX filters
account/withdrawal-confirm.php Withdrawal confirmation in My Account
account/wishlist.php Wishlist in My Account
account/compare.php Comparison in My Account
Template file Description
shared/product-slider.php Product slider
shared/badges.php Product badges
shared/popup.php Popup
shared/quick-view-modal.php Quick view modal
shared/gallery-lightbox.php Gallery lightbox
quick-view/content.php Quick view content

The withdrawal and double opt-in emails are WooCommerce emails. Override them the WooCommerce way, in yourtheme/woocommerce/:

Template file Override path
emails/withdrawal-confirmation.php yourtheme/woocommerce/emails/withdrawal-confirmation.php
emails/withdrawal-completed.php yourtheme/woocommerce/emails/withdrawal-completed.php
emails/withdrawal-rejected.php yourtheme/woocommerce/emails/withdrawal-rejected.php
emails/admin-withdrawal-notification.php yourtheme/woocommerce/emails/admin-withdrawal-notification.php
emails/double-opt-in.php yourtheme/woocommerce/emails/double-opt-in.php

Each has a plain-text twin in emails/plain/.

The invoice document (invoice/document.php) is loaded directly from the plugin and cannot be overridden from the theme.

Every variable passed to a template gets a polski_ prefix, so it cannot clash with your theme's variables. Each template lists its variables in the header comment. Example for single-product/omnibus-price.php:

<?php
/**
* @var string $polski_omnibus_price_html The formatted Omnibus price HTML.
* @var WC_Product $polski_product The product object.
*/
defined('ABSPATH') || exit;
echo $polski_omnibus_price_html;

Keeping overridden templates up to date

Section titled "Keeping overridden templates up to date"

The plugin does not stamp templates with a version number and does not check your theme for outdated copies. After a plugin update, compare your overridden file with the current one in wp-content/plugins/polski/templates/ yourself, for example with a diff tool, and carry over any changes.

Hook Type Arguments Use
polski/template/path filter string $path (full file path), string $template (e.g. single-product/omnibus-price.php) Load a different file
polski/template/args filter array $args, string $template Add or change template variables before the prefix is applied
// Load the Omnibus template from a plugin of your own
add_filter('polski/template/path', function (string $path, string $template): string {
if ($template === 'single-product/omnibus-price.php') {
return WP_PLUGIN_DIR . '/my-shop/templates/omnibus-price.php';
}
return $path;
}, 10, 2);

Where do I put an overridden Polski template?

Section titled "Where do I put an overridden Polski template?"

In wp-content/themes/your-theme/polski/, keeping the subfolder, for example polski/single-product/omnibus-price.php. A child theme's copy wins over the parent theme's.

Why is my variable undefined in an overridden template?

Section titled "Why is my variable undefined in an overridden template?"

Template variables carry a polski_ prefix: use $polski_product, not $product. The header comment of each template lists the names.

How do I override the withdrawal confirmation email?

Section titled "How do I override the withdrawal confirmation email?"

Copy emails/withdrawal-confirmation.php to yourtheme/woocommerce/emails/, as with any WooCommerce email.

Report issues: github.com/wppoland/polski/issues

This page is for informational purposes only and does not constitute legal advice. Consult a lawyer before implementation. Polski for WooCommerce is open source software (GPLv2) provided without warranty.