Move the price above the title on a WooCommerce product page with a visual builder and you usually ship several hundred extra DOM nodes, a second layer of frontend JavaScript, and slower variation dropdowns, all for a change that takes two lines of PHP. Searching woocommerce how to edit product page mostly turns up builder tutorials. This guide covers the three methods WooCommerce itself is designed around: action hooks, template overrides, and block templates. Each one is update-safe, measurable, and leaves your Core Web Vitals intact.
Table of Contents
- Why Builders Break Product Page Performance
- How the Single Product Template Renders
- Hook Priority Reference Table
- Method 1: Edit the Product Page With PHP Hooks
- Method 2: Template Overrides in a Child Theme
- Method 3: Block Templates in the Site Editor
- Choosing the Right Method
- Measuring the Result: DOM Depth, LCP and INP
- Troubleshooting Product Page Edits
- Related Content
Why Builders Break Product Page Performance
The product page is the most JavaScript-heavy template in a WooCommerce store before checkout.
It already loads the gallery stack (zoom, PhotoSwipe lightbox, FlexSlider), the variation form script, wc-add-to-cart-variation, and usually a reviews script. A visual builder then wraps every summary element in its own container, column, and widget wrapper, and adds its own runtime to animate, lazy-load, and re-render those wrappers.
Three numbers decide whether that trade is acceptable:
- DOM size. Lighthouse starts warning at roughly 800 body nodes and flags pages above about 1,400. It also reports trees deeper than 32 levels and parents with more than 60 children. Every wrapper adds style recalculation and layout work on each interaction.
- INP (Interaction to Next Paint). INP replaced FID as a Core Web Vital on 12 March 2024. Good is 200 ms or less, poor is above 500 ms. On a product page, the interactions that matter are variation dropdown changes, quantity steppers, gallery thumbnail clicks, and the add-to-cart button. Each one triggers jQuery handlers that query and mutate the DOM, so a deeper tree means a slower paint.
- LCP (Largest Contentful Paint). Good is 2.5 s or less. The LCP element on most product pages is the main gallery image, and WooCommerce renders the gallery wrapper with an inline
opacity: 0until its script initialises. Chrome does not count an invisible element as the LCP candidate until it becomes visible, so a slow script chain pushes LCP back directly.
Verdict: a builder is a layout tool, not a performance tool. If your change is “reorder, remove, or insert,” WooCommerce already exposes a hook for it.
How the Single Product Template Renders
In a classic theme, single-product.php loads content-single-product.php, which is mostly a sequence of do_action() calls. Every visible element on the page is a callback attached to one of those actions, at a specific priority. Lower numbers run first. Callbacks sharing a priority run in the order they were added.
graph TD
A[woocommerce_before_single_product] --> B[Priority 10 Store Notices]
B --> C[woocommerce_before_single_product_summary]
C --> D[Priority 10 Sale Flash]
D --> E[Priority 20 Product Images]
E --> F[woocommerce_single_product_summary]
F --> G[Priority 5 Title]
G --> H[Priority 10 Rating and Price]
H --> I[Priority 20 Short Description]
I --> J[Priority 30 Add to Cart Form]
J --> K[Priority 40 SKU and Categories]
K --> L[Priority 50 Sharing]
L --> M[Priority 60 Structured Data]
M --> N[woocommerce_after_single_product_summary]
N --> O[Priority 10 Tabs]
O --> P[Priority 15 Upsells]
P --> Q[Priority 20 Related Products]
Q --> R[woocommerce_after_single_product]
The outer wrapper hooks sit in single-product.php: woocommerce_before_main_content (content wrapper at 10, breadcrumbs at 20), woocommerce_after_main_content, and woocommerce_sidebar. Everything a shopper actually looks at lives between woocommerce_before_single_product_summary and woocommerce_after_single_product_summary.
Hook Priority Reference Table
These defaults are registered in wp-content/plugins/woocommerce/includes/wc-template-hooks.php. To remove a callback, remove_action() must use the exact same hook, function name, and priority.
| Hook | Priority | Callback | Renders |
|---|---|---|---|
woocommerce_before_single_product |
10 | woocommerce_output_all_notices |
“Added to cart” and error notices |
woocommerce_before_single_product_summary |
10 | woocommerce_show_product_sale_flash |
Sale badge |
woocommerce_before_single_product_summary |
20 | woocommerce_show_product_images |
Main image and gallery |
woocommerce_single_product_summary |
5 | woocommerce_template_single_title |
Product <h1> |
woocommerce_single_product_summary |
10 | woocommerce_template_single_rating |
Star rating and review count |
woocommerce_single_product_summary |
10 | woocommerce_template_single_price |
Price HTML |
woocommerce_single_product_summary |
20 | woocommerce_template_single_excerpt |
Short description |
woocommerce_single_product_summary |
30 | woocommerce_template_single_add_to_cart |
Quantity, variation form, button |
woocommerce_single_product_summary |
40 | woocommerce_template_single_meta |
SKU, categories, tags |
woocommerce_single_product_summary |
50 | woocommerce_template_single_sharing |
woocommerce_share action output |
woocommerce_single_product_summary |
60 | WC_Structured_Data::generate_product_data |
Product schema (no visible markup) |
woocommerce_after_single_product_summary |
10 | woocommerce_output_product_data_tabs |
Description, attributes, reviews tabs |
woocommerce_after_single_product_summary |
15 | woocommerce_upsell_display |
Upsells |
woocommerce_after_single_product_summary |
20 | woocommerce_output_related_products |
Related products grid |
Leave priority 60 alone. Removing it strips the Product structured data that feeds rich results.
Method 1: Edit the Product Page With PHP Hooks
Hooks are the default answer. They survive WooCommerce updates, add zero template files to maintain, and add no markup beyond what you print.
Put the code in a child theme’s functions.php or, better, a must-use plugin at wp-content/mu-plugins/kx-product-layout.php. A mu-plugin keeps working if someone switches themes, and it can’t be deactivated from the Plugins screen by accident.
Reorder, Remove and Insert Summary Elements
<?php
/**
* Plugin Name: Kinetix Product Page Layout
* Description: Single product layout changes through WooCommerce hooks. No template copies.
*/
defined( 'ABSPATH' ) || exit;
add_action( 'wp', function () {
if ( ! function_exists( 'is_product' ) || ! is_product() ) {
return;
}
// 1. Price above the title: title stays at 5, price moves from 10 to 4.
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 4 );
// 2. Drop the SKU/category/tag block (40) and the sharing slot (50).
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
// 3. Insert a shipping note after the add-to-cart form (30).
add_action( 'woocommerce_single_product_summary', 'kx_shipping_note', 35 );
// 4. Remove upsells entirely; keep related products.
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
} );
function kx_shipping_note() {
global $product;
if ( ! $product instanceof WC_Product || ! $product->is_in_stock() ) {
return;
}
printf(
'<p class="kx-shipping-note">%s</p>',
esc_html__( 'Ships within 24 hours. Free returns for 30 days.', 'kinetix-child' )
);
}
Why the wp action? It fires after the main query is parsed, so is_product() returns a real answer, and it runs before any template output starts. Running the removals at the top level of functions.php also works, but you lose the ability to scope them to product pages.
Priority 4 is not a hack. It is simply “earlier than the title at 5.” If you need room for several inserts, use gaps: 25 and 27 between the short description (20) and the add-to-cart form (30), 45 between meta (40) and sharing (50).
Edit the Tabs Without Touching Templates
The tabs area is controlled by the woocommerce_product_tabs filter. Core tabs ship at priorities 10 (Description), 20 (Additional information), and 30 (Reviews).
add_filter( 'woocommerce_product_tabs', function ( $tabs ) {
// Remove the attribute table if your short description already covers specs.
unset( $tabs['additional_information'] );
// Show reviews first.
if ( isset( $tabs['reviews'] ) ) {
$tabs['reviews']['priority'] = 5;
}
// Add a custom tab fed by post meta.
$tabs['kx_care'] = array(
'title' => __( 'Care guide', 'kinetix-child' ),
'priority' => 25,
'callback' => 'kx_render_care_tab',
);
return $tabs;
}, 98 );
function kx_render_care_tab() {
$care = get_post_meta( get_the_ID(), '_kx_care_guide', true );
if ( $care ) {
echo wp_kses_post( wpautop( $care ) );
}
}
// Three related products in three columns instead of four.
add_filter( 'woocommerce_output_related_products_args', function ( $args ) {
$args['posts_per_page'] = 3;
$args['columns'] = 3;
return $args;
} );
Priority 98 on the tabs filter is deliberate: it runs after most extensions have added their own tabs, so your ordering wins.
Cut Gallery JavaScript You Don’t Use
Each gallery feature is opt-in through add_theme_support(), and each one pulls in a script:
| Theme support flag | Script it loads | Remove it when |
|---|---|---|
wc-product-gallery-zoom |
jQuery Zoom | Product photos are already high resolution in the lightbox |
wc-product-gallery-lightbox |
PhotoSwipe (JS and CSS) | You use a single hero image per product |
wc-product-gallery-slider |
FlexSlider | Thumbnails are enough, or the product has one image |
add_action( 'after_setup_theme', function () {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-slider' );
}, 20 );
Priority 20 matters here: most themes declare support at the default priority of 10, and you can only remove what has already been added.
With the slider gone, the gallery no longer needs to stay hidden while its script loads. One CSS rule removes the opacity: 0 delay on the LCP image:
.woocommerce div.product .woocommerce-product-gallery {
opacity: 1 !important;
}
Keep the slider enabled? Then leave this rule out, or shoppers will see the unstyled image stack for a frame before FlexSlider takes over.
If your variable products are large, the variation form is the other big INP cost on this template. The threshold and payload tuning in our guide to adding WooCommerce product variations without database bloat pairs directly with the layout changes above.
Method 2: Template Overrides in a Child Theme
Use an override when you need to change markup structure, not just order. Copy the file from the plugin into your theme, keeping the same path under a woocommerce/ folder:
wp-content/plugins/woocommerce/templates/single-product/tabs/tabs.php
→ wp-content/themes/your-child-theme/woocommerce/single-product/tabs/tabs.php
WooCommerce’s wc_locate_template() checks the child theme first, then the parent theme, then the plugin.
Good use case: replacing the jQuery tab widget with native <details> accordions. The browser handles the open and close state, so no click handler runs and the interaction cost on mobile drops to almost nothing.
<?php
/**
* Single product tabs rendered as native <details> accordions.
*
* Override of woocommerce/templates/single-product/tabs/tabs.php.
* Keep the @version line from the copy you started from so
* WooCommerce > Status > Templates can flag it when core changes.
*/
defined( 'ABSPATH' ) || exit;
$product_tabs = apply_filters( 'woocommerce_product_tabs', array() );
if ( empty( $product_tabs ) ) {
return;
}
?>
<div class="woocommerce-tabs kx-accordion">
<?php foreach ( $product_tabs as $key => $product_tab ) : ?>
<details class="kx-accordion__item" id="tab-<?php echo esc_attr( $key ); ?>" <?php echo 'description' === $key ? 'open' : ''; ?>>
<summary class="kx-accordion__title">
<?php echo wp_kses_post( apply_filters( 'woocommerce_product_' . $key . '_tab_title', $product_tab['title'], $key ) ); ?>
</summary>
<div class="kx-accordion__panel">
<?php
if ( isset( $product_tab['callback'] ) ) {
call_user_func( $product_tab['callback'], $key, $product_tab );
}
?>
</div>
</details>
<?php endforeach; ?>
<?php do_action( 'woocommerce_product_after_tabs' ); ?>
</div>
.kx-accordion__item { border-top: 1px solid rgb(0 0 0 / 0.1); }
.kx-accordion__title { cursor: pointer; padding: 1rem 0; font-weight: 600; list-style: none; }
.kx-accordion__title::-webkit-details-marker { display: none; }
.kx-accordion__panel { padding-bottom: 1.25rem; }
The filter calls stay intact, so the custom tab from Method 1 and any extension tabs still render.
The cost of overrides is maintenance. Every WooCommerce release that touches the original file makes your copy stale. Check WooCommerce > Status > System status > Templates after each major update; outdated overrides are listed with both version numbers.
Edge case: the "(x customer reviews)" link no longer opens the reviews tab
WooCommerce’s single-product.js handles clicks on .woocommerce-review-link by triggering a click on .reviews_tab a. That element no longer exists, so nothing happens, though nothing breaks either. Add a tiny handler that opens the right <details> element:
document.addEventListener('click', (event) => {
const link = event.target.closest('.woocommerce-review-link');
if (!link) return;
const reviews = document.getElementById('tab-reviews');
if (reviews) {
reviews.open = true;
reviews.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
The same approach handles deep links like /product/hoodie/#tab-reviews: check location.hash on load and set open on the matching element.
Method 3: Block Templates in the Site Editor
On a block theme, the PHP template files above are not used. The single product page is a block template, editable at Appearance > Editor > Templates > Single Product, and stored either in the database (after you edit it) or in your theme at:
wp-content/themes/your-block-theme/templates/single-product.html
A trimmed example of the summary column:
<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column {"width":"55%"} -->
<div class="wp-block-column" style="flex-basis:55%">
<!-- wp:woocommerce/product-image-gallery /-->
</div>
<!-- /wp:column -->
<!-- wp:column {"width":"45%"} -->
<div class="wp-block-column" style="flex-basis:45%">
<!-- wp:woocommerce/product-price {"isDescendentOfSingleProductTemplate":true} /-->
<!-- wp:post-title {"level":1} /-->
<!-- wp:woocommerce/product-rating {"isDescendentOfSingleProductTemplate":true} /-->
<!-- wp:post-excerpt /-->
<!-- wp:woocommerce/add-to-cart-form /-->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
<!-- wp:woocommerce/product-details /-->
Reordering here is drag and drop, and the output is plain block markup: no builder runtime, no shortcode parsing. Start from your own export (Site Editor > Templates > Single Product > ⋮ > Export) rather than pasting the snippet above; WooCommerce adds styling attributes that differ between versions. If you are building the surrounding theme from scratch, our full walkthrough on WordPress custom block theme development with theme.json v3 (Coming soon) covers how templates, parts and design tokens fit together.
Two block names get confused often:
woocommerce//single-productis the template ID for the product page itself.woocommerce/single-productis the Single Product block, which places one specific product, with its own inner blocks, inside any page or post. Use it for landing pages, not for the product template.
Need your PHP hooks from Method 1 on a block theme? Replace the template contents with the classic template block, and the full classic hook chain runs again:
<!-- wp:woocommerce/legacy-template {"template":"single-product"} /-->
Theme compatibility: do my hooks fire on a block template without the legacy block?
Mostly, yes. WooCommerce ships a compatibility layer (SingleProductTemplateCompatibility) that fires the classic actions such as woocommerce_before_single_product_summary and woocommerce_single_product_summary around the matching blocks, and removes the default callbacks whose job is already done by a block. That means:
- Custom callbacks you add (like
kx_shipping_noteat priority 35) usually render in roughly the expected position. - Calls that remove or reorder core callbacks (moving the price to priority 4) often have no visible effect, because the price block renders the price, not the callback. Reorder the blocks instead.
- If you delete a block from the template, the compatibility layer adapts its hook placement, so test after every structural change.
Rule of thumb: on a block theme, structure lives in the template, and hooks are only for inserting extra output.
Choosing the Right Method
| Criterion | PHP hooks | Template override | Block template | Visual builder |
|---|---|---|---|---|
| Update safety | High: no copied files | Medium: copies go stale | High: core blocks update with WooCommerce | Low: depends on builder and its WooCommerce add-on |
| Extra DOM nodes | Only what you print | Only what you write | Block wrappers, usually one level each | Several wrapper levels per widget |
| Extra JavaScript | None | None, or less (native <details>) |
Per-block scripts, loaded only where used | Builder runtime plus widget scripts |
| Version control | Plain PHP in Git | Plain PHP in Git | HTML in Git, or DB if edited in UI | Serialized JSON in wp_postmeta |
| Best for | Reorder, remove, insert | Structural markup changes | Block themes, visual editing by store staff | Prototyping, then rebuild |
Our verdict is simple. Start with hooks. Override a template only when the markup itself has to change. On a block theme, edit the template and keep it in Git.
Kinetix follows the same rule as a theme: a block-editor-first framework with a clean hook architecture and no builder runtime. Layout changes go through hooks and templates you can diff, not serialized builder data. The Kinetix user guide explains how its templates and companion plugin fit together, and the release changelog records every template-level change by version, which is the same habit you want for your own overrides.
Measuring the Result: DOM Depth, LCP and INP
Measure before and after every change. Paste this into the DevTools console on a product page:
const nodes = document.querySelectorAll('body *');
let maxDepth = 0;
nodes.forEach((el) => {
let depth = 0;
for (let n = el; n.parentElement; n = n.parentElement) depth++;
if (depth > maxDepth) maxDepth = depth;
});
console.table({ nodes: nodes.length, maxDepth });
Then open the Performance panel. Current Chrome builds show live LCP, CLS, and INP for your own interactions: change a variation dropdown five times, click a gallery thumbnail, and press add to cart. Any interaction above 200 ms is worth tracing.
The ranges below are typical of what we see when auditing single product pages with one variable product, a four-image gallery, and three tabs. Use them as orientation, not as a promise; your theme, extensions and product data will move the numbers.
| Build approach | Body nodes | Max DOM depth | Gallery LCP risk | INP on variation change |
|---|---|---|---|---|
| Classic theme, hooks only | 700 to 1,100 | 14 to 18 | Low if slider removed | Usually under 200 ms |
| Block theme, edited template | 800 to 1,300 | 16 to 22 | Low | Usually under 200 ms |
| Visual builder product template | 1,800 to 3,500 | 25 to 35 | Medium to high | Often 200 to 500 ms on mid-range Android |
The product page is only half of the equation. Server response time, unused core scripts, and conditional asset loading decide how quickly any of this markup reaches the browser, which is the subject of our follow-up on WordPress speed optimization without plugin stacking (Coming soon). And once a shopper clicks Add to Cart, carry the same zero-builder discipline into your payment step with our guide on how to edit the WooCommerce checkout page without a builder (Coming soon).
Troubleshooting Product Page Edits
remove_action() runs but the element still appears
Three causes, in order of frequency:
- Wrong priority.
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price' )without the third argument tries priority 10 by default, which happens to be right for the price but wrong for the excerpt (20) or meta (40). - Your theme replaced the callback. Many commercial themes remove WooCommerce’s default and add their own function at the same spot. Inspect what is actually attached:
add_action( 'woocommerce_single_product_summary', function () {
if ( current_user_can( 'manage_options' ) && isset( $_GET['kx_hooks'] ) ) {
global $wp_filter;
echo '<pre>';
print_r( array_map( 'array_keys', $wp_filter['woocommerce_single_product_summary']->callbacks ) );
echo '</pre>';
}
}, 1 );
Load the product with ?kx_hooks as an administrator, then remove the function name you actually see.
- You’re on a block template. See the compatibility accordion in Method 3: reorder the blocks rather than the callbacks.
The template override is ignored
- Check the path. It must be
your-theme/woocommerce/single-product/..., mirroring the plugin’stemplates/folder exactly. A missingsingle-product/segment is the usual culprit. - On a block theme, PHP templates under
woocommerce/only load inside thewoocommerce/legacy-templateblock. - Another plugin may be filtering
wc_get_templateorwoocommerce_locate_template. Temporarily disable extensions to confirm.
Prices or buttons show twice after editing a block template
You likely have both a block and a hooked callback producing the same output, for example a Product Price block plus a custom add_action() that re-adds woocommerce_template_single_price. Remove the hook and let the block handle it. Clear page cache and any object cache afterwards, since template HTML is often cached at the edge.
Moving away from a builder without losing the layout
Rebuild the product template first, on staging, with hooks or a block template. Then disable the builder’s WooCommerce template assignment, not the whole builder, so marketing pages keep working while product pages switch over. Compare DOM size and INP before deleting anything. If a page-builder layout is still required for some pages, use a full-width canvas template for those pages only; the Kinetix troubleshooting FAQ covers how that works with page builders.
Related Content
- How to Add Product Variations in WooCommerce (Without Wrecking Your Database): global attributes, bulk pricing, and the 30-variation AJAX threshold that decides how fast the variation form you just repositioned responds.
- WordPress Speed Optimization Without a Plugin (Coming soon): strip core bloat, dequeue WooCommerce assets where they aren’t used, and fix
wp_optionsautoload so your clean product template reaches the browser faster. - WordPress Custom Block Theme Development: Full FSE Guide (Coming soon): architect
theme.jsonschema v3 tokens, HTML block templates, and PHP block patterns with zero builder overhead.